RSB
0.7.0
|
Scope is a descriptor for a hierarchical channel of the unified bus. More...
#include <Scope.h>
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< Scope > | superScopes (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 |
Scope is a descriptor for a hierarchical channel of the unified bus.
It can be described through a syntax like "/a/parent/scope/".
rsb::Scope::Scope | ( | const std::string & | scope | ) |
Constructs scope from a string syntax.
scope | string representation of the desired scope |
std::invalid_argument | invalid syntax |
Definition at line 115 of file Scope.cpp.
References components, scopestring, and rsb::verifyAndSplit().
rsb::Scope::Scope | ( | const char * | scope | ) |
Constructs scope from a string syntax.
scope | string representation of the desired scope |
std::invalid_argument | invalid syntax |
Definition at line 123 of file Scope.cpp.
References components, scopestring, and rsb::verifyAndSplit().
rsb::Scope::Scope | ( | ) |
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".
childScope | child to concatenate to the current scope for forming a 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().
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.
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/".
other | other scope to test |
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.
other | other scope to test |
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().
bool rsb::Scope::operator== | ( | const Scope & | other | ) | const |
Definition at line 236 of file Scope.cpp.
References toString().
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.
includeSelf | if set to true , this scope is also included as last element of the returned list |
Definition at line 207 of file Scope.cpp.
References components, and updateStringCache().
Referenced by rsb::spread::SpreadConnector::makeGroupNames(), and rsb::inprocess::Bus::removeSink().
const std::string & rsb::Scope::toString | ( | ) | const |
Reconstructs a fully formal string representation of the scope with leading an trailing slashes.
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().
|
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().
|
static |
Definition at line 139 of file Scope.h.
Referenced by updateStringCache().
|
private |
Definition at line 150 of file Scope.h.
Referenced by concat(), getComponents(), isSubScopeOf(), isSuperScopeOf(), Scope(), superScopes(), and updateStringCache().
|
private |
Definition at line 149 of file Scope.h.
Referenced by Scope(), toString(), and updateStringCache().