AceSmartSoft API Documentation
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SmartACE::NSAdapterACE Class Reference

This class defines the client-side interface of the Naming-Service. More...

#include <smartNSAdapterACE.hh>

Public Member Functions

 NSAdapterACE ()
 default constructor More...
 
 NSAdapterACE (const int &argc, char **argv)
 constructor that initializes internal naming-service More...
 
virtual ~NSAdapterACE ()
 default destructor More...
 
int init (const int &argc, char **argv)
 initialize internal naming-service and check whether it started correctly More...
 
int init (const std::map< std::string, std::string > &parameters)
 an alternative initialization method using parameters passed in a map of name-value pairs More...
 
void fini (void)
 
void checkForHelpArg (const int &argc, char *const *argv, std::ostream &ostr=std::cout)
 check for help argument (e.g. -h or –help) and print out the help text More...
 
int bind (const NSKeyType &name, const NSValueType &value)
 function to bind a name-value pair in naming-context. More...
 
int rebind (const NSKeyType &name, const NSValueType &value)
 function to rebind a name-value pair in naming-context. More...
 
int resolve (const NSKeyType &name, NSValueType &value)
 function to resolve (to find) a value, giving its name (key), in naming-context. More...
 
int unbind (const NSKeyType &name)
 function to unbind (to delete) a name-value pair from naming-context. More...
 
int unbindEntriesForMatchingPattern (const NSKeyType &searchPattern)
 recursive unbind function. More...
 
ACE_Unbounded_Queue< NSKeyTypegetEntriesForMatchingPattern (const NSKeyType &searchPattern) const
 get a list of naming-service entries from naming-context for a given search-pattern More...
 

Protected Member Functions

int setConfiguration (const std::map< std::string, std::string > &parameters)
 
std::map< std::string, std::string > parseCommandLineParams (const int &argc, char **argv, const int &skip_args=1) const
 

Protected Attributes

ACE_INET_Addr ns_address
 
ACE_INET_Addr component_ip
 
bool use_component_ip
 
ACE_Connector< NSProxy, ACE_SOCK_CONNECTOR > connector
 
NSProxynamingService
 
ACE_Recursive_Thread_Mutex mutex
 
bool contextInitialized
 

Detailed Description

This class defines the client-side interface of the Naming-Service.

With that binding/unbinding/rebinding of name-value pairs in Naming-Service is possible. In addition some helper functions are available.

Constructor & Destructor Documentation

◆ NSAdapterACE() [1/2]

SmartACE::NSAdapterACE::NSAdapterACE ( )

default constructor

Default constructor does NOT initialize internal naming-service connection. To fully initialize it, use either the constructor with the naming-service string or call the init() method directly.

See also
init()

◆ NSAdapterACE() [2/2]

SmartACE::NSAdapterACE::NSAdapterACE ( const int &  argc,
char **  argv 
)

constructor that initializes internal naming-service

This constructor fully initializes the naming-service by internally calling the init() method.

Parameters
argcthe number of console-parameter arguments
argvthe list of console parameters

◆ ~NSAdapterACE()

virtual SmartACE::NSAdapterACE::~NSAdapterACE ( )
virtual

default destructor

This Destructor is responsible to close the naming-context (being the remote name-space-connection).

Member Function Documentation

◆ bind()

int SmartACE::NSAdapterACE::bind ( const NSKeyType name,
const NSValueType value 
)

function to bind a name-value pair in naming-context.

If the name exists in naming-context, it will be not overridden and an error value is returned.

Parameters
nameName (key) for the value to be stored in the naming-context (must be a fully qualified name without asterisks, except for commobj2)
valueThe value object to be bound with the name
Returns
0 on success
-1 on failure or existing name
See also
rebind()
unbind()
resolve()

◆ checkForHelpArg()

void SmartACE::NSAdapterACE::checkForHelpArg ( const int &  argc,
char *const *  argv,
std::ostream &  ostr = std::cout 
)

check for help argument (e.g. -h or –help) and print out the help text

If one of the arguments in the ARGV vector contains the help argument (e.g. -h or –help) then a text explaining all the valid naming service arguments is printed out using ostr.

◆ fini()

void SmartACE::NSAdapterACE::fini ( void  )

close down naming-context

◆ getEntriesForMatchingPattern()

ACE_Unbounded_Queue<NSKeyType> SmartACE::NSAdapterACE::getEntriesForMatchingPattern ( const NSKeyType searchPattern) const

get a list of naming-service entries from naming-context for a given search-pattern

This method queries the naming-service for a list of entries, that match the given search-pattern. For each part of the search-pattern either a specific name can be set (e.g. a certain component name) or an asterisk ("*") indicates this part to be an arbitrary string (like in regular expressions). Thereby, the search-pattern is evaluated as follows: for each entry in the naming service it is checked, whether it matches <comp-name> && <pattern-name> && <service-name> && <commobj1-name> && <commobj2-name>. For example, to query for a list of all services of a component, the search pattern looks as follows: ("MyComponent" "*" "*" "*" "*").

Parameters
searchPatternThe search-pattern to be matched against each entry in the naming-service
Returns
A list of all entries in the naming-service that match the search-pattern. This list is empty if no matches are found or an error occurs.

◆ init() [1/2]

int SmartACE::NSAdapterACE::init ( const int &  argc,
char **  argv 
)

initialize internal naming-service and check whether it started correctly

This method fully initializes the naming-service and checks if it starts successfully. After that all methods (like bind, unbind, resolve etc.) can be used.

Parameters
argcdefined the number of console parameters
argvcontains the list of console parameters
Returns
0 on success
-1 on failure during initialization

◆ init() [2/2]

int SmartACE::NSAdapterACE::init ( const std::map< std::string, std::string > &  parameters)

an alternative initialization method using parameters passed in a map of name-value pairs

This method fully initializes the naming-service and checks if it starts successfully. After that all methods (like bind, unbind, resolve etc.) can be used. Thereby the parameters are passed in the std::map parameters which contains entries with the first part being the parameter name and the second part being the corresponding parameter value.

Parameters
parameterscontains the parameter name-value pairs
Returns
0 if initialization was successfully
-1 if initialization fails

◆ parseCommandLineParams()

std::map<std::string,std::string> SmartACE::NSAdapterACE::parseCommandLineParams ( const int &  argc,
char **  argv,
const int &  skip_args = 1 
) const
protected

◆ rebind()

int SmartACE::NSAdapterACE::rebind ( const NSKeyType name,
const NSValueType value 
)

function to rebind a name-value pair in naming-context.

If the name exists in naming-context, the value will be overridden silently.

Parameters
nameName (key) for the value to be stored in the naming-context (must be a fully qualified name without asterisks, except for commobj2)
valueThe value object to be bound with the name
Returns
0 on success
-1 on failure
See also
bind()
resolve()
unbind()

◆ resolve()

int SmartACE::NSAdapterACE::resolve ( const NSKeyType name,
NSValueType value 
)

function to resolve (to find) a value, giving its name (key), in naming-context.

Search a name in naming-context, resolve its value and return it in the value parameter.

Parameters
nameName to resolve (must be a fully qualified name without asterisks, except for commobj2)
valueResulting value to the corresponding name
Returns
0 on success (found name)
-1 on not found or failure
See also
bind()
rebind()
unbind()

◆ setConfiguration()

int SmartACE::NSAdapterACE::setConfiguration ( const std::map< std::string, std::string > &  parameters)
protected

◆ unbind()

int SmartACE::NSAdapterACE::unbind ( const NSKeyType name)

function to unbind (to delete) a name-value pair from naming-context.

This function searches the name (key) in the naming-context and unbinds (deletes) corresponding name-value pair (entry).

Parameters
nameName (key) to unbind (delete) the corresponding name-value pair (must be a fully qualified name without asterisks, except for commobj2)
Returns
0 on success
-1 on not found or failure
See also
bind()
rebind()
resolve()

◆ unbindEntriesForMatchingPattern()

int SmartACE::NSAdapterACE::unbindEntriesForMatchingPattern ( const NSKeyType searchPattern)

recursive unbind function.

This function is similar to unbind(). Here however, all name-value pairs, matching the searchPattern will be unbound sequentially. This function is typically used in SmartComponent in case of strg+c abortion to clean up all potential dead-entries from the naming-service!

Parameters
searchPatternIs used as pattern to find all name-value pairs (use asterisks to generalize variable parts of the search pattern).
Returns
0 on success
-1 on failure
See also
getEntriesForMatchingPattern()

Member Data Documentation

◆ component_ip

ACE_INET_Addr SmartACE::NSAdapterACE::component_ip
protected

◆ connector

ACE_Connector<NSProxy, ACE_SOCK_CONNECTOR> SmartACE::NSAdapterACE::connector
protected

◆ contextInitialized

bool SmartACE::NSAdapterACE::contextInitialized
protected

◆ mutex

ACE_Recursive_Thread_Mutex SmartACE::NSAdapterACE::mutex
mutableprotected

◆ namingService

NSProxy* SmartACE::NSAdapterACE::namingService
protected

◆ ns_address

ACE_INET_Addr SmartACE::NSAdapterACE::ns_address
protected

◆ use_component_ip

bool SmartACE::NSAdapterACE::use_component_ip
protected

The documentation for this class was generated from the following file: