pion::platform::ConfigManager Class Reference

#include <ConfigManager.hpp>

Inherited by pion::platform::PluginConfig< PluginType >, pion::platform::PluginConfig< pion::platform::Codec >, pion::platform::PluginConfig< pion::platform::Database >, pion::platform::PluginConfig< pion::platform::Protocol >, pion::platform::PluginConfig< pion::platform::Reactor >, pion::platform::PluginConfig< pion::server::PlatformService >, pion::platform::VocabularyConfig, pion::platform::VocabularyManager, pion::server::PlatformConfig, and pion::server::UserManager.

List of all members.


Detailed Description

ConfigManager: interface that manages XML configuration files

Definition at line 40 of file ConfigManager.hpp.

Public Member Functions

virtual ~ConfigManager ()
 virtual destructor
virtual void createConfigFile (void)
 creates a new config file and adds a root Pion "config" element
virtual void openConfigFile (void)
 opens an existing config file and finds the root Pion "config" element
void setConfigFile (const std::string &config_file)
 sets the name of the config file to use
const std::string & getConfigFile (void) const
 returns the name of the config file being used
bool configIsOpen (void) const
 returns true if the config file is open and being used
void setLogger (PionLogger log_ptr)
 sets the logger to be used
PionLogger getLogger (void)
 returns the logger currently in use
void setDataDirectory (const std::string &dir)
 sets the directory in which data files are stored
const std::string & getDataDirectory (void) const
 returns the directory in which data files are stored
void resetDataDirectory (void)
 resets the data file directory to the same path as the config file
void setDebugMode (bool b)
 sets the "debug mode" flag
bool getDebugMode (void) const
 returns true if pion is running in "debug mode"
void removeConfigFile (void)
 removes the config file (after backing it up)
virtual void writeConfigXML (std::ostream &out) const
std::string createUUID (void)
 returns a string containing a new UUID value
std::string createFilename (void)
 returns a unique XML filename based on a UUID
std::string createFilename (const std::string &file_path)
std::string resolveRelativePath (const std::string &orig_path) const
std::string resolveRelativeDataPath (const std::string &orig_path)
virtual bool creationAllowed (xmlNodePtr permission_config_ptr, xmlNodePtr config_ptr) const
virtual bool updateAllowed (xmlNodePtr permission_config_ptr, const std::string &id, xmlNodePtr config_ptr) const
virtual bool removalAllowed (xmlNodePtr permission_config_ptr, const std::string &id) const
virtual bool accessAllowed (xmlNodePtr permission_config_ptr, const std::string &plugin_id) const
virtual std::string getPermissionType (void) const
 returns the type attribute used for an XML Permission node pertaining to the type of plugin being managed

Static Public Member Functions

static xmlDocPtr getConfigFromFile (const std::string &config_file, const std::string &root_element_name, xmlNodePtr &config_ptr, PionLogger &logger)
static void writeConfigXML (std::ostream &out, xmlNodePtr config_node, bool include_siblings=false)
static void writeConfigXMLHeader (std::ostream &out)
static void writeBeginPionConfigXML (std::ostream &out)
static void writeEndPionConfigXML (std::ostream &out)
static void writeBeginPionStatsXML (std::ostream &out)
static void writeEndPionStatsXML (std::ostream &out)
static std::string xml_encode (const std::string &str)
 encodes strings so that they are safe for XML (this & that)
static xmlNodePtr createPluginConfig (const std::string &plugin_type)
static xmlNodePtr createResourceConfig (const std::string &resource_name, const char *buf, std::size_t len)
static bool getNodeId (xmlNodePtr config_node, std::string &node_id)
static xmlNodePtr findConfigNodeByName (const std::string &element_name, xmlNodePtr starting_node)
static xmlNodePtr findConfigNodeByContent (const std::string &element_name, const std::string &content_value, xmlNodePtr starting_node)
static xmlNodePtr findConfigNodeByAttr (const std::string &element_name, const std::string &attr_name, const std::string &attr_value, xmlNodePtr starting_node)
static bool getConfigOption (const std::string &option_name, std::string &option_value, const xmlNodePtr starting_node)
static bool getConfigOptionEmptyOk (const std::string &option_name, std::string &option_value, const xmlNodePtr starting_node)
static std::string getAttribute (const char *name, const xmlNodePtr ptr)
static std::string getAttribute (const std::string &name, const xmlNodePtr ptr)
template<typename ValueType>
static bool getConfigOption (const std::string &option_name, ValueType &option_value, const xmlNodePtr starting_node)
template<typename ValueType>
static bool getConfigOption (const std::string &option_name, ValueType &option_value, const ValueType &default_value, const xmlNodePtr starting_node)
static bool updateConfigOption (const std::string &option_name, const std::string &option_value, xmlNodePtr parent_node)
static std::string resolveRelativePath (const std::string &base_path_to_file, const std::string &orig_path)

Protected Member Functions

 ConfigManager (const std::string &default_config_file)
void closeConfigFile (void)
 closes the config file
void saveConfigFile (void)
 saves the config file (after backing up the existing copy)
void backupConfigFile (void)
 creates a backup copy of the config file (if it exists)
void openPluginConfig (const std::string &plugin_name)
bool setPluginConfig (xmlNodePtr plugin_node_ptr, xmlNodePtr config_ptr)
void setPluginConfig (const std::string &plugin_name, const std::string &plugin_id, const xmlNodePtr config_ptr)
void addPluginConfig (const std::string &plugin_name, const std::string &plugin_id, const std::string &plugin_type, const xmlNodePtr config_ptr=NULL)
void removePluginConfig (const std::string &plugin_name, const std::string &plugin_id)
virtual void addPluginNoLock (const std::string &plugin_id, const std::string &plugin_name, const xmlNodePtr config_ptr)

Protected Attributes

PionLogger m_logger
 primary logging interface used by this class
PionIdGenerator m_id_gen
 UUID generator.
std::string m_config_file
 name of the XML config file being used
std::string m_data_directory
 directory in which data files are stored (from platform configuration)
bool m_debug_mode
 true if pion is running in "debug mode"
xmlDocPtr m_config_doc_ptr
 pointer to the root of the XML document tree (if libxml support is enabled)
xmlNodePtr m_config_node_ptr
 pointer to the root configuration node ("config") in the XML document tree

Static Protected Attributes

static const std::string XML_FILE_EXTENSION = ".xml"
 extension added to the name of XML files
static const std::string BACKUP_FILE_EXTENSION = ".bak"
 extension added to the name of backup files
static const std::string CONFIG_NAMESPACE_URL = "http://purl.org/pion/config"
 URL associated with the Pion "config" namespace.
static const std::string ROOT_ELEMENT_NAME = "PionConfig"
 name of the root element for Pion XML config files
static const std::string STATS_ELEMENT_NAME = "PionStats"
 name of the statistics element for Pion XML config files
static const std::string PLUGIN_ELEMENT_NAME = "Plugin"
 name of the plug-in type element for Pion XML config files
static const std::string NAME_ELEMENT_NAME = "Name"
 name of the descriptive name element for Pion XML config files
static const std::string COMMENT_ELEMENT_NAME = "Comment"
 name of the comment element for Pion XML config files
static const std::string PION_VERSION_ATTRIBUTE_NAME = "pion_version"
 name of the attribute for the Pion version number
static const std::string ID_ATTRIBUTE_NAME = "id"
 name of the unique identifier attribute for Pion XML config files

Classes

class  AddPluginConfigException
 exception thrown if there is an error adding a plug-in to the config file More...
class  BadXMLBufferException
 exception thrown if the buffer is NULL or has length zero More...
class  ConfigAlreadyOpenException
 exception thrown if you try to open a config file when it is already open More...
class  ConfigFileExistsException
 exception thrown if you try to create a config file that already exists More...
class  ConfigFileVersionException
 exception thrown if the version of the config file is not compatible (upgrade required) More...
class  ConfigNotOpenException
 exception thrown if you try modifying something before opening the config file More...
class  EmptyPluginElementException
 exception thrown if the plug-in config does not include a plug-in element More...
class  EmptyPluginIdException
 exception thrown if the config file contains a plug-in with a missing identifier More...
class  InitializeRootConfigException
 exception thrown if there is an error initializing a new config file's root element More...
class  MissingConfigFileException
 exception thrown if you try to open a config file that does not exist More...
class  MissingResourceElementException
 exception thrown if the requested resource element is not found More...
class  MissingRootElementException
 exception thrown if the root configuration element is not found More...
class  ReadConfigException
 exception thrown if there is an error reading a config file More...
class  RemovePluginConfigException
 exception thrown if there is an error removing a plug-in from the config file More...
class  UpdateConfigException
 exception thrown if there is an error updating the configuration in memory More...
class  UpdatePluginConfigException
 exception thrown if there is an error updating a plug-in in the config file More...
class  WriteConfigException
 exception thrown if there is an error writing a config file More...
class  XMLBufferParsingException
 exception thrown if there is an error parsing XML from memory More...


Constructor & Destructor Documentation

pion::platform::ConfigManager::ConfigManager ( const std::string &  default_config_file  )  [inline, protected]

protected constructor: this should only be used by derived classes

Parameters:
default_config_file the default configuration file to use

Definition at line 590 of file ConfigManager.hpp.


Member Function Documentation

virtual bool pion::platform::ConfigManager::accessAllowed ( xmlNodePtr  permission_config_ptr,
const std::string &  plugin_id 
) const [inline, virtual]

determines whether a User has permission to use a plugin

Parameters:
permission_config_ptr the Permission node of the appropriate type from the User's configuration
plugin_id unique identifier associated with an existing plugin
Returns:
true if the User has permission

Reimplemented in pion::platform::ReactionEngine.

Definition at line 569 of file ConfigManager.hpp.

Referenced by pion::server::UserManager::accessAllowed().

void pion::platform::ConfigManager::addPluginConfig ( const std::string &  plugin_name,
const std::string &  plugin_id,
const std::string &  plugin_type,
const xmlNodePtr  config_ptr = NULL 
) [protected]

adds a new plug-in object to the configuration file

Parameters:
plugin_name the name of the plug-in element node
plugin_id unique identifier associated with the plug-in
plugin_type the type of plug-in to load (searches plug-in directories and appends extensions)
config_ptr pointer to a list of XML nodes containing plug-in configuration parameters

Definition at line 709 of file ConfigManager.cpp.

References ID_ATTRIBUTE_NAME, m_config_node_ptr, PLUGIN_ELEMENT_NAME, saveConfigFile(), and setPluginConfig().

Referenced by pion::platform::PluginConfig< PluginType >::addPlugin().

virtual void pion::platform::ConfigManager::addPluginNoLock ( const std::string &  plugin_id,
const std::string &  plugin_name,
const xmlNodePtr  config_ptr 
) [inline, protected, virtual]

adds a new plug-in object (without locking or config file updates). This function must be defined properly for any derived classes that wish to use openPluginConfig().

Parameters:
plugin_id unique identifier associated with the plug-in
plugin_name the name of the plug-in to load (searches plug-in directories and appends extensions)
config_ptr pointer to a list of XML nodes containing plug-in configuration parameters

Reimplemented in pion::platform::CodecFactory, pion::platform::DatabaseManager, pion::platform::PluginConfig< PluginType >, pion::platform::ProtocolFactory, pion::server::ServiceManager, pion::platform::PluginConfig< pion::platform::Codec >, pion::platform::PluginConfig< pion::platform::Reactor >, pion::platform::PluginConfig< pion::platform::Database >, pion::platform::PluginConfig< pion::server::PlatformService >, and pion::platform::PluginConfig< pion::platform::Protocol >.

Definition at line 672 of file ConfigManager.hpp.

Referenced by openPluginConfig().

std::string pion::platform::ConfigManager::createFilename ( const std::string &  file_path  ) 

creates a unique XML filename based on a UUID that is located in the given path

Parameters:
file_path path where the file will be located
Returns:
std::string absolute path to the new filename

Definition at line 403 of file ConfigManager.cpp.

References createFilename().

xmlNodePtr pion::platform::ConfigManager::createPluginConfig ( const std::string &  plugin_type  )  [static]

returns an XML configuration list for a new Plugin

Parameters:
plugin_type the type of new plugin that is being created
Returns:
xmlNodePtr XML configuration list for the new Plugin

Definition at line 357 of file ConfigManager.cpp.

References PLUGIN_ELEMENT_NAME.

xmlNodePtr pion::platform::ConfigManager::createResourceConfig ( const std::string &  resource_name,
const char *  buf,
std::size_t  len 
) [static]

uses a memory buffer to generate XML configuration data for a resource

Parameters:
resource_name the XML element name for the resource
buf pointer to a memory buffer containing configuration data
len number of bytes available in the memory buffer
Returns:
xmlNodePtr XML configuration list for the resource

Definition at line 364 of file ConfigManager.cpp.

References findConfigNodeByName(), and ROOT_ELEMENT_NAME.

Referenced by pion::platform::VocabularyManager::addVocabulary(), pion::platform::CodecFactory::createCodecConfig(), pion::platform::ReactionEngine::createConnectionConfig(), pion::platform::DatabaseManager::createDatabaseConfig(), pion::platform::ProtocolFactory::createProtocolConfig(), pion::platform::ReactionEngine::createReactorConfig(), pion::platform::VocabularyConfig::createTermConfig(), pion::platform::VocabularyConfig::createVocabularyConfig(), and PionPlatformUnitTest::makeReactorConfigFromString().

virtual bool pion::platform::ConfigManager::creationAllowed ( xmlNodePtr  permission_config_ptr,
xmlNodePtr  config_ptr 
) const [inline, virtual]

determines whether a User has permission to create a new configuration node

Parameters:
permission_config_ptr the Permission node of the appropriate type from the User's configuration
config_ptr pointer to the new configuration; if null, returns true only if the User has permission for any configuration handled by this manager
Returns:
true if the User has permission

Reimplemented in pion::platform::ReactionEngine.

Definition at line 528 of file ConfigManager.hpp.

Referenced by pion::server::UserManager::creationAllowed().

xmlNodePtr pion::platform::ConfigManager::findConfigNodeByAttr ( const std::string &  element_name,
const std::string &  attr_name,
const std::string &  attr_value,
xmlNodePtr  starting_node 
) [static]

searches for an element node within the XML document tree that has a particular attribute value defined

Parameters:
element_name the name of the element node to search for
attr_name the name of the attribute to search for
attr_value the value that should be assigned to the attribute
starting_node pointer to the node to start searching with; both it and any following sibling nodes will be checked
Returns:
xmlNodePtr pointer to an XML document node if found, otherwise NULL

Definition at line 498 of file ConfigManager.cpp.

Referenced by pion::platform::PluginConfig< PluginType >::getPluginConfig(), pion::platform::ReactionEngine::hasWorkspace(), removePluginConfig(), pion::platform::VocabularyConfig::removeTerm(), pion::platform::VocabularyManager::removeVocabulary(), pion::platform::ReactionEngine::removeWorkspace(), setPluginConfig(), pion::server::UserManager::setUserConfig(), pion::platform::ReactionEngine::setWorkspaceConfig(), pion::platform::VocabularyConfig::updateTerm(), pion::server::UserManager::writeConfigXML(), pion::platform::PluginConfig< PluginType >::writeConfigXML(), pion::server::UserManager::writePermissionsXML(), pion::server::ServiceManager::writeServerXML(), pion::platform::ReactionEngine::writeWorkspaceLimitedConfigXML(), and pion::platform::ReactionEngine::writeWorkspaceXML().

xmlNodePtr pion::platform::ConfigManager::findConfigNodeByContent ( const std::string &  element_name,
const std::string &  content_value,
xmlNodePtr  starting_node 
) [static]

searches for an element node within the XML document tree that has a particular content value defined

Parameters:
element_name the name of the element node to search for
content_value the value that should match the element's content
starting_node pointer to the node to start searching with; both it and any following sibling nodes will be checked
Returns:
xmlNodePtr pointer to an XML document node if found, otherwise NULL

Definition at line 469 of file ConfigManager.cpp.

Referenced by pion::platform::ReactionEngine::accessAllowed(), pion::platform::ReactionEngine::creationAllowed(), pion::platform::ReactionEngine::removalAllowed(), and pion::platform::ReactionEngine::updateAllowed().

xmlNodePtr pion::platform::ConfigManager::findConfigNodeByName ( const std::string &  element_name,
xmlNodePtr  starting_node 
) [static]

searches for an element node within the XML document tree

Parameters:
element_name the name of the element node to search for
starting_node pointer to the node to start searching with; both it and any following sibling nodes will be checked
Returns:
xmlNodePtr pointer to an XML document node if found, otherwise NULL

Definition at line 448 of file ConfigManager.cpp.

Referenced by createResourceConfig(), pion::server::UserManager::createUserConfig(), pion::platform::ReactionEngine::creationAllowed(), getConfigOption(), getConfigOptionEmptyOk(), pion::platform::DatabaseManager::getDatabaseEngineConfig(), pion::platform::VocabularyManager::openConfigFile(), pion::platform::VocabularyConfig::openConfigFile(), pion::platform::ReactionEngine::openConfigFile(), openPluginConfig(), pion::platform::VocabularyConfig::parseTermConfig(), pion::platform::Database::readConfigDetails(), pion::platform::ReactionEngine::removeReactorsFromWorkspace(), pion::platform::ReactionEngine::removeWorkspace(), pion::platform::ReactionEngine::restartReactorsThatShouldBeRunning(), pion::platform::RuleChain::setConfig(), pion::platform::DatabaseInserter::setConfig(), setPluginConfig(), pion::platform::ReactionEngine::setReactorLocation(), pion::platform::ReactionEngine::startReactor(), pion::platform::ReactionEngine::stopReactor(), pion::platform::TransformJoinTerm::TransformJoinTerm(), pion::platform::TransformLookup::TransformLookup(), pion::platform::TransformRegex::TransformRegex(), pion::platform::TransformRules::TransformRules(), pion::platform::TransformSplitTerm::TransformSplitTerm(), updateConfigOption(), pion::platform::VocabularyConfig::updateTerm(), pion::platform::ReactionEngine::writeStatsXML(), pion::platform::ReactionEngine::writeWorkspaceLimitedConfigXML(), and pion::platform::ReactionEngine::writeWorkspacesXML().

static std::string pion::platform::ConfigManager::getAttribute ( const std::string &  name,
const xmlNodePtr  ptr 
) [inline, static]

get the value of an attribute in a pointed-to XML node

Parameters:
name Name, as std::string of the parameter
ptr xmlNodePtr of the node, to find the attribute in
Returns:
std::string of the value of the attribute (or empty string)

Definition at line 420 of file ConfigManager.hpp.

std::string pion::platform::ConfigManager::getAttribute ( const char *  name,
const xmlNodePtr  ptr 
) [static]

get the value of an attribute in a pointed-to XML node

Parameters:
name Name, as const char* of the parameter
ptr xmlNodePtr of the node, to find the attribute in
Returns:
std::string of the value of the attribute (or empty string)

Definition at line 565 of file ConfigManager.cpp.

Referenced by pion::platform::Database::readConfigDetails(), pion::platform::DatabaseInserter::setConfig(), pion::platform::TransformJoinTerm::TransformJoinTerm(), and pion::platform::TransformSplitTerm::TransformSplitTerm().

template<typename ValueType>
static bool pion::platform::ConfigManager::getConfigOption ( const std::string &  option_name,
ValueType &  option_value,
const ValueType &  default_value,
const xmlNodePtr  starting_node 
) [inline, static]

retrieves the value for a simple configuration option that is contained within an XML element node; assigns to default_value if option not found.

Parameters:
option_name the name of the option's element node
option_value will be assigned to the value of the option's element node
default_value the value assigned if the element node is not found
starting_node pointer to the node to start searching with; both it and any following sibling nodes will be checked
Returns:
true if the option has a value; false if it is undefined or empty

Definition at line 462 of file ConfigManager.hpp.

template<typename ValueType>
static bool pion::platform::ConfigManager::getConfigOption ( const std::string &  option_name,
ValueType &  option_value,
const xmlNodePtr  starting_node 
) [inline, static]

retrieves the value for a simple configuration option that is contained within an XML element node.

Parameters:
option_name the name of the option's element node
option_value will be assigned to the value of the option's element node
starting_node pointer to the node to start searching with; both it and any following sibling nodes will be checked
Returns:
true if the option has a value; false if it is undefined or empty

Definition at line 437 of file ConfigManager.hpp.

bool pion::platform::ConfigManager::getConfigOption ( const std::string &  option_name,
std::string &  option_value,
const xmlNodePtr  starting_node 
) [static]

retrieves the value for a simple configuration option that is contained within an XML element node.

Parameters:
option_name the name of the option's element node
option_value the value (text content) of the option's element node
starting_node pointer to the node to start searching with; both it and any following sibling nodes will be checked
Returns:
true if the option has a value; false if it is undefined or empty

Definition at line 528 of file ConfigManager.cpp.

References findConfigNodeByName().

Referenced by pion::platform::PluginConfig< PluginType >::addPlugin(), pion::platform::ReactionEngine::addReactorConnection(), pion::platform::VocabularyManager::addVocabulary(), pion::platform::ReactionEngine::creationAllowed(), getConfigOptionEmptyOk(), pion::platform::DatabaseManager::getDatabaseEngineConfig(), pion::platform::VocabularyManager::openConfigFile(), pion::platform::VocabularyConfig::openConfigFile(), pion::platform::ReactionEngine::openConfigFile(), pion::server::ServiceManager::openConfigFile(), openPluginConfig(), pion::platform::VocabularyConfig::parseTermConfig(), pion::platform::Database::readConfig(), pion::platform::Database::readConfigDetails(), pion::platform::ReactionEngine::removeReactorsFromWorkspace(), pion::platform::ReactionEngine::removeWorkspace(), pion::platform::VocabularyConfig::setConfig(), pion::platform::RuleChain::setConfig(), pion::platform::Reactor::setConfig(), pion::platform::Protocol::setConfig(), pion::platform::PlatformPlugin::setConfig(), pion::platform::DatabaseInserter::setConfig(), pion::platform::Codec::setConfig(), pion::platform::ReactionEngine::setReactorLocation(), pion::platform::Reactor::startOutRunning(), pion::platform::TransformAssignTerm::TransformAssignTerm(), pion::platform::TransformJoinTerm::TransformJoinTerm(), pion::platform::TransformLookup::TransformLookup(), pion::platform::TransformRegex::TransformRegex(), pion::platform::TransformRules::TransformRules(), pion::platform::TransformSplitTerm::TransformSplitTerm(), pion::platform::TransformURLDecode::TransformURLDecode(), pion::platform::TransformURLEncode::TransformURLEncode(), pion::platform::ReactionEngine::updateAllowed(), and pion::platform::ReactionEngine::writeWorkspaceLimitedConfigXML().

bool pion::platform::ConfigManager::getConfigOptionEmptyOk ( const std::string &  option_name,
std::string &  option_value,
const xmlNodePtr  starting_node 
) [static]

retrieves the value for a simple configuration option that is contained within an XML element node. Difference from getConfigOption; see return value

Parameters:
option_name the name of the option's element node
option_value the value (text content) of the option's element node
starting_node pointer to the node to start searching with; both it and any following sibling nodes will be checked
Returns:
false if not defined (not found), true otherwise

Definition at line 553 of file ConfigManager.cpp.

References findConfigNodeByName(), and getConfigOption().

Referenced by pion::platform::RuleChain::setConfig(), pion::platform::TransformAssignValue::TransformAssignValue(), pion::platform::TransformLookup::TransformLookup(), and pion::platform::TransformRules::TransformRules().

bool pion::platform::ConfigManager::getNodeId ( xmlNodePtr  config_node,
std::string &  node_id 
) [static]

retrieves the unique identifier for an XML document node

Parameters:
config_node the node to get the identifier for
node_id will be assigned to the unique identifier for the node
Returns:
true if a unique identifier was found and it is not empty

Definition at line 437 of file ConfigManager.cpp.

References ID_ATTRIBUTE_NAME.

Referenced by pion::server::UserManager::createUserConfig(), pion::platform::VocabularyManager::openConfigFile(), pion::platform::VocabularyConfig::openConfigFile(), pion::platform::ReactionEngine::openConfigFile(), pion::server::UserManager::openConfigFile(), pion::server::ServiceManager::openConfigFile(), openPluginConfig(), pion::platform::ReactionEngine::removeReactorsFromWorkspace(), pion::platform::ReactionEngine::restartReactorsThatShouldBeRunning(), pion::platform::ReactionEngine::setReactorLocation(), pion::platform::ReactionEngine::startReactor(), pion::platform::ReactionEngine::stopReactor(), and pion::platform::ReactionEngine::writeStatsXML().

void pion::platform::ConfigManager::openPluginConfig ( const std::string &  plugin_name  )  [protected]

opens a plug-in configuration file and loads all of the plug-ins that it contains by calling addPluginNoLock()

Parameters:
plugin_name the name of the plug-in element node

Definition at line 607 of file ConfigManager.cpp.

References addPluginNoLock(), findConfigNodeByName(), getConfigFile(), getConfigOption(), getNodeId(), m_config_node_ptr, openConfigFile(), and PLUGIN_ELEMENT_NAME.

Referenced by pion::platform::ReactionEngine::openConfigFile(), and pion::platform::PluginConfig< pion::platform::Protocol >::openConfigFile().

virtual bool pion::platform::ConfigManager::removalAllowed ( xmlNodePtr  permission_config_ptr,
const std::string &  id 
) const [inline, virtual]

determines whether a User has permission to remove a configuration node or set of configuration nodes

Parameters:
permission_config_ptr the Permission node of the appropriate type from the User's configuration
id unique identifier associated with an existing configuration node or set of configuration nodes
Returns:
true if the User has permission

Reimplemented in pion::platform::ReactionEngine.

Definition at line 556 of file ConfigManager.hpp.

Referenced by pion::server::UserManager::removalAllowed().

void pion::platform::ConfigManager::removePluginConfig ( const std::string &  plugin_name,
const std::string &  plugin_id 
) [protected]

removes a plug-in object from the configuration file

Parameters:
plugin_name the name of the plug-in element node
plugin_id unique identifier associated with the plug-in

Definition at line 744 of file ConfigManager.cpp.

References findConfigNodeByAttr(), ID_ATTRIBUTE_NAME, m_config_node_ptr, and saveConfigFile().

Referenced by pion::platform::PluginConfig< PluginType >::removePlugin(), and pion::server::UserManager::removeUser().

std::string pion::platform::ConfigManager::resolveRelativeDataPath ( const std::string &  orig_path  ) 

resolves paths relative to the data directory

Parameters:
orig_path the original path (may be relative or absolute)
Returns:
std::string resolved, absolute path to the file

Definition at line 425 of file ConfigManager.cpp.

References getDataDirectory().

Referenced by pion::plugins::LogOutputReactor::setConfig(), pion::plugins::LogInputReactor::setConfig(), and pion::plugins::SQLiteDatabase::setConfig().

std::string pion::platform::ConfigManager::resolveRelativePath ( const std::string &  orig_path  )  const [inline]

resolves paths relative to the location of the config file

Parameters:
orig_path the original path (may be relative or absolute)
Returns:
std::string resolved, absolute path to the file

Definition at line 506 of file ConfigManager.hpp.

std::string pion::platform::ConfigManager::resolveRelativePath ( const std::string &  base_path_to_file,
const std::string &  orig_path 
) [static]

resolves paths relative to the location of another file

Parameters:
base_path_to_file path to a file that will be used if orig_path is relative
orig_path the original path (may be relative or absolute)
Returns:
std::string resolved, absolute path to the file

Definition at line 410 of file ConfigManager.cpp.

Referenced by pion::platform::VocabularyManager::createConfigFile(), pion::platform::DatabaseManager::getDatabaseEngineConfig(), pion::plugins::PythonReactor::getSourceCodeFromFile(), pion::platform::VocabularyManager::openConfigFile(), pion::plugins::LogInputReactor::setConfig(), pion::platform::VocabularyManager::setVocabularyPath(), and pion::platform::DatabaseManager::writeDatabaseEnginesXML().

void pion::platform::ConfigManager::setPluginConfig ( const std::string &  plugin_name,
const std::string &  plugin_id,
const xmlNodePtr  config_ptr 
) [protected]

updates the configuration parameters for a plug-in

Parameters:
plugin_name the name of the plug-in element node
plugin_id unique identifier associated with the plug-in
config_ptr pointer to a list of XML nodes containing plug-in configuration parameters

Definition at line 672 of file ConfigManager.cpp.

References findConfigNodeByAttr(), ID_ATTRIBUTE_NAME, m_config_node_ptr, PLUGIN_ELEMENT_NAME, saveConfigFile(), and setPluginConfig().

bool pion::platform::ConfigManager::setPluginConfig ( xmlNodePtr  plugin_node_ptr,
xmlNodePtr  config_ptr 
) [protected]

add configuration parameters for a plug-in to the configuration file

Parameters:
plugin_node_ptr pointer to the existing plugin element node
config_ptr pointer to the new configuration parameters
Returns:
true if successful, false if there was an error

Definition at line 633 of file ConfigManager.cpp.

References findConfigNodeByName(), and PLUGIN_ELEMENT_NAME.

Referenced by addPluginConfig(), setPluginConfig(), and pion::platform::PluginConfig< PluginType >::setPluginConfig().

virtual bool pion::platform::ConfigManager::updateAllowed ( xmlNodePtr  permission_config_ptr,
const std::string &  id,
xmlNodePtr  config_ptr 
) const [inline, virtual]

determines whether a User has permission to update a configuration node

Parameters:
permission_config_ptr the Permission node of the appropriate type from the User's configuration
id unique identifier associated with an existing configuration node
config_ptr pointer to the new configuration; if null, returns true only if the User has permission for any configuration handled by this manager
Returns:
true if the User has permission

Reimplemented in pion::platform::ReactionEngine.

Definition at line 543 of file ConfigManager.hpp.

Referenced by pion::server::UserManager::updateAllowed().

bool pion::platform::ConfigManager::updateConfigOption ( const std::string &  option_name,
const std::string &  option_value,
xmlNodePtr  parent_node 
) [static]

updates a simple configuration option that is contained within an XML element node. If the option value is empty, the node is removed. Adds a new element node if necessary.

Parameters:
option_name the name of the option's element node
option_value the value that should be assigned to the option
parent_node pointer to the option's parent node
Returns:
true if the option was updated; false if there was an error

Definition at line 577 of file ConfigManager.cpp.

References findConfigNodeByName(), and xml_encode().

Referenced by pion::platform::VocabularyManager::createConfigFile(), pion::platform::VocabularyConfig::setComment(), pion::platform::VocabularyConfig::setLocked(), pion::platform::VocabularyConfig::setName(), pion::platform::ReactionEngine::setReactorLocation(), pion::platform::VocabularyManager::setVocabularyPath(), pion::platform::ReactionEngine::startReactor(), and pion::platform::ReactionEngine::stopReactor().

void pion::platform::ConfigManager::writeBeginPionConfigXML ( std::ostream &  out  )  [static]

write out the beginning <PionConfig> block for XML config information

Parameters:
out the ostream to write the configuration info into

Definition at line 242 of file ConfigManager.cpp.

References CONFIG_NAMESPACE_URL, PION_VERSION_ATTRIBUTE_NAME, ROOT_ELEMENT_NAME, and writeConfigXMLHeader().

Referenced by pion::platform::PluginConfig< PluginType >::writeConfigXML(), pion::platform::ReactionEngine::writeConnectionsXML(), pion::platform::VocabularyManager::writeTermConfigXML(), pion::platform::ReactionEngine::writeWorkspaceLimitedConfigXML(), pion::platform::ReactionEngine::writeWorkspacesXML(), and pion::platform::ReactionEngine::writeWorkspaceXML().

void pion::platform::ConfigManager::writeBeginPionStatsXML ( std::ostream &  out  )  [static]

write out the beginning <PionStats> block for XML statistic information

Parameters:
out the ostream to write the statistic info into

Definition at line 254 of file ConfigManager.cpp.

References CONFIG_NAMESPACE_URL, STATS_ELEMENT_NAME, and writeConfigXMLHeader().

Referenced by pion::platform::ReactionEngine::writeStatsXML().

void pion::platform::ConfigManager::writeConfigXML ( std::ostream &  out,
xmlNodePtr  config_node,
bool  include_siblings = false 
) [static]

writes configuration data to an output stream (as XML)

Parameters:
out the ostream to write the configuration tree into
config_node xmlNodePtr to start writing data from
include_siblings if true, siblings of config_node will be written

Definition at line 180 of file ConfigManager.cpp.

References writeConfigXML(), and xml_encode().

virtual void pion::platform::ConfigManager::writeConfigXML ( std::ostream &  out  )  const [inline, virtual]

writes the entire configuration tree to an output stream (as XML)

Parameters:
out the ostream to write the configuration tree into

Reimplemented in pion::platform::PluginConfig< PluginType >, pion::platform::VocabularyManager, pion::server::PlatformConfig, pion::server::UserManager, pion::platform::PluginConfig< pion::platform::Codec >, pion::platform::PluginConfig< pion::platform::Reactor >, pion::platform::PluginConfig< pion::platform::Database >, pion::platform::PluginConfig< pion::server::PlatformService >, and pion::platform::PluginConfig< pion::platform::Protocol >.

Definition at line 229 of file ConfigManager.hpp.

Referenced by writeConfigXML(), pion::platform::VocabularyManager::writeConfigXML(), pion::platform::PluginConfig< PluginType >::writeConfigXML(), pion::platform::PluginConfig< pion::platform::Protocol >::writeConfigXML(), pion::platform::DatabaseManager::writeDatabaseEnginesXML(), pion::platform::ReactionEngine::writeWorkspaceLimitedConfigXML(), pion::platform::ReactionEngine::writeWorkspacesXML(), and pion::platform::ReactionEngine::writeWorkspaceXML().

void pion::platform::ConfigManager::writeConfigXMLHeader ( std::ostream &  out  )  [static]

write the XML header <?xml ... ?> to an ouput stream

Parameters:
out the ostream to write the configuration info into

Definition at line 237 of file ConfigManager.cpp.

Referenced by writeBeginPionConfigXML(), writeBeginPionStatsXML(), pion::platform::VocabularyManager::writeConfigXML(), and pion::platform::PluginConfig< pion::platform::Protocol >::writeConfigXML().

void pion::platform::ConfigManager::writeEndPionConfigXML ( std::ostream &  out  )  [static]

write out the end </PionConfig> block for XML config information

Parameters:
out the ostream to write the configuration info into

Definition at line 249 of file ConfigManager.cpp.

Referenced by pion::platform::PluginConfig< PluginType >::writeConfigXML(), pion::platform::ReactionEngine::writeConnectionsXML(), pion::platform::VocabularyManager::writeTermConfigXML(), pion::platform::ReactionEngine::writeWorkspaceLimitedConfigXML(), pion::platform::ReactionEngine::writeWorkspacesXML(), and pion::platform::ReactionEngine::writeWorkspaceXML().

void pion::platform::ConfigManager::writeEndPionStatsXML ( std::ostream &  out  )  [static]

write out the end </PionStats> block for XML statistic information

Parameters:
out the ostream to write the statistic info into

Definition at line 261 of file ConfigManager.cpp.

Referenced by pion::platform::ReactionEngine::writeStatsXML().


The documentation for this class was generated from the following files:
Generated on Wed Apr 13 16:38:35 2011 for pion-platform by  doxygen 1.4.7