12.15 ISNamedInfo
ISInfo
#include <is/namedinfo.h>
class MyInfo: public ISNamedInfo { ... };
This is an abstract class that can be used as base class for a user-defined information types. The difference from the ISInfo class is that the ISNamedInfo defines a number of public methods which developer can use to publish this object in the IS repository, to update it or to remove from the IS. In another words, this class combines features provided by the ISInfo and ISInfoDictionary classes.
1: class PersonNamed: public ISNamedInfo {
2: public:
3: std::string name;
4: unsigned int age;
5:
6: PersonNamed( const IPCPartition & p, const char * name )
7: : ISNamedInfo( partition, name, "Person" )
8: { ; }
9:
10: void command( const std::string & cmd ) {
11: std::cout << cmd << " command has been received" << std::endl;
12: }
13:
14: void publishGuts( ISostream & out ){
15: out << name << age;
16: }
17:
18: void refreshGuts( ISistream & in ){
19: in >> name >> age;
20: }
21: };
22:
23: void main()
24: {
25: IPCPartition partition("MyPartition");
26:
27: PersonNamed person( partition, "MyServer.Person1" );
28: person.name = "Jone";
29: person.sex = Male;
30: person.birth_date = OWLDate( "24/09/83" );
31: person.checkin();
32:
33: person.name( "MyServer.Person2" ); // Set new IS repository ID
34: person.name = "Jone Smith;
35: person.checkin();
36: }
ISNamedInfo( const IPCPartition & part, const char * name, const char * type_name = ISType::Unknown );
-
Constructs an IS information object. The part is a partition in which the IS repository will be used. The name is the information object name that will be used to identify this object in the IS. The type_name defines the type name of this information object.
virtual void
command( const std::string & cmd );
-
This function is called when the command to provider, which published this information object, has been sent. The cmd parameter is the command, which was sent. It's up to implementation of a particular information class what to do in response to this command.
virtual void
publishGuts( ISostream & out );
-
Inherited from the ISInfo. Writes an information object's state to the IS output stream. User-defined class must implement this method by writing all class' attributes to the out stream.
virtual void
refreshGuts( ISistream & in );
-
Inherited from the ISInfo. Reads an information object's state from the IS input stream. User-defined class must implement this method by reading all class' attributes from the in stream.
ISType&
type( );
-
Inherited from the ISInfo. Returns reference to the ISType class that represents the type of the IS information. This type can be used for comparison and also for accessing the IS type description.
OWLTime&
time();
-
Inherited from the ISInfo. Returns time of the last information update. For the just created information returns creation time. For the definition of the OWLTime class see [12].
ISInfo::Status
checkin()
-
Inserts this information object into the IS repository if it was not there already, otherwise updates the object in the IS. The method uses the name defined at the object construction time as the information name in the IS repository. Returns ISInfo::CommFailure if the IS repository is not available.
-
This method is a mixture of the insert and update methods of the ISInfoDictionary class.
ISInfo::Status
checkout()
-
The method uses the name defined at the object construction time as the information name in the IS repository. If the information object with this name exists already in the IS repository, this method updates the attributes of the object accordingly to what is in the IS and returns ISInfo::Success. Otherwise, returns ISInfo::NotFound and doesn't change the current object. Returns ISInfo::CommFailure if the IS repository is not available.
-
The ISNamedInfo derived object must have the same type as the corresponding information object in the IS. Otherwise this function returns ISInfo::IncompatibleType and doesn't change the current object.
-
This method is an equivalent to the findValue method of the ISInfoDictionary.
ISInfo::Status
remove()
-
The method uses the name defined at the object construction time as the information name in the IS repository. If the information object with this name exists already in the IS repository, this method removes this information from the IS and returns ISInfo::Success. Returns ISInfo::NotFound if there is no such information object in the IS repository. Returns ISInfo::CommFailure if the IS repository is not available.
-
This method is an equivalent to the remove method of the ISInfoDictionary.
bool
isExist()
-
The method uses the name defined at the object construction time as the information name in the IS repository. If the information object with this name exists already in the IS repository, this method returns true. Returns false if the IS repository is not available or information object does not exist in it.
-
This method is an equivalent to the contains method of the ISInfoDictionary.
const char *
name()
-
Returns the IS information name of this object.
void
name ( const char * name )
-
Assign the name IS information identifier to this object. This new name will be used by all the other methods of this class instead of the name that has been defined at the object construction time.
2 July 1998 - WebMaster | Copyright © CERN 1998 |