#include <OMKName.h>
Inheritance diagram for OMK::Name:
redefine standard operators | |
bool | operator== (const Name &first, const Name &second) |
compare | |
bool | operator!= (const Name &first, const Name &second) |
compare. | |
bool OMK_API | operator< (const Name &Source1, const Name &Source2) |
smaller than | |
bool OMK_API | operator> (const Name &Source1, const Name &Source2) |
greater than | |
bool OMK_API | operator<= (const Name &Source1, const Name &Source2) |
smaller than or equal to | |
bool OMK_API | operator>= (const Name &Source1, const Name &Source2) |
greater than or equal to | |
virtual Name & | operator= (const Name &) |
affectation | |
virtual Name & | operator= (const char *) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
virtual Name & | operator= (const std::string &) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
Public Types | |
typedef long | idType |
real type of name identifiers | |
Public Member Functions | |
Name () | |
Default contructor. | |
Name (const std::string &) | |
Construction from a std::string. | |
Name (const char *) | |
Construction from a char * (getCString). | |
Name (const Name &) | |
copy constructor | |
virtual | ~Name () |
Destructor. | |
bool | undefined () const |
Return true if the name is undefined. | |
virtual Type::PolatorNT * | createPolator (void) |
Creation a Polator for names, a Name derives from OMKType. | |
virtual const char * | getCString () const |
get C style string corresponding to name | |
virtual const std::string & | getString () const |
get std::string corresponding to name | |
virtual void | insertInStream (std::ostream &out) const |
Insert in a stream. | |
virtual void | extract (std::istream &in) |
Extract from a stream. | |
virtual void | unpack (IncomingSynchronisationMessage &) |
unpack from a message | |
virtual void | pack (OutgoingSynchronisationMessage &) const |
pack in a message | |
Static Public Member Functions | |
static NameServer * | getNameServer () |
get the name server. | |
static void | setNameServer (NameServer *) |
change the name server will only have any effect if the new name server is equivalent to the old one | |
Static Public Attributes | |
static const idType | _maxReservedId |
max id of reserved ids (reserved ids are called system ids) | |
Protected Member Functions | |
virtual void | changeId (idType oldId, idType newId) |
a protected member function to enable change of the id by the name server | |
Name (idType) | |
constructor using the associated id. | |
Protected Attributes | |
idType | _identifier |
the identifier used to store the name | |
Static Protected Attributes | |
static NameServer * | _nameServer |
the current name server | |
Friends | |
class | OMK::NameServer |
Related Functions | |
(Note that these are not member functions.) | |
functions and object-function to manipulate names | |
bool | operator== (const Name &a, const char *b) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
bool | operator== (const char *a, const Name &b) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
bool | operator!= (const Name &a, const char *b) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
bool | operator!= (const char *a, const Name &b) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
Classes | |
struct | hash_compare_Name |
a function object for a hash function More... |
For efficiency reasons, names appear to the user as human readable strings but are in fact identifiers. Correpondance between an identifier and a human readable string is kept by the name server. The following Names are reserved id:
bool myOSO::processEvent( Event *event ) { static Name eventName( "theEvent" ) ; if( event->eventId == eventName ) { // Compare identifiers => fast } }
bool myOSO::processEvent( Event *event ) { if( event->eventId == "theEvent" ) { // Compare strings => slow } }
Definition at line 73 of file OMKName.h.
typedef long OMK::Name::idType |
Name::Name | ( | ) |
Default contructor.
Definition at line 65 of file OMKName.cpp.
References _identifier, OMK::NameServer::created(), getNameServer(), OMK_DEBUG_OMK_NAME, and OMTRACEID.
00066 { 00067 OMTRACEID( OMK_DEBUG_OMK_NAME, "Name::Name()" ) ; 00068 _identifier=0; 00069 getNameServer()->created( _identifier, this ); 00070 OMTRACEID( OMK_DEBUG_OMK_NAME, "Name::Name() end" ) ; 00071 }
Name::Name | ( | const std::string & | ) |
Construction from a std::string.
Definition at line 84 of file OMKName.cpp.
References _identifier, OMK::NameServer::created(), OMK::NameServer::getIdentifier(), getNameServer(), OMK_DEBUG_OMK_NAME, and OMTRACEID.
00085 { 00086 OMTRACEID( OMK_DEBUG_OMK_NAME, "Name::Name(const std::string & \"" << name << "\" )" 00087 << endl <<"Name server = " << (void*)getNameServer() ) ; 00088 _identifier = getNameServer()->getIdentifier(name); 00089 getNameServer()->created( _identifier, this ) ; 00090 OMTRACEID( OMK_DEBUG_OMK_NAME, "Name::Name(const std::string &) end" ) ; 00091 }
Name::Name | ( | const char * | ) |
Construction from a char * (getCString).
Definition at line 73 of file OMKName.cpp.
References _identifier, OMK::NameServer::created(), OMK::NameServer::getIdentifier(), getNameServer(), OMK_DEBUG_OMK_NAME, and OMTRACEID.
00074 { 00075 OMTRACEID( OMK_DEBUG_OMK_NAME, "Name::Name(const char * (" << (void*)name << ")\"" << name << "\" )" 00076 << endl <<"Name server = " << (void*)getNameServer() ) ; 00077 _identifier = getNameServer()->getIdentifier(std::string(name)); 00078 getNameServer()->created( _identifier, this ) ; 00079 OMTRACEID( OMK_DEBUG_OMK_NAME, "Name::Name(const char *) end" ); 00080 }
Name::Name | ( | const Name & | ) |
copy constructor
Definition at line 94 of file OMKName.cpp.
References _identifier, OMK::NameServer::created(), getNameServer(), OMK_DEBUG_OMK_NAME, and OMTRACEID.
00095 { 00096 OMTRACEID( OMK_DEBUG_OMK_NAME, "Name::Name(const Name & \"" << aCopier << "\") " << aCopier._identifier ) ; 00097 _identifier = aCopier._identifier; 00098 getNameServer()->created(_identifier,this); 00099 OMTRACEID( OMK_DEBUG_OMK_NAME, "Name::Name(const Name &) end" ) ; 00100 }
Name::~Name | ( | ) | [virtual] |
Destructor.
Definition at line 102 of file OMKName.cpp.
References _identifier, OMK::NameServer::deleted(), and getNameServer().
00103 { 00104 getNameServer()->deleted( _identifier, this ); 00105 }
Name::Name | ( | idType | ) | [explicit, protected] |
constructor using the associated id.
It's usage is reserved for the creation of system identifiers
Definition at line 56 of file OMKName.cpp.
References _identifier, _maxReservedId, OMK::NameServer::created(), getNameServer(), OMASSERT, OMK_DEBUG_OMK_NAME, and OMTRACEID.
00057 { 00058 OMTRACEID( OMK_DEBUG_OMK_NAME, "Name::Name(idType " << i << " )" ) ; 00059 OMASSERT( i < _maxReservedId ) ; 00060 _identifier = i ; 00061 getNameServer()->created( _identifier , this ); 00062 OMTRACEID( OMK_DEBUG_OMK_NAME, "Name::Name(idType) end" ) ; 00063 }
bool OMK::Name::undefined | ( | ) | const [inline] |
Return true if the name is undefined.
It is the same to write
name == OMK::Name()
Definition at line 102 of file OMKName.h.
Referenced by OMK::IAttribute::activateConnectBySignal(), OMK::IAttribute::activateGetBySignal(), OMK::IAttribute::activateSetBySignal(), and OMK::IAttribute::activateSetBySignalOf().
00102 { return 0 == _identifier ; }
OMK::Type::PolatorNT * Name::createPolator | ( | void | ) | [virtual] |
Creation a Polator for names, a Name derives from OMKType.
Implements OMK::Type::Base.
Definition at line 109 of file OMKName.cpp.
00110 { 00111 return new OMK::Type::Polator<Name>(); 00112 }
const char * Name::getCString | ( | ) | const [virtual] |
get C style string corresponding to name
Definition at line 115 of file OMKName.cpp.
References _identifier, getNameServer(), and OMK::NameServer::getStringAssociatedTo().
Referenced by OMK::PvmSvm::addNewWorkstation(), OMK::Vis::VisBase::createInput(), OMK::Vis::debugMsg(), OMK::ParametersAccessor::getAndCheckObject(), OMK::Output< T >::getDateOfLastExactValue(), OMK::Output< T >::getLastExactValue(), OMK::Controller::getPointerToDuplicatedObjectNamed(), OMK::Iii::InteractorExtension::InteractorExtension(), OMK::Iii::JointInteractorExtension::loadExtensionParameters(), OMK::MultiValuedEventSignalEmitterUtilT< T, ModelType >::loadParametersUtil(), OMK::ValuedEventSignalEmitterUtilT< T, ModelType >::loadParametersUtil(), OMK::Output< T >::localInsert(), OMK::Name::hash_compare_Name::operator()(), OMK::ValuedEventListenerCallBack< CallerClass, PrmType >::processEvent(), OMK::PvmSvm::removeWorkstation(), OMK::ObjectDescriptor::setProcess(), and OMK::PvmSvm::spawnProcess().
00116 { 00117 //OMTRACEID( OMK_DEBUG_OMK_NAME, "Name::getCString()" ) ; 00118 const char * result = ( getNameServer()->getStringAssociatedTo( _identifier ) ).c_str() ; 00119 //OMTRACEID( OMK_DEBUG_OMK_NAME, "Name::getCString() returns \"" << resul << "\"" ) ; 00120 return result ; 00121 }
const std::string & Name::getString | ( | ) | const [virtual] |
get std::string corresponding to name
Definition at line 123 of file OMKName.cpp.
References _identifier, getNameServer(), OMK::NameServer::getStringAssociatedTo(), OMK_DEBUG_OMK_NAME, and OMTRACEID.
Referenced by OMK::ExtensibleSimulatedObject::addAttribute(), OMK::ExtensionManager::addExtension(), OMK::MKMHumano::computeParameters(), OMK::Iii::SharedConnectorT< Type >::connect(), OMK::Iii::SimpleConnectorT< Type >::connect(), OMK::IAttribute::connectTo(), OMK::debugMsg(), OMK::Vis::debugMsg(), OMK::Iii::SharedConnectorT< Type >::disconnect(), OMK::Iii::SimpleConnectorT< Type >::disconnect(), OMK::IAttribute::fireValueTo(), OMK::StaticHumano::getInitialiseSequence(), OMK::Vis::VisObjectExtension::loadAnimatorParameters(), OMK::HumanoRecorder::loadParameters(), OMK::HumanoPlayer::loadParameters(), OMK::ObjectDescriptor::ObjectDescriptor(), operator!=(), OMK::Name::hash_compare_Name::operator()(), OMK::Vis::VisBase::processEvent(), OMK::Inp::InputCreatorListener::processEvent(), OMK::IAttribute::processGetValue(), OMK::IAttribute::sendValueTo(), and OMK::Output< T >::set().
00124 { 00125 OMTRACEID( OMK_DEBUG_OMK_NAME, "Name::getString()" ) ; 00126 return getNameServer()->getStringAssociatedTo( _identifier ) ; 00127 }
void Name::insertInStream | ( | std::ostream & | out | ) | const [virtual] |
Insert in a stream.
Implements OMK::Flowable.
Definition at line 130 of file OMKName.cpp.
References _identifier, getNameServer(), and OMK::NameServer::getStringAssociatedTo().
00131 { 00132 // cerr<<"Name::insertInStream of id "<<_identifier<<endl; 00133 // cerr<<"Name::insertInStream of "<<getNameServer()->getStringAssociatedTo(_identifier)<<endl; 00134 out << getNameServer()->getStringAssociatedTo( _identifier ); 00135 }
void Name::extract | ( | std::istream & | in | ) | [virtual] |
Extract from a stream.
Implements OMK::Flowable.
Definition at line 138 of file OMKName.cpp.
References _identifier, OMK::NameServer::created(), OMK::NameServer::deleted(), OMK::NameServer::getIdentifier(), and getNameServer().
00139 { 00140 std::string name ; 00141 in >> name ; 00142 idType oldIdentifier = _identifier ; 00143 00144 _identifier = getNameServer()->getIdentifier ( name ); 00145 00146 getNameServer()->created( _identifier, this ); 00147 00148 getNameServer()->deleted( oldIdentifier, this ); 00149 }
void Name::unpack | ( | IncomingSynchronisationMessage & | ) | [virtual] |
unpack from a message
Reimplemented from OMK::Flowable.
Definition at line 216 of file OMKName.cpp.
References _identifier, OMK::NameServer::created(), OMK::NameServer::deleted(), and getNameServer().
Referenced by OMK::PvmController::parseSynchronisationMessage(), OMK::PvmController::sendInitialValuesToMirror(), OMK::SimulatedObject::unpack(), OMK::PvmReferenceObjectHandle::unpack(), and OMK::SimulatedObject::unpackAllValues().
00217 { 00218 idType oldIdentifier = _identifier ; 00219 00220 in>>_identifier ; 00221 getNameServer()->created( _identifier, this ); 00222 00223 getNameServer()->deleted( oldIdentifier, this ); 00224 }
void Name::pack | ( | OutgoingSynchronisationMessage & | ) | const [virtual] |
pack in a message
Reimplemented from OMK::Flowable.
Definition at line 227 of file OMKName.cpp.
References _identifier.
Referenced by OMK::Process::pack(), OMK::Output< T >::pack(), OMK::Output< T >::packAllValues(), OMK::PvmReferenceObjectHandle::packInitialValues(), OMK::PvmMirrorObjectHandle::registerToReferenceObject(), and OMK::PvmController::sendInitialValuesToMirror().
00228 { 00229 out << _identifier ; 00230 }
affectation
Definition at line 177 of file OMKName.cpp.
References _identifier, OMK::NameServer::created(), OMK::NameServer::deleted(), and getNameServer().
00178 { 00179 // copy into onself 00180 idType oldIdentifier = _identifier ; 00181 00182 _identifier = aCopier._identifier; 00183 getNameServer()->created( _identifier, this ); 00184 00185 getNameServer()->deleted( oldIdentifier, this ); 00186 00187 return *this; 00188 }
Name & Name::operator= | ( | const char * | ) | [virtual] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 171 of file OMKName.cpp.
Name & Name::operator= | ( | const std::string & | ) | [virtual] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 156 of file OMKName.cpp.
References _identifier, OMK::NameServer::created(), OMK::NameServer::deleted(), OMK::NameServer::getIdentifier(), and getNameServer().
00157 { 00158 // copy into onself : creation must happen before deletion 00159 idType oldIdentifier = _identifier ; 00160 00161 _identifier = getNameServer()->getIdentifier( original ); 00162 00163 getNameServer()->created(_identifier, this); 00164 00165 getNameServer()->deleted( oldIdentifier, this ); 00166 00167 return *this; 00168 }
NameServer * Name::getNameServer | ( | ) | [static] |
get the name server.
If no name server has been set yet, a default name server is created
Definition at line 29 of file OMKName.cpp.
References _nameServer.
Referenced by OMK::Svm::connectToDistributedSimulation(), extract(), getCString(), getString(), insertInStream(), Name(), operator=(), OMK::Svm::serveNameRequestsUntilEnd(), unpack(), and ~Name().
00030 { 00031 static bool initialised = false ; 00032 if ( ! initialised ) 00033 { 00034 _nameServer = new NameServer () ; 00035 initialised = true ; 00036 } 00037 return _nameServer ; 00038 }
void Name::setNameServer | ( | NameServer * | ) | [static] |
change the name server will only have any effect if the new name server is equivalent to the old one
Definition at line 42 of file OMKName.cpp.
References _nameServer, OMK::NameServer::includes(), and OMMESSAGE.
Referenced by OMK::Svm::connectToDistributedSimulation(), and OMK::Svm::serveNameRequestsUntilEnd().
00043 { 00044 // the new name server is only installed if it has the same pairs <id,char *> as the old one. 00045 if ( newNameServer->includes( *_nameServer ) ) 00046 { 00047 _nameServer = newNameServer ; 00048 } 00049 else 00050 { 00051 OMMESSAGE( "WARNING : the name server wasn't changed because it wasn't equal to the old one" ); 00052 } 00053 }
a protected member function to enable change of the id by the name server
oldId | only used for verifications | |
newId | the new id to use |
Definition at line 232 of file OMKName.cpp.
References _identifier, and OMASSERTM.
Referenced by OMK::NameServer::changeNamesId().
00233 { 00234 //cerr<<"Name::changeId ( "<<oldId< <", "<<newId<<" ) "<<endl; 00235 //this is called by the name server : do not need to call back to keep the books 00236 OMASSERTM( oldId == _identifier, "" ) ; 00237 00238 _identifier = newId ; 00239 }
friend class OMK::NameServer [friend] |
smaller than
Definition at line 191 of file OMKName.cpp.
greater than
Definition at line 197 of file OMKName.cpp.
smaller than or equal to
Definition at line 203 of file OMKName.cpp.
greater than or equal to
Definition at line 210 of file OMKName.cpp.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 283 of file OMKName.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 293 of file OMKName.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 312 of file OMKName.h.
References getString().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 322 of file OMKName.h.
const Name::idType Name::_maxReservedId [static] |
max id of reserved ids (reserved ids are called system ids)
Definition at line 210 of file OMKName.h.
Referenced by OMK::NameServer::getSystemIdentifier(), OMK::EventIdentifier::isSystemEvent(), Name(), and OMK::NameServer::NameServer().
NameServer * Name::_nameServer [static, protected] |
the current name server
Definition at line 254 of file OMKName.h.
Referenced by getNameServer(), and setNameServer().
idType OMK::Name::_identifier [protected] |
the identifier used to store the name
Definition at line 262 of file OMKName.h.
Referenced by changeId(), extract(), getCString(), getString(), insertInStream(), OMK::EventIdentifier::isSystemEvent(), Name(), OMK::operator!=(), OMK::operator<(), OMK::operator<=(), operator=(), OMK::operator>(), OMK::operator>=(), pack(), unpack(), and ~Name().
Documentation generated on Mon Jun 9 11:46:02 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |