#include <ArServerHandlerConfig.h>
Public Member Functions | |
void | addConfigUpdatedCallback (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST) |
Adds a callback to be called when the config is updated. | |
void | addPostWriteCallback (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST) |
Adds a callback to be called after writing to disk. | |
void | addPreWriteCallback (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST) |
Adds a callback to be called before writing to disk. | |
ArServerHandlerConfig (ArServerBase *server, ArConfig *config, const char *defaultFile=NULL, const char *defaultFileBaseDirectory=NULL) | |
bool | configUpdated (ArServerClient *client=NULL) |
Notifies the clients that the config was updated. | |
void | createEmptyConfigDefaults (void) |
Creates an empty default config... | |
void | getConfig (ArServerClient *client, ArNetPacket *packet) |
Handles the (deprecated) "getConfig" request. | |
void | getConfigBySections (ArServerClient *client, ArNetPacket *packet) |
Handles the "getConfigBySections" request. | |
void | getConfigDefaults (ArServerClient *client, ArNetPacket *packet) |
Handles the "getConfigDefaults" request. | |
void | getConfigSectionFlags (ArServerClient *client, ArNetPacket *packet) |
Handles the "getConfigSectionFlags" request. | |
bool | loadDefaultsFromFile (void) |
loads the whole of a default file (for internal use) | |
bool | loadDefaultsFromPacket (ArNetPacket *packet) |
Parses a line of the default config (for internal use). | |
int | lockConfig (void) |
Locks the config so we don't do anything with it. | |
void | reloadConfig (ArServerClient *client, ArNetPacket *packet) |
Handles the "reloadConfig" request. | |
void | remConfigUpdatedCallback (ArFunctor *functor) |
Removes a callback to be called when the config is updated. | |
void | remPostWriteCallback (ArFunctor *functor) |
Removes a callback to be called after writing to disk. | |
void | remPreWriteCallback (ArFunctor *functor) |
Removes a callback to be called before writing to disk. | |
void | setConfig (ArServerClient *client, ArNetPacket *packet) |
Handles the "setConfig" request. | |
int | tryLockConfig (void) |
Tries to lock the config so we don't do anything with it. | |
int | unlockConfig (void) |
Unlocks the config so we can use it again. | |
bool | writeConfig (void) |
Writes the config out. | |
virtual | ~ArServerHandlerConfig () |
Destructor. | |
Protected Member Functions | |
void | addDefaultServerCommands (void) |
Adds the default config callbacks;. | |
void | createDefaultConfig (const char *defaultFileBaseDir) |
just creates the default config... (internal, don't use) | |
void | handleGetConfig (ArServerClient *client, ArNetPacket *packet, bool isMultiplePackets) |
Helper method for getConfigBySections and getConfig. | |
bool | internalSetConfig (ArServerClient *client, ArNetPacket *packet) |
Internal method that handles a setConfig packet for myConfig or myDefaults. | |
Protected Attributes | |
bool | myAddedDefaultServerCommands |
ArConfig * | myConfig |
ArMutex | myConfigMutex |
std::list< ArFunctor * > | myConfigUpdatedCallbacks |
ArConfig * | myDefault |
ArMutex | myDefaultConfigMutex |
std::string | myDefaultFile |
std::string | myDefaultFileBaseDir |
ArFunctor2C< ArServerHandlerConfig, ArServerClient *, ArNetPacket * > | myGetConfigBySectionsCB |
ArFunctor2C< ArServerHandlerConfig, ArServerClient *, ArNetPacket * > | myGetConfigCB |
ArFunctor2C< ArServerHandlerConfig, ArServerClient *, ArNetPacket * > | myGetConfigDefaultsCB |
ArFunctor2C< ArServerHandlerConfig, ArServerClient *, ArNetPacket * > | myGetConfigSectionFlagsCB |
std::list< ArFunctor * > | myPostWriteCallbacks |
std::list< ArFunctor * > | myPreWriteCallbacks |
ArFunctor2C< ArServerHandlerConfig, ArServerClient *, ArNetPacket * > | myReloadConfigCB |
ArServerBase * | myServer |
ArFunctor2C< ArServerHandlerConfig, ArServerClient *, ArNetPacket * > | mySetConfigCB |
Since the packet structure for the ArConfig is rather complex, this class is best used in conjunction with the ArClientHandlerConfig.
This class handles the following requests:
A reply packet containing a string is sent to the client. If the string is empty, then the config was successfully updated. Otherwise, the string contains the name of the first parameter that caused an error during the update handling.
For each requested section, the reply packet contains:
If you are using this class with the default file option you'll want to make it AFTER you're done adding things to the config, ie last, so that the default code can work correctly (it needs to know about all the info).
Definition at line 108 of file ArServerHandlerConfig.h.
|
Definition at line 43 of file ArServerHandlerConfig.cpp. References ArServerBase::addData(), loadDefaultsFromFile(), myDefaultFile, myDefaultFileBaseDir, myGetConfigBySectionsCB, myGetConfigCB, myGetConfigSectionFlagsCB, myReloadConfigCB, myServer, and mySetConfigCB. |
|
Destructor.
Definition at line 106 of file ArServerHandlerConfig.cpp. |
|
Adds a callback to be called when the config is updated.
Definition at line 653 of file ArServerHandlerConfig.cpp. References ArLog::log(), and myConfigUpdatedCallbacks. |
|
Adds the default config callbacks;.
Definition at line 273 of file ArServerHandlerConfig.cpp. References ArServerBase::addData(), myAddedDefaultServerCommands, myGetConfigDefaultsCB, and myServer. Referenced by createEmptyConfigDefaults(), loadDefaultsFromFile(), and loadDefaultsFromPacket(). |
|
Adds a callback to be called after writing to disk.
Definition at line 635 of file ArServerHandlerConfig.cpp. References ArLog::log(), and myPostWriteCallbacks. |
|
Adds a callback to be called before writing to disk.
Definition at line 617 of file ArServerHandlerConfig.cpp. References ArLog::log(), and myPreWriteCallbacks. |
|
Notifies the clients that the config was updated.
Definition at line 704 of file ArServerHandlerConfig.cpp. References ArServerBase::broadcastPacketTcpWithExclusion(), client, myConfigUpdatedCallbacks, and myServer. Referenced by internalSetConfig(), and reloadConfig(). |
|
just creates the default config... (internal, don't use)
For internal use only. doesn't delete the old one, do that if you're going to call this yourself and make sure you lock around all that Definition at line 201 of file ArServerHandlerConfig.cpp. References ArConfig::addParam(), ArConfigArg::getBool(), ArConfigArg::getConfigPriority(), ArConfigArg::getDescription(), ArConfigArg::getDisplayHint(), ArConfigArg::getDouble(), ArConfigArg::getInt(), ArConfigArg::getMaxDouble(), ArConfigArg::getMaxInt(), ArConfigArg::getMinDouble(), ArConfigArg::getMinInt(), ArConfigSection::getName(), ArConfigArg::getName(), ArConfigSection::getParams(), ArConfig::getSections(), ArConfigArg::getString(), ArConfigArg::getType(), myConfig, and myDefault. Referenced by loadDefaultsFromFile(), and loadDefaultsFromPacket(). |
|
Creates an empty default config...
Definition at line 180 of file ArServerHandlerConfig.cpp. References addDefaultServerCommands(), ArServerBase::broadcastPacketTcp(), lockConfig(), myDefault, myServer, and unlockConfig(). |
|
Handles the (deprecated) "getConfig" request.
Definition at line 409 of file ArServerHandlerConfig.cpp. References client, and handleGetConfig(). |
|
Handles the "getConfigBySections" request.
Definition at line 400 of file ArServerHandlerConfig.cpp. References client, and handleGetConfig(). |
|
Handles the "getConfigDefaults" request.
Definition at line 544 of file ArServerHandlerConfig.cpp. References ArClientArg::argTextToBuf(), client, ArConfigArg::getName(), ArConfigSection::getName(), ArConfigSection::getParams(), ArConfig::getSections(), ArClientArg::isSendableParamType(), ArMutex::lock(), ArLog::log(), myConfigMutex, myDefault, ArClientBase::sendPacketTcp(), ArBasePacket::strToBuf(), and ArMutex::unlock(). |
|
Handles the "getConfigSectionFlags" request.
Definition at line 723 of file ArServerHandlerConfig.cpp. References ArBasePacket::byte4ToBuf(), client, ArConfigSection::getFlags(), ArConfigSection::getName(), ArConfig::getSections(), ArLog::log(), myConfig, ArClientBase::sendPacketTcp(), and ArBasePacket::strToBuf(). |
|
Helper method for getConfigBySections and getConfig.
Definition at line 290 of file ArServerHandlerConfig.cpp. References ArBasePacket::byteToBuf(), client, ArClientArg::createPacket(), ArNetPacket::empty(), ArConfigSection::getComment(), ArConfigArg::getName(), ArConfigSection::getName(), ArConfigSection::getParams(), ArConfig::getSections(), ArConfigArg::getType(), ArClientArg::isSendableParamType(), ArBasePacket::isValid(), ArLog::log(), myConfig, ArClientBase::sendPacketTcp(), and ArBasePacket::strToBuf(). Referenced by getConfig(), and getConfigBySections(). |
|
Internal method that handles a setConfig packet for myConfig or myDefaults.
Definition at line 430 of file ArServerHandlerConfig.cpp. References ArArgumentBuilder::add(), ArConfig::callProcessFileCallBacks(), client, configUpdated(), lockConfig(), ArLog::log(), myConfig, myDefault, ArConfig::parseArgument(), ArConfig::parseSection(), ArClientBase::sendPacketTcp(), ArArgumentBuilder::setExtraString(), ArBasePacket::strToBuf(), unlockConfig(), and writeConfig(). Referenced by loadDefaultsFromPacket(), and setConfig(). |
|
loads the whole of a default file (for internal use)
Definition at line 111 of file ArServerHandlerConfig.cpp. References addDefaultServerCommands(), ArServerBase::broadcastPacketTcp(), ArConfig::clearAllValueSet(), createDefaultConfig(), lockConfig(), ArLog::log(), myDefault, myDefaultFile, myDefaultFileBaseDir, myServer, ArConfig::parseFile(), ArConfig::removeAllUnsetValues(), and unlockConfig(). Referenced by ArServerHandlerConfig(). |
|
Parses a line of the default config (for internal use).
Definition at line 147 of file ArServerHandlerConfig.cpp. References addDefaultServerCommands(), ArServerBase::broadcastPacketTcp(), ArConfig::clearAllValueSet(), createDefaultConfig(), internalSetConfig(), lockConfig(), ArLog::log(), myDefault, myServer, ArConfig::removeAllUnsetValues(), and unlockConfig(). |
|
Locks the config so we don't do anything with it.
Definition at line 177 of file ArServerHandlerConfig.h. References ArMutex::lock(), and myConfigMutex. Referenced by createEmptyConfigDefaults(), internalSetConfig(), loadDefaultsFromFile(), and loadDefaultsFromPacket(). |
|
Handles the "reloadConfig" request.
Definition at line 537 of file ArServerHandlerConfig.cpp. References configUpdated(), ArConfig::getFileName(), myConfig, and ArConfig::parseFile(). |
|
Removes a callback to be called when the config is updated.
Definition at line 665 of file ArServerHandlerConfig.cpp. References myConfigUpdatedCallbacks. |
|
Removes a callback to be called after writing to disk.
Definition at line 647 of file ArServerHandlerConfig.cpp. References myPostWriteCallbacks. |
|
Removes a callback to be called before writing to disk.
Definition at line 629 of file ArServerHandlerConfig.cpp. References myPreWriteCallbacks. |
|
Handles the "setConfig" request.
Definition at line 420 of file ArServerHandlerConfig.cpp. References client, and internalSetConfig(). |
|
Tries to lock the config so we don't do anything with it.
Definition at line 179 of file ArServerHandlerConfig.h. References myConfigMutex, and ArMutex::tryLock(). |
|
Unlocks the config so we can use it again.
Definition at line 181 of file ArServerHandlerConfig.h. References myConfigMutex, and ArMutex::unlock(). Referenced by createEmptyConfigDefaults(), internalSetConfig(), loadDefaultsFromFile(), and loadDefaultsFromPacket(). |
|
Writes the config out.
Definition at line 671 of file ArServerHandlerConfig.cpp. References ArConfig::getFileName(), ArLog::log(), myConfig, myPostWriteCallbacks, myPreWriteCallbacks, and ArConfig::writeFile(). Referenced by internalSetConfig(). |
|
Definition at line 219 of file ArServerHandlerConfig.h. Referenced by addDefaultServerCommands(). |
|
Definition at line 212 of file ArServerHandlerConfig.h. Referenced by createDefaultConfig(), getConfigSectionFlags(), handleGetConfig(), internalSetConfig(), reloadConfig(), and writeConfig(). |
|
Definition at line 221 of file ArServerHandlerConfig.h. Referenced by getConfigDefaults(), lockConfig(), tryLockConfig(), and unlockConfig(). |
|
Definition at line 225 of file ArServerHandlerConfig.h. Referenced by addConfigUpdatedCallback(), configUpdated(), and remConfigUpdatedCallback(). |
|
Definition at line 215 of file ArServerHandlerConfig.h. Referenced by createDefaultConfig(), createEmptyConfigDefaults(), getConfigDefaults(), internalSetConfig(), loadDefaultsFromFile(), and loadDefaultsFromPacket(). |
|
Definition at line 218 of file ArServerHandlerConfig.h. |
|
Definition at line 216 of file ArServerHandlerConfig.h. Referenced by ArServerHandlerConfig(), and loadDefaultsFromFile(). |
|
Definition at line 217 of file ArServerHandlerConfig.h. Referenced by ArServerHandlerConfig(), and loadDefaultsFromFile(). |
|
Definition at line 227 of file ArServerHandlerConfig.h. Referenced by ArServerHandlerConfig(). |
|
Definition at line 228 of file ArServerHandlerConfig.h. Referenced by ArServerHandlerConfig(). |
|
Definition at line 231 of file ArServerHandlerConfig.h. Referenced by addDefaultServerCommands(). |
|
Definition at line 232 of file ArServerHandlerConfig.h. Referenced by ArServerHandlerConfig(). |
|
Definition at line 224 of file ArServerHandlerConfig.h. Referenced by addPostWriteCallback(), remPostWriteCallback(), and writeConfig(). |
|
Definition at line 223 of file ArServerHandlerConfig.h. Referenced by addPreWriteCallback(), remPreWriteCallback(), and writeConfig(). |
|
Definition at line 230 of file ArServerHandlerConfig.h. Referenced by ArServerHandlerConfig(). |
|
Definition at line 211 of file ArServerHandlerConfig.h. Referenced by addDefaultServerCommands(), ArServerHandlerConfig(), configUpdated(), createEmptyConfigDefaults(), loadDefaultsFromFile(), and loadDefaultsFromPacket(). |
|
Definition at line 229 of file ArServerHandlerConfig.h. Referenced by ArServerHandlerConfig(). |