MXS-2304 Add ctor/dtor and other functions to parameter class

The manipulation functions are currently static so that the container can be initialized
if required. This will be fixed later.

The new functions are taken into use in monitor management.
This commit is contained in:
Esa Korhonen
2019-02-05 13:58:26 +02:00
parent 42b5c39f43
commit ed80680da9
8 changed files with 154 additions and 103 deletions

View File

@ -222,6 +222,7 @@ extern const char CN_LOG_TO_SHM[];
class MXS_CONFIG_PARAMETER
{
public:
~MXS_CONFIG_PARAMETER();
/**
* Get value of key as string.
@ -317,9 +318,42 @@ public:
*/
bool contains(const std::string& key) const;
char* name; /**< The name of the parameter */
char* value; /**< The value of the parameter */
MXS_CONFIG_PARAMETER* next; /**< Next pointer in the linked list */
/**
* Set a key-value combination. If the key doesn't exist, it is added. The function is static
* to handle the special case of params being empty. This is needed until the config management
* has been properly refactored.
*
* @param ppParams Double pointer to the parameters structure to edit
* @param key Parameter key
* @param value Value to set
*/
static void set(MXS_CONFIG_PARAMETER** ppParams, const std::string& key, const std::string& value);
/**
* Copy all key-value pairs from a set to this container. If a key doesn't exist, it is added.
*
* @param destination Destination of the copied parameters
* @param source Parameters to copy
*/
static void set_multiple(MXS_CONFIG_PARAMETER** destination, const MXS_CONFIG_PARAMETER* source);
/**
* Remove a key-value pair from the container.
*
* @param ppParams Parameters container
* @param key Key to remove
*/
static void remove(MXS_CONFIG_PARAMETER** ppParams, const std::string& key);
char* name {nullptr}; /**< The name of the parameter */
char* value {nullptr}; /**< The value of the parameter */
MXS_CONFIG_PARAMETER* next {nullptr}; /**< Next pointer in the linked list */
private:
/**
* TODO: Remove this once using STL container.
*/
MXS_CONFIG_PARAMETER* find(const std::string& key);
};
/**

View File

@ -458,21 +458,6 @@ bool mon_connection_is_ok(mxs_connect_result_t connect_result);
void mon_log_connect_error(MXS_MONITORED_SERVER* database, mxs_connect_result_t rval);
const char* mon_get_event_name(mxs_monitor_event_t event);
/**
* Alter monitor parameters
*
* The monitor parameters should not be altered while the monitor is
* running. To alter a parameter from outside a monitor module, stop the monitor,
* do the alteration and then restart the monitor. The monitor "owns" the parameters
* as long as it is running so if the monitor needs to change its own parameters,
* it can do it without stopping itself.
*
* @param monitor Monitor whose parameter is altered
* @param key Parameter name to alter
* @param value New value for the parameter
*/
void mon_alter_parameter(Monitor* monitor, const char* key, const char* value);
/**
* @brief Hangup connections to failed servers
*