Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages | Examples

ArClientHandlerConfig Class Reference

ArClientHandlerConfig processes the network packets that describe a robot's ArConfig. More...

#include <ArClientHandlerConfig.h>

List of all members.

Public Member Functions

void addGotConfigCB (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST)
 Adds a gotConfig callback.
void addGotConfigDefaultsCB (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST)
 Adds a got config defaults callback.
void addSaveConfigFailedCB (ArFunctor1< const char * > *functor, ArListPos::Pos position=ArListPos::LAST)
 Adds a save config to server failed callback.
void addSaveConfigSucceededCB (ArFunctor *functor, ArListPos::Pos position=ArListPos::LAST)
 Adds a save config to server succeeded callback.
 ArClientHandlerConfig (ArClientBase *client, bool ignoreBounds=false, const char *robotName=NULL)
 Constructor.
bool canRequestDefaults (void)
 Sees if we can request defaults (both types).
ArConfiggetConfig (void)
 Unthreadsafe way to get the config to play with (see long docs).
ArConfig getConfigCopy (void)
 Threadsafe way to get the config to play with.
ArConfiggetDefaultConfig ()
 Returns a pointer to the robot server's default configuration, if canRequestDefaults() is true.
void handleGetConfig (ArNetPacket *packet)
 Handles the packet from the getConfig.
void handleGetConfigBySections (ArNetPacket *packet)
 Handles the packet from the GetConfigBySections.
void handleGetConfigDefaults (ArNetPacket *packet)
 Handles the return packet from getConfigDefaults.
void handleGetConfigSectionFlags (ArNetPacket *packet)
 Handles the packet from the GetConfigSectionFlags.
void handleSetConfig (ArNetPacket *packet)
 Handles the return packet from the setConfig (saveConfigToServer).
bool haveGottenConfig (void)
 Returns true if config gotten.
bool haveGottenDefaults (void)
 Returns if we've gotten our requested defaults.
bool haveRequestedDefaults (void)
 Returns if we've requested some defaults.
int lock (void)
 Locks the config for if you're using the unthreadsafe getConfig.
void reloadConfigOnServer (void)
 Tells the server to reload the configuration.
void remGotConfigCB (ArFunctor *functor)
 Removes a gotConfig callback.
void remGotConfigDefaultsCB (ArFunctor *functor)
 Removes a got config defaults callback.
void remSaveConfigFailedCB (ArFunctor1< const char * > *functor)
 Removes a save config to server failed callback.
void remSaveConfigSucceededCB (ArFunctor *functor)
 Removes a save config to server succeeded callback.
bool requestConfigDefaults (void)
 Requests defaults for all sections from the server; modifies the config.
void requestConfigFromServer (void)
 Requests the config from the server.
bool requestDefaultConfigFromServer (void)
bool requestSectionDefaults (const char *section)
 Requests defaults for one section from the server; modifies the config.
void saveConfigToServer (ArConfig *config, const std::set< std::string, ArStrCaseCmpOp > *ignoreTheseSections=NULL)
 Sends the config back to the server.
void saveConfigToServer (void)
 Sends the config back to the server.
int tryLock (void)
 Try to lock for the config for if you're using the unthreadsafe getConfig.
int unlock (void)
 Unlocks the config for if you're using the unthreadsafe getConfig.
virtual ~ArClientHandlerConfig (void)
 Destructor.

Protected Member Functions

void handleGetConfigData (ArNetPacket *packet, bool isMultiplePackets)

Protected Attributes

ArMutex myCallbackMutex
ArClientBasemyClient
ArConfig myConfig
ArMutex myDataMutex
ArConfigmyDefaultConfig
std::list< ArFunctor * > myGotConfigCBList
std::list< ArFunctor * > myGotConfigDefaultsCBList
ArFunctor1C< ArClientHandlerConfig,
ArNetPacket * > 
myHandleGetConfigBySectionsCB
ArFunctor1C< ArClientHandlerConfig,
ArNetPacket * > 
myHandleGetConfigCB
ArFunctor1C< ArClientHandlerConfig,
ArNetPacket * > 
myHandleGetConfigDefaultsCB
ArFunctor1C< ArClientHandlerConfig,
ArNetPacket * > 
myHandleGetConfigSectionFlagsCB
ArFunctor1C< ArClientHandlerConfig,
ArNetPacket * > 
myHandleGetDefaultConfigCB
ArFunctor1C< ArClientHandlerConfig,
ArNetPacket * > 
myHandleSetConfigCB
bool myHaveGottenConfig
bool myHaveGottenDefaults
bool myHaveRequestedDefaultCopy
bool myHaveRequestedDefaults
std::string myLogPrefix
std::string myRobotName
std::list< ArFunctor1< const
char * > * > 
mySaveConfigFailedCBList
std::list< ArFunctor * > mySaveConfigSucceededCBList


Detailed Description

ArClientHandlerConfig processes the network packets that describe a robot's ArConfig.

It also provides a means to save the modified configuration data to the robot server. This class is designed to work in conjunction with the ArServerHandlerConfig. See the server handler documentation for a complete description of the networking interface.

This class should be thread safe, with the exception of unThreadSafeGetConfig. (If you want to use this method, surround it with calls to lock() and unlock().)

Note that you can't add callbacks or remove callbacks from within a callback function.

Definition at line 48 of file ArClientHandlerConfig.h.


Constructor & Destructor Documentation

ArClientHandlerConfig::ArClientHandlerConfig ArClientBase client,
bool  ignoreBounds = false,
const char *  robotName = NULL
 

Constructor.

Parameters:
client the client base to attach to
ignoreBounds whether the ArConfig we have should ignore bounds or not, this should only be used for debugging

Definition at line 43 of file ArClientHandlerConfig.cpp.

References client, myClient, myConfig, myHaveGottenConfig, myHaveGottenDefaults, myHaveRequestedDefaultCopy, myHaveRequestedDefaults, myLogPrefix, myRobotName, and ArConfig::setConfigName().

ArClientHandlerConfig::~ArClientHandlerConfig void   )  [virtual]
 

Destructor.

Definition at line 74 of file ArClientHandlerConfig.cpp.


Member Function Documentation

void ArClientHandlerConfig::addGotConfigCB ArFunctor functor,
ArListPos::Pos  position = ArListPos::LAST
 

Adds a gotConfig callback.

Definition at line 384 of file ArClientHandlerConfig.cpp.

References ArMutex::lock(), ArLog::log(), myCallbackMutex, myGotConfigCBList, and ArMutex::unlock().

Referenced by main().

void ArClientHandlerConfig::addGotConfigDefaultsCB ArFunctor functor,
ArListPos::Pos  position = ArListPos::LAST
 

Adds a got config defaults callback.

Definition at line 449 of file ArClientHandlerConfig.cpp.

References ArMutex::lock(), ArLog::log(), myCallbackMutex, myGotConfigDefaultsCBList, and ArMutex::unlock().

void ArClientHandlerConfig::addSaveConfigFailedCB ArFunctor1< const char * > *  functor,
ArListPos::Pos  position = ArListPos::LAST
 

Adds a save config to server failed callback.

Definition at line 427 of file ArClientHandlerConfig.cpp.

References ArMutex::lock(), ArLog::log(), myCallbackMutex, mySaveConfigFailedCBList, and ArMutex::unlock().

Referenced by main().

void ArClientHandlerConfig::addSaveConfigSucceededCB ArFunctor functor,
ArListPos::Pos  position = ArListPos::LAST
 

Adds a save config to server succeeded callback.

Definition at line 405 of file ArClientHandlerConfig.cpp.

References ArMutex::lock(), ArLog::log(), myCallbackMutex, mySaveConfigSucceededCBList, and ArMutex::unlock().

Referenced by main().

bool ArClientHandlerConfig::canRequestDefaults void   ) 
 

Sees if we can request defaults (both types).

Definition at line 488 of file ArClientHandlerConfig.cpp.

References ArClientBase::dataExists(), and myClient.

Referenced by main(), requestConfigDefaults(), requestDefaultConfigFromServer(), and requestSectionDefaults().

ArConfig * ArClientHandlerConfig::getConfig void   ) 
 

Unthreadsafe way to get the config to play with (see long docs).

Definition at line 330 of file ArClientHandlerConfig.cpp.

References myConfig.

Referenced by gotConfig().

ArConfig ArClientHandlerConfig::getConfigCopy void   ) 
 

Threadsafe way to get the config to play with.

Definition at line 351 of file ArClientHandlerConfig.cpp.

References ArMutex::lock(), myConfig, myDataMutex, and ArMutex::unlock().

ArConfig * ArClientHandlerConfig::getDefaultConfig void   ) 
 

Returns a pointer to the robot server's default configuration, if canRequestDefaults() is true.

Note that both requestConfigFromServer() and then requestDefaultConfigFromServer() must be called before a valid default configuration is available on the client. If there is no default configuration, then NULL is returned.

Definition at line 342 of file ArClientHandlerConfig.cpp.

References myDefaultConfig.

Referenced by main().

void ArClientHandlerConfig::handleGetConfig ArNetPacket packet  ) 
 

Handles the packet from the getConfig.

Definition at line 126 of file ArClientHandlerConfig.cpp.

References handleGetConfigData().

void ArClientHandlerConfig::handleGetConfigBySections ArNetPacket packet  ) 
 

Handles the packet from the GetConfigBySections.

Definition at line 121 of file ArClientHandlerConfig.cpp.

References handleGetConfigData().

void ArClientHandlerConfig::handleGetConfigData ArNetPacket packet,
bool  isMultiplePackets
[protected]
 

Definition at line 131 of file ArClientHandlerConfig.cpp.

References ArConfig::addParam(), ArClientArg::createArg(), ArConfigArg::getConfigPriority(), ArConfigArg::getDisplayHint(), IFDEBUG, ArMutex::lock(), ArConfig::log(), ArLog::log(), myCallbackMutex, myConfig, myDataMutex, myGotConfigCBList, myHaveGottenConfig, myLogPrefix, ArConfig::setSectionComment(), and ArMutex::unlock().

Referenced by handleGetConfig(), and handleGetConfigBySections().

void ArClientHandlerConfig::handleGetConfigDefaults ArNetPacket packet  ) 
 

Handles the return packet from getConfigDefaults.

Definition at line 594 of file ArClientHandlerConfig.cpp.

References ArArgumentBuilder::add(), ArConfig::clearAllValueSet(), IFDEBUG, ArMutex::lock(), ArLog::log(), myConfig, myDataMutex, myDefaultConfig, myHaveRequestedDefaultCopy, myHaveRequestedDefaults, myLogPrefix, myRobotName, ArConfig::parseArgument(), ArConfig::parseSection(), ArConfig::setConfigName(), ArArgumentBuilder::setExtraString(), and ArMutex::unlock().

void ArClientHandlerConfig::handleGetConfigSectionFlags ArNetPacket packet  ) 
 

Handles the packet from the GetConfigSectionFlags.

Definition at line 216 of file ArClientHandlerConfig.cpp.

References ArConfig::addSectionFlags(), ArMutex::lock(), myConfig, myDataMutex, and ArMutex::unlock().

void ArClientHandlerConfig::handleSetConfig ArNetPacket packet  ) 
 

Handles the return packet from the setConfig (saveConfigToServer).

Definition at line 293 of file ArClientHandlerConfig.cpp.

References ArMutex::lock(), ArLog::log(), myCallbackMutex, myLogPrefix, mySaveConfigFailedCBList, mySaveConfigSucceededCBList, and ArMutex::unlock().

bool ArClientHandlerConfig::haveGottenConfig void   ) 
 

Returns true if config gotten.

Definition at line 375 of file ArClientHandlerConfig.cpp.

References ArMutex::lock(), myDataMutex, myHaveGottenConfig, and ArMutex::unlock().

bool ArClientHandlerConfig::haveGottenDefaults void   ) 
 

Returns if we've gotten our requested defaults.

Definition at line 479 of file ArClientHandlerConfig.cpp.

References ArMutex::lock(), myDataMutex, myHaveGottenDefaults, and ArMutex::unlock().

Referenced by main().

bool ArClientHandlerConfig::haveRequestedDefaults void   ) 
 

Returns if we've requested some defaults.

Definition at line 470 of file ArClientHandlerConfig.cpp.

References ArMutex::lock(), myDataMutex, myHaveRequestedDefaultCopy, myHaveRequestedDefaults, and ArMutex::unlock().

Referenced by requestConfigDefaults(), requestDefaultConfigFromServer(), and requestSectionDefaults().

int ArClientHandlerConfig::lock void   ) 
 

Locks the config for if you're using the unthreadsafe getConfig.

Definition at line 360 of file ArClientHandlerConfig.cpp.

References ArMutex::lock(), and myDataMutex.

void ArClientHandlerConfig::reloadConfigOnServer void   ) 
 

Tells the server to reload the configuration.

Definition at line 321 of file ArClientHandlerConfig.cpp.

References myClient, and ArClientBase::requestOnce().

void ArClientHandlerConfig::remGotConfigCB ArFunctor functor  ) 
 

Removes a gotConfig callback.

Definition at line 398 of file ArClientHandlerConfig.cpp.

References ArMutex::lock(), myCallbackMutex, myGotConfigCBList, and ArMutex::unlock().

void ArClientHandlerConfig::remGotConfigDefaultsCB ArFunctor functor  ) 
 

Removes a got config defaults callback.

Definition at line 463 of file ArClientHandlerConfig.cpp.

References ArMutex::lock(), myCallbackMutex, myGotConfigDefaultsCBList, and ArMutex::unlock().

void ArClientHandlerConfig::remSaveConfigFailedCB ArFunctor1< const char * > *  functor  ) 
 

Removes a save config to server failed callback.

Definition at line 441 of file ArClientHandlerConfig.cpp.

References ArMutex::lock(), myCallbackMutex, mySaveConfigFailedCBList, and ArMutex::unlock().

void ArClientHandlerConfig::remSaveConfigSucceededCB ArFunctor functor  ) 
 

Removes a save config to server succeeded callback.

Definition at line 419 of file ArClientHandlerConfig.cpp.

References ArMutex::lock(), myCallbackMutex, mySaveConfigSucceededCBList, and ArMutex::unlock().

bool ArClientHandlerConfig::requestConfigDefaults void   ) 
 

Requests defaults for all sections from the server; modifies the config.

Definition at line 493 of file ArClientHandlerConfig.cpp.

References canRequestDefaults(), haveRequestedDefaults(), ArMutex::lock(), ArLog::log(), myClient, myDataMutex, myHaveGottenDefaults, myHaveRequestedDefaultCopy, myHaveRequestedDefaults, myLogPrefix, ArClientBase::requestOnce(), and ArMutex::unlock().

void ArClientHandlerConfig::requestConfigFromServer void   ) 
 

Requests the config from the server.

Definition at line 83 of file ArClientHandlerConfig.cpp.

References ArClientBase::addHandler(), ArConfig::clearSections(), ArClientBase::dataExists(), ArMutex::lock(), myClient, myConfig, myDataMutex, myHandleGetConfigBySectionsCB, myHandleGetConfigCB, myHandleGetConfigDefaultsCB, myHandleGetConfigSectionFlagsCB, myHandleSetConfigCB, myHaveGottenConfig, ArClientBase::remHandler(), ArClientBase::requestOnce(), and ArMutex::unlock().

Referenced by main().

bool ArClientHandlerConfig::requestDefaultConfigFromServer void   ) 
 

Definition at line 524 of file ArClientHandlerConfig.cpp.

References canRequestDefaults(), haveRequestedDefaults(), ArMutex::lock(), ArLog::log(), myClient, myDataMutex, myHaveGottenDefaults, myHaveRequestedDefaultCopy, myHaveRequestedDefaults, myLogPrefix, ArClientBase::requestOnce(), and ArMutex::unlock().

Referenced by main().

bool ArClientHandlerConfig::requestSectionDefaults const char *  section  ) 
 

Requests defaults for one section from the server; modifies the config.

Definition at line 553 of file ArClientHandlerConfig.cpp.

References canRequestDefaults(), ArConfig::findSection(), haveRequestedDefaults(), ArMutex::lock(), ArLog::log(), myClient, myConfig, myDataMutex, myHaveGottenDefaults, myHaveRequestedDefaultCopy, myHaveRequestedDefaults, myLogPrefix, ArClientBase::requestOnceWithString(), and ArMutex::unlock().

void ArClientHandlerConfig::saveConfigToServer ArConfig config,
const std::set< std::string, ArStrCaseCmpOp > *  ignoreTheseSections = NULL
 

Sends the config back to the server.

Definition at line 241 of file ArClientHandlerConfig.cpp.

References ArClientArg::argTextToBuf(), ArConfigArg::getName(), ArConfigSection::getName(), ArConfigSection::getParams(), ArClientArg::isSendableParamType(), ArMutex::lock(), ArLog::log(), myClient, myDataMutex, myLogPrefix, ArClientBase::requestOnce(), ArBasePacket::strToBuf(), and ArMutex::unlock().

void ArClientHandlerConfig::saveConfigToServer void   ) 
 

Sends the config back to the server.

Definition at line 236 of file ArClientHandlerConfig.cpp.

References myConfig.

Referenced by gotConfig().

int ArClientHandlerConfig::tryLock void   ) 
 

Try to lock for the config for if you're using the unthreadsafe getConfig.

Definition at line 365 of file ArClientHandlerConfig.cpp.

References myDataMutex, and ArMutex::tryLock().

int ArClientHandlerConfig::unlock void   ) 
 

Unlocks the config for if you're using the unthreadsafe getConfig.

Definition at line 370 of file ArClientHandlerConfig.cpp.

References myDataMutex, and ArMutex::unlock().


Member Data Documentation

ArMutex ArClientHandlerConfig::myCallbackMutex [protected]
 

Definition at line 157 of file ArClientHandlerConfig.h.

Referenced by addGotConfigCB(), addGotConfigDefaultsCB(), addSaveConfigFailedCB(), addSaveConfigSucceededCB(), handleGetConfigData(), handleSetConfig(), remGotConfigCB(), remGotConfigDefaultsCB(), remSaveConfigFailedCB(), and remSaveConfigSucceededCB().

ArClientBase* ArClientHandlerConfig::myClient [protected]
 

Definition at line 153 of file ArClientHandlerConfig.h.

Referenced by ArClientHandlerConfig(), canRequestDefaults(), reloadConfigOnServer(), requestConfigDefaults(), requestConfigFromServer(), requestDefaultConfigFromServer(), requestSectionDefaults(), and saveConfigToServer().

ArConfig ArClientHandlerConfig::myConfig [protected]
 

Definition at line 154 of file ArClientHandlerConfig.h.

Referenced by ArClientHandlerConfig(), getConfig(), getConfigCopy(), handleGetConfigData(), handleGetConfigDefaults(), handleGetConfigSectionFlags(), requestConfigFromServer(), requestSectionDefaults(), and saveConfigToServer().

ArMutex ArClientHandlerConfig::myDataMutex [protected]
 

Definition at line 156 of file ArClientHandlerConfig.h.

Referenced by getConfigCopy(), handleGetConfigData(), handleGetConfigDefaults(), handleGetConfigSectionFlags(), haveGottenConfig(), haveGottenDefaults(), haveRequestedDefaults(), lock(), requestConfigDefaults(), requestConfigFromServer(), requestDefaultConfigFromServer(), requestSectionDefaults(), saveConfigToServer(), tryLock(), and unlock().

ArConfig* ArClientHandlerConfig::myDefaultConfig [protected]
 

Definition at line 155 of file ArClientHandlerConfig.h.

Referenced by getDefaultConfig(), and handleGetConfigDefaults().

std::list<ArFunctor *> ArClientHandlerConfig::myGotConfigCBList [protected]
 

Definition at line 149 of file ArClientHandlerConfig.h.

Referenced by addGotConfigCB(), handleGetConfigData(), and remGotConfigCB().

std::list<ArFunctor *> ArClientHandlerConfig::myGotConfigDefaultsCBList [protected]
 

Definition at line 152 of file ArClientHandlerConfig.h.

Referenced by addGotConfigDefaultsCB(), and remGotConfigDefaultsCB().

ArFunctor1C<ArClientHandlerConfig, ArNetPacket *> ArClientHandlerConfig::myHandleGetConfigBySectionsCB [protected]
 

Definition at line 163 of file ArClientHandlerConfig.h.

Referenced by requestConfigFromServer().

ArFunctor1C<ArClientHandlerConfig, ArNetPacket *> ArClientHandlerConfig::myHandleGetConfigCB [protected]
 

Definition at line 164 of file ArClientHandlerConfig.h.

Referenced by requestConfigFromServer().

ArFunctor1C<ArClientHandlerConfig, ArNetPacket *> ArClientHandlerConfig::myHandleGetConfigDefaultsCB [protected]
 

Definition at line 167 of file ArClientHandlerConfig.h.

Referenced by requestConfigFromServer().

ArFunctor1C<ArClientHandlerConfig, ArNetPacket *> ArClientHandlerConfig::myHandleGetConfigSectionFlagsCB [protected]
 

Definition at line 171 of file ArClientHandlerConfig.h.

Referenced by requestConfigFromServer().

ArFunctor1C<ArClientHandlerConfig, ArNetPacket *> ArClientHandlerConfig::myHandleGetDefaultConfigCB [protected]
 

Definition at line 169 of file ArClientHandlerConfig.h.

ArFunctor1C<ArClientHandlerConfig, ArNetPacket *> ArClientHandlerConfig::myHandleSetConfigCB [protected]
 

Definition at line 165 of file ArClientHandlerConfig.h.

Referenced by requestConfigFromServer().

bool ArClientHandlerConfig::myHaveGottenConfig [protected]
 

Definition at line 158 of file ArClientHandlerConfig.h.

Referenced by ArClientHandlerConfig(), handleGetConfigData(), haveGottenConfig(), and requestConfigFromServer().

bool ArClientHandlerConfig::myHaveGottenDefaults [protected]
 

Definition at line 160 of file ArClientHandlerConfig.h.

Referenced by ArClientHandlerConfig(), haveGottenDefaults(), requestConfigDefaults(), requestDefaultConfigFromServer(), and requestSectionDefaults().

bool ArClientHandlerConfig::myHaveRequestedDefaultCopy [protected]
 

Definition at line 161 of file ArClientHandlerConfig.h.

Referenced by ArClientHandlerConfig(), handleGetConfigDefaults(), haveRequestedDefaults(), requestConfigDefaults(), requestDefaultConfigFromServer(), and requestSectionDefaults().

bool ArClientHandlerConfig::myHaveRequestedDefaults [protected]
 

Definition at line 159 of file ArClientHandlerConfig.h.

Referenced by ArClientHandlerConfig(), handleGetConfigDefaults(), haveRequestedDefaults(), requestConfigDefaults(), requestDefaultConfigFromServer(), and requestSectionDefaults().

std::string ArClientHandlerConfig::myLogPrefix [protected]
 

Definition at line 147 of file ArClientHandlerConfig.h.

Referenced by ArClientHandlerConfig(), handleGetConfigData(), handleGetConfigDefaults(), handleSetConfig(), requestConfigDefaults(), requestDefaultConfigFromServer(), requestSectionDefaults(), and saveConfigToServer().

std::string ArClientHandlerConfig::myRobotName [protected]
 

Definition at line 146 of file ArClientHandlerConfig.h.

Referenced by ArClientHandlerConfig(), and handleGetConfigDefaults().

std::list<ArFunctor1<const char *> *> ArClientHandlerConfig::mySaveConfigFailedCBList [protected]
 

Definition at line 151 of file ArClientHandlerConfig.h.

Referenced by addSaveConfigFailedCB(), handleSetConfig(), and remSaveConfigFailedCB().

std::list<ArFunctor *> ArClientHandlerConfig::mySaveConfigSucceededCBList [protected]
 

Definition at line 150 of file ArClientHandlerConfig.h.

Referenced by addSaveConfigSucceededCB(), handleSetConfig(), and remSaveConfigSucceededCB().


The documentation for this class was generated from the following files:
Generated on Tue Feb 20 10:51:51 2007 for ArNetworking by  doxygen 1.4.0