HydraExpress™ C++ API Reference Guide

Product Documentation:
   HydraExpress C++
Documentation Home
List of all members | Public Types | Public Member Functions | Static Public Member Functions
rwsf::AgentContext Class Reference

Holds state information about the entire Agent process. More...

#include <rwsf/handlers/AgentContext.h>

Inheritance diagram for rwsf::AgentContext:
rwsf::MessageInfo rwsf::HandleBase

Public Types

enum  AgentState { AgentStateUnknown, AgentStateInitializing, AgentStateNormal, AgentStateBackup }
 

Public Member Functions

 AgentContext (const AgentContext &context)
 
rwsf::AgentContext::AgentState getAgentState () const
 
std::string getConfigurationFile () const
 
rwsf::Connector getConnector (const std::string &name) const
 
rwsf::Enumeration< rwsf::ConnectorgetConnectors () const
 
rwsf::MessageInfoHandlerChain getHandlerChain (const std::string &name) const
 
rwsf::Logger getLogger () const
 
void init (const rwsf::Config &config)
 
AgentContextoperator= (const AgentContext &context)
 
void setConnector (const std::string &name, const rwsf::Connector &connector)
 
void setHandlerChain (const std::string &name, const rwsf::MessageInfoHandlerChain &chain)
 
void setLogger (const rwsf::Logger &logger)
 
- Public Member Functions inherited from rwsf::MessageInfo
 MessageInfo ()
 
 MessageInfo (const rwsf::MessageInfo &second)
 
virtual void clear ()
 
void clear (const std::string &name)
 
bool contains (const std::string &name) const
 
template<typename T >
const T & get (const std::string &name) const
 
rwsf::Attribute getAttribute (const std::string &name) const
 
MessageInfooperator= (const rwsf::MessageInfo &second)
 
template<typename T >
void set (const std::string &name, const T &value)
 
void setAttribute (const std::string &name, const rwsf::Attribute &attr)
 
template<typename T >
T & value (const std::string &name)
 
- Public Member Functions inherited from rwsf::HandleBase
bool isValid (void) const
 
bool operator!= (const HandleBase &second) const
 
bool operator== (const HandleBase &second) const
 

Static Public Member Functions

static std::string agentStateToStr (const rwsf::AgentContext::AgentState &state)
 
static rwsf::AgentContext::AgentState strToAgentState (const std::string &type)
 

Additional Inherited Members

- Protected Member Functions inherited from rwsf::MessageInfo
const MessageInfoImp & body () const
 
MessageInfoImp & body ()
 
- Protected Member Functions inherited from rwsf::HandleBase
 HandleBase (void)
 
 HandleBase (StaticCtor)
 
 HandleBase (BodyBase *body)
 
 HandleBase (const HandleBase &second)
 
virtual ~HandleBase (void)
 
BodyBase & body (void) const
 
HandleBaseoperator= (const HandleBase &second)
 

Detailed Description

The AgentContext holds state information about the entire Agent process. It initializes based on the main configuration file (usually <installdir>/conf/rwagent.xml) and sets up important Agent modules, such as the connectors, handler chains, and loggers.

Note
There should only be one instance of an AgentContext in the Agent. This class uses reference semantics wherein copies and assignments always point to the same object instance.

Querying and/or modifying the context can inspect or change the state of the running Agent, so care should be taken when using this class directly.

Note
Do not instantiate this class directly. The AgentContext process instance is available only through certain features, such as within a Connector instance. See the Connector chapter in the RWSF User Guide for an example.

Member Enumeration Documentation

Enumeration containing all possible Agent states. For more information on Agent state, please see

Enumerator
AgentStateUnknown 

The state is unknown, and therefore likely to be down.

AgentStateInitializing 

The Agent is initializing startup.

AgentStateNormal 

The Agent is operating normally.

AgentStateBackup 

Not used.

Constructor & Destructor Documentation

rwsf::AgentContext::AgentContext ( const AgentContext context)

Copy constructor.

Member Function Documentation

static std::string rwsf::AgentContext::agentStateToStr ( const rwsf::AgentContext::AgentState state)
static

Helper method to convert the given state to a string, as follows:

Agent State Types
rwsf:AgentContext::AgentStateNormal Normal
rwsf:AgentContext::AgentStateBackup Backup
rwsf:AgentContext::AgentStateInitializing Initializing
Any other value Unknown
rwsf::AgentContext::AgentState rwsf::AgentContext::getAgentState ( ) const

Gets the Agent's state.

std::string rwsf::AgentContext::getConfigurationFile ( ) const

Returns the path to the configuration file used to start the Agent (i.e. the file passed with the "-c" argument on the command line when the Agent was started).

rwsf::Connector rwsf::AgentContext::getConnector ( const std::string &  name) const

Retrieves the connector name, usually derived from the name of a configured connector in rwagent.xml. If name does not exist, an invalid handle is returned.

rwsf::Enumeration<rwsf::Connector> rwsf::AgentContext::getConnectors ( ) const

Returns an enumeration of all of the connectors registered in the Agent.

rwsf::MessageInfoHandlerChain rwsf::AgentContext::getHandlerChain ( const std::string &  name) const

Retrieves the handler chain associated with the provided handler chain name, usually derived from the handler chain of that name in the Agent configuration file rwagent.xml. If one does not exist, an empty chain is returned.

rwsf::Logger rwsf::AgentContext::getLogger ( ) const

Gets the current default logger for this AgentContext.

void rwsf::AgentContext::init ( const rwsf::Config config)

Initializes the AgentContext with any special properties provided by config.

AgentContext& rwsf::AgentContext::operator= ( const AgentContext context)

Assignment operator.

void rwsf::AgentContext::setConnector ( const std::string &  name,
const rwsf::Connector connector 
)

Sets a new connector with specified name. If name already exists, it is replaced.

Note
Applications are responsible for stopping any existing connectors before replacing them.
void rwsf::AgentContext::setHandlerChain ( const std::string &  name,
const rwsf::MessageInfoHandlerChain chain 
)

Sets a new handler chain with the specified name. Any modules (connectors, etc) that use name for their handler chain will run the new chain specified in chain for any message processing. If the handler chain name already exists, it is replaced.

void rwsf::AgentContext::setLogger ( const rwsf::Logger logger)

Sets the default logger for this AgentContext to logger.

static rwsf::AgentContext::AgentState rwsf::AgentContext::strToAgentState ( const std::string &  type)
static

Helper method to convert the given type to an rwsf::AgentContext::AgentState. Case-insensitive. The possible types and the conversion to state are:

Types Agent State
Normal rwsf:AgentContext::AgentStateNormal
Backup rwsf:AgentContext::AgentStateBackup
Initializing rwsf:AgentContext::AgentStateInitializing
.* rwsf:AgentContext::AgentStateUnknown

Copyright © 2020 Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is registered trademark of Rogue Wave Software, Inc. in the United States and other countries, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.