15.14 ISInfoReceiver
IPCServer
#include <is/inforeceiver.h>
IPCPartition p ( "MyPartition" );
ISInfoReceiver isir( p );
This class provides the main interface for the subscriptions to the IS repository. By using the methods of this class an application can subscribe for the changes in the IS repository or remove previously created subscriptions.
1: void callback1(ISCallbackInfo * isc){
2: ISInfoInt isi;
3:
4: if ( isc->type() == isi.type() ){
5: isc->value(isi);
6: cout << isc->name() << " : " << isi << endl;
7: }
8: else
9: cout << isc->name() << " has unknown type " << isc->type() << endl;
10: }
11:
12: void callback2(ISCallbackInfo * isc){
13: ISInfoAny isa;
14: isc->value(isa);
15: cout << isc->name() << " has type " << isc->type() << endl;
16: cout << " and value : " << isa << endl;
17: }
18:
19: void main(void){
20: IPCPartition p;
21: ISInfoReceiver ir(p);
22: cerr << ir.subscribe( "MyServer.DeviceVoltage", callback1 ) << endl;
23: cerr << ir.subscribe( "MyServer", "Device.*", callback2 ) << endl;
24: ir.run();
25: }
ISInfoReceiver( bool serialize_callbacks = true );
-
Constructs new ISInfoReceiver object which can be used for access to the IS repository in the default IPC partition. The serialize_callbacks parameter defines whether callbacks will be serialized into a single thread or they will be executed in parallel in the context of several concurrent threads.

For compatibility with the early versions of the IS, the default value of the serialize_callbacks parameter is set to true, which means that callbacks will be serialized. But it's strongly recommended to set this parameter to false to allow concurrent callbacks processing, which drastically increases the callback processing rate. Note that in this case the callback code has to be thread safe, i.e. it has to guard every access to shared data by mutex.
ISInfoReceiver( const IPCPartition & part, bool serialize_callbacks = true );
-
Constructs new ISInfoReceiver object which can be used for access to the IS repository in the part IPC partition. The serialize_callbacks parameter defines whether callbacks will be serialized into a single thread or they will be executed in parallel in the context of several concurrent threads.

For compatibility with the early versions of the IS, the default value of the serialize_callbacks parameter is set to true, which means that callbacks will be serialized. But it's strongly recommended to set this parameter to false to allow concurrent callbacks processing, which drastically increases the callback processing rate. Note that in this case the callback code has to be thread safe, i.e. it has to guard every access to shared data by mutex.
-
const IPCPartition &
partition();
-
Returns the partition in which this instance of the ISInfoReceiver has been created.
void
subscribe( const std::string & name, ISCallbackInfo::Callback callback, void* param = 0);
-
Sets user callback that will be called each time the value of the information object associated with the name name is changed. The callback is a user function that will be called, param is the user parameter that will be passed to this function.
-
Throws daq::is::RepositoryNotFound if the IS repository is not available, daq::is::AlreadySubscribed in case the same subscription has been already done via this instance of the ISInfoReceiver or daq::is::InvalidName if the given information name is invalid, i.e. does not contain Server/Object name separator (dot).
void
subscribe( const std::string & name, ISCallbackEvent::Callback callback, void* param = 0);
-
Sets user callback that will be called each time the value of the information object associated with the name name is changed. The object value will not transported as part of the callback message. The callback is a user function that will be called, param is the user parameter that will be passed to this function.
-
Throws daq::is::RepositoryNotFound if the IS repository is not available, daq::is::AlreadySubscribed in case the same subscription has been already done via this instance of the ISInfoReceiver or daq::is::InvalidName if the given information name is invalid, i.e. does not contain Server/Object name separator (dot).
void
subscribe(const std::string & server_name, const ISCriteria & criteria, ISCallbackInfo::Callback callback, void* param = 0);
-
Sets user callback for the server_name IS server. The callback function will be invoked each time the information objects, which match the criteria criteria are changed. The param is the user parameter that will be passed to the callback function.
-
Throws daq::is::RepositoryNotFound if the IS repository is not available, daq::is::AlreadySubscribed in case the same subscription has been already done via this instance of the ISInfoReceiver or daq::is::InvalidCriteria if the given criteria parameter is invalid (e.g. contains invalid regular expression).
void
subscribe(const std::string & server_name, const ISCriteria & criteria, ISCallbackEvent::Callback callback, void* param = 0);
-
Sets user callback for the server_name IS server. The callback function will be invoked each time the information objects, which match the criteria criteria are changed. The object value will not transported as part of the callback message. The param is the user parameter that will be passed to the callback function.
-
Throws daq::is::RepositoryNotFound if the IS repository is not available, daq::is::AlreadySubscribed in case the same subscription has been already done via this instance of the ISInfoReceiver or daq::is::InvalidCriteria if the given criteria parameter is invalid (e.g. contains invalid regular expression).
void
unsubscribe( const std::string & name, bool wait_for_completion = true);
-
Removes subscription which has been previously done for the information object associated with the name name. The wait_for_completion parameter defines whether this function has to be blocked before the processing for all callbacks which have already been delivered for the given subscription is finished.

Be careful, since if this function is called from the callback itself with the wait_for_completion parameter set to true, this call will be blocked forever.
-
Throws daq::is::SubscriptionNotFound if the subscription has not been done or has been already removed, daq::is::RepositoryNotFound if the IS repository is not available.
void
unsubscribe(const std::string & server_name, const ISCriteria & criteria, bool wait_for_completion = true);
-
Removes the subscription which has been previously done using the criteria and the server_name IS server. The wait_for_completion parameter defines whether this function has to be blocked before the processing for all callbacks which have already been delivered for the given subscription is finished.

Be careful, since if this function is called from the callback itself with the wait_for_completion parameter set to true, this call will be blocked forever.
-
-
Throws daq::is::SubscriptionNotFound if the subscription has not been done or has been already removed, daq::is::RepositoryNotFound if the IS repository is not available.
Inherited Public Member Functions |
void
run();
-
Inherited from the IPCServer class. This method blocks the current thread of execution until the stop method of the same ISInfoReceiver instance is called.
void
stop();
-
Inherited from the IPCServer class. Unblock the thread which has been blocked by the run method of the same ISInfoReceiver instance.
2 July 1998 - WebMaster | Copyright © CERN 1998 |