RSB  0.7.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rsb::Scope Class Reference

Scope is a descriptor for a hierarchical channel of the unified bus. More...

#include <Scope.h>

Collaboration diagram for rsb::Scope:
Collaboration graph

Public Member Functions

 Scope (const std::string &scope)
 Constructs scope from a string syntax.
 Scope (const char *scope)
 Constructs scope from a string syntax.
 Scope ()
 Creates a scope representing "/".
virtual ~Scope ()
 Destructor.
const std::vector< std::string > & getComponents () const
 Returns all components of the scope as an ordered list.
const std::string & toString () const
 Reconstructs a fully formal string representation of the scope with leading an trailing slashes.
Scope concat (const Scope &childScope) const
 Creates a new scope that is a sub-scope of this one with the subordinated scope described by the given argument.
bool isSubScopeOf (const Scope &other) const
 Tests whether this scope is a sub-scope of the given other scope, which means that the other scope is a prefix of this scope.
bool isSuperScopeOf (const Scope &other) const
 Inverse operation of isSubScopeOf.
std::vector< ScopesuperScopes (const bool &includeSelf=false) const
 Generates all super scopes of this scope including the root scope "/".
bool operator== (const Scope &other) const
bool operator< (const Scope &other) const

Static Public Attributes

static const char COMPONENT_SEPARATOR = '/'

Private Member Functions

void updateStringCache ()
 Updates the contents of scopestring based on components.

Private Attributes

std::string scopestring
std::vector< std::string > components

Detailed Description

Scope is a descriptor for a hierarchical channel of the unified bus.

It can be described through a syntax like "/a/parent/scope/".

Author
jwienke

Definition at line 46 of file Scope.h.

Constructor & Destructor Documentation

rsb::Scope::Scope ( const std::string &  scope)

Constructs scope from a string syntax.

Parameters
scopestring representation of the desired scope
Exceptions
std::invalid_argumentinvalid syntax

Definition at line 115 of file Scope.cpp.

References components, scopestring, and rsb::verifyAndSplit().

Here is the call graph for this function:

rsb::Scope::Scope ( const char *  scope)

Constructs scope from a string syntax.

Parameters
scopestring representation of the desired scope
Exceptions
std::invalid_argumentinvalid syntax

Definition at line 123 of file Scope.cpp.

References components, scopestring, and rsb::verifyAndSplit().

Here is the call graph for this function:

rsb::Scope::Scope ( )

Creates a scope representing "/".

Use this wisely!

Definition at line 131 of file Scope.cpp.

rsb::Scope::~Scope ( )
virtual

Destructor.

Definition at line 135 of file Scope.cpp.

Member Function Documentation

Scope rsb::Scope::concat ( const Scope childScope) const

Creates a new scope that is a sub-scope of this one with the subordinated scope described by the given argument.

E.g. "/this/is/".concat("/a/test/") results in "/this/is/a/test".

Parameters
childScopechild to concatenate to the current scope for forming a sub-scope
Returns
new scope instance representing the created sub-scope

Definition at line 146 of file Scope.cpp.

References components, and updateStringCache().

Referenced by rsb::patterns::RemoteServer::getMethodSet(), and rsb::patterns::Server::registerMethod().

Here is the call graph for this function:

Here is the caller graph for this function:

const vector< string > & rsb::Scope::getComponents ( ) const

Returns all components of the scope as an ordered list.

Components are the names between the separator character '/'. The first entry in the list is the highest level of hierarchy. The scope '/' returns an empty list.

Returns
components of the represented scope as ordered list with highest level as first entry

Definition at line 138 of file Scope.cpp.

References components.

bool rsb::Scope::isSubScopeOf ( const Scope other) const

Tests whether this scope is a sub-scope of the given other scope, which means that the other scope is a prefix of this scope.

E.g. "/a/b/" is a sub-scope of "/a/".

Parameters
otherother scope to test
Returns
true if this is a sub-scope of the other scope, equality gives false, too

Definition at line 159 of file Scope.cpp.

References components.

bool rsb::Scope::isSuperScopeOf ( const Scope other) const

Inverse operation of isSubScopeOf.

Parameters
otherother scope to test
Returns
true if this scope is a strict super scope of the other scope. equality also gives false.

Definition at line 174 of file Scope.cpp.

References components.

bool rsb::Scope::operator< ( const Scope other) const

Definition at line 240 of file Scope.cpp.

References toString().

Here is the call graph for this function:

bool rsb::Scope::operator== ( const Scope other) const

Definition at line 236 of file Scope.cpp.

References toString().

Here is the call graph for this function:

vector< Scope > rsb::Scope::superScopes ( const bool &  includeSelf = false) const

Generates all super scopes of this scope including the root scope "/".

The returned list of scopes is ordered by hierarchy with "/" being the first entry.

Parameters
includeSelfif set to true, this scope is also included as last element of the returned list
Returns
list of all super scopes ordered by hierarchy, "/" being first

Definition at line 207 of file Scope.cpp.

References components, and updateStringCache().

Referenced by rsb::spread::SpreadConnector::makeGroupNames(), and rsb::inprocess::Bus::removeSink().

Here is the call graph for this function:

Here is the caller graph for this function:

const std::string & rsb::Scope::toString ( ) const

Reconstructs a fully formal string representation of the scope with leading an trailing slashes.

Returns
string representation of the scope

Definition at line 142 of file Scope.cpp.

References scopestring.

Referenced by rsb::spread::SpreadConnector::makeGroupName(), operator<(), rsb::operator<<(), operator==(), and rsb::patterns::Server::registerMethod().

Here is the caller graph for this function:

void rsb::Scope::updateStringCache ( )
private

Updates the contents of scopestring based on components.

Calling this method is necessary if components is modified directly without using one of the constructors.

Definition at line 189 of file Scope.cpp.

References COMPONENT_SEPARATOR, components, and scopestring.

Referenced by concat(), and superScopes().

Here is the caller graph for this function:

Member Data Documentation

const char rsb::Scope::COMPONENT_SEPARATOR = '/'
static

Definition at line 139 of file Scope.h.

Referenced by updateStringCache().

std::vector<std::string> rsb::Scope::components
private
std::string rsb::Scope::scopestring
private

Definition at line 149 of file Scope.h.

Referenced by Scope(), toString(), and updateStringCache().


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