fesa::SubscriptionTreeManager Class Reference

The SubscriptionTreeManager is implemented as a singleton. It provides a functional interface to the subscription tree and manages the tree - mutex - policity. More...

#include <SubscriptionTreeManager.h>

List of all members.

Public Member Functions

 SubscriptionTreeManager (bool useFastUpdate)
 Flag defining the client update policy fastUpdate =true: data are all first collected and flushed all at once. fastUpdate =false: data are collected and flushed one by one.
 SubscriptionTreeManager (const SubscriptionTreeManager &other)
SubscriptionTreeManageroperator= (const SubscriptionTreeManager &other)
bool initialize ()
 After the build up of the class tree, the initialize method can be started.
void addSubscriber (const std::string &className, AbstractDevice &device, Property &property, const std::string &cycleSelector, const rdaData &filter, rdaValueChangeListener *subscriber)
 This method adds a subscriber to the subscription tree. The new subscriber is also added into the "Notification" vector.
void removeSubscriber (AbstractDevice &device, Property &property, const std::string &cycleSelector, rdaValueChangeListener *subscriber)
 This method removes a subscriber from the subscription tree. The subscriber is also deleted from the "Notification" vector.
void notify (uint32_t IDKey, MultiplexingContext &muxContext, RequestType &reqType)
 The Core::NotificationConsumer calls this method, in order to notify all necessary subscribers.
void notify (ManualNotificationMessage *msg, RequestType &reqType)
 The Core::NotificationConsumer calls this method, in order to notify all necessary subscribers.
void reportInternalError (const std::string &errorCategory, int32_t errorCode, const std::string &message)
 Reports the error to all clients currently subscribed.
 ~SubscriptionTreeManager ()
 destructor.

Private Types

typedef std::map< uint32_t,
boost::shared_ptr
< Notification > > 
NotificationMap
 hashmap that contains all the notifications in the tree. A Notification is identified by a unique Id. This Id is used as a primary key to locate an instance of Notification
typedef NotificationMap::iterator NotificationItr
typedef std::map< std::string,
boost::shared_ptr
< SubscriptionParameter > > 
SubscriptionMap
 hashmap that contains all the current subscriptions
typedef SubscriptionMap::iterator SubscriptionItr

Private Member Functions

boost::shared_ptr
< SubscriptionParameter
addSubscriptionParam (const std::string &paramName, AbstractDevice &device, Property &property, const std::string &cycleSelector, const rdaData &filter, rdaValueChangeListener *subscriber)
 This method provides a lock for reader - threads. Any number of reader threads may lock at the same time. Writer threads have to use lockSubscriptionTree_editTree. The method will wait, until the lock is granted.
void initNotifications ()
 This method fills the Notification Vector, with Notifications. The IDs are recieved from the Core::EquipmentData class.
void printState (std::string &header)

Private Attributes

Mutex treeMutex_
 Since the deviceCollections on the RT side contain no global devices, and the knowledge if a property is global is kept on the server side, we have to add the information here.
NotificationMap notifications_
SubscriptionMap subscriptions_
SubscriptionCycle subscriptionCycle_
 contains all the current cycleSelector used at the moment This object should return the list cycleSelector matching a given context
bool initializationSucessfull_
 True, if the initialization was successful.
int32_t lastErrorCode_
 If a subscriber subscribes, before the IDCollection is retrieved, he is temporary stored in this list.
bool useFastUpdate_
 Flag defining the client update policy fastUpdate =true: data are all first collected and flushed all at once. fastUpdate =false: data are collected and flushed one by one.
NotificationThreadFactory notificationThreadFactory_
 The factory in charge of the creation of the background threads for notifications.

Detailed Description

The SubscriptionTreeManager is implemented as a singleton. It provides a functional interface to the subscription tree and manages the tree - mutex - policity.

Definition at line 33 of file SubscriptionTreeManager.h.


Member Typedef Documentation

typedef NotificationMap::iterator fesa::SubscriptionTreeManager::NotificationItr [private]

Definition at line 134 of file SubscriptionTreeManager.h.

typedef std::map<uint32_t, boost::shared_ptr<Notification> > fesa::SubscriptionTreeManager::NotificationMap [private]

hashmap that contains all the notifications in the tree. A Notification is identified by a unique Id. This Id is used as a primary key to locate an instance of Notification

Definition at line 133 of file SubscriptionTreeManager.h.

typedef SubscriptionMap::iterator fesa::SubscriptionTreeManager::SubscriptionItr [private]

Definition at line 141 of file SubscriptionTreeManager.h.

typedef std::map<std::string, boost::shared_ptr<SubscriptionParameter> > fesa::SubscriptionTreeManager::SubscriptionMap [private]

hashmap that contains all the current subscriptions

Definition at line 140 of file SubscriptionTreeManager.h.


Constructor & Destructor Documentation

fesa::SubscriptionTreeManager::SubscriptionTreeManager ( bool  useFastUpdate  ) 

Flag defining the client update policy fastUpdate =true: data are all first collected and flushed all at once. fastUpdate =false: data are collected and flushed one by one.

Definition at line 36 of file SubscriptionTreeManager.cpp.

fesa::SubscriptionTreeManager::SubscriptionTreeManager ( const SubscriptionTreeManager other  ) 
fesa::SubscriptionTreeManager::~SubscriptionTreeManager (  ) 

destructor.

Definition at line 42 of file SubscriptionTreeManager.cpp.

References notifications_, and subscriptions_.


Member Function Documentation

void fesa::SubscriptionTreeManager::addSubscriber ( const std::string &  className,
AbstractDevice device,
Property property,
const std::string &  cycleSelector,
const rdaData &  filter,
rdaValueChangeListener *  subscriber 
)

This method adds a subscriber to the subscription tree. The new subscriber is also added into the "Notification" vector.

Parameters:
property the corresponding property
cycleSelector the CycleSelecto of the subscriber
device to which device the subscriber has subscribed
filter the filter, which is used for the data
subscriber a ref to the subscriber, which is called, if new data is available

Definition at line 66 of file SubscriptionTreeManager.cpp.

References fesa::SubscriptionCycle::addCycle(), addSubscriptionParam(), fesa::AbstractDevice::getName(), initializationSucessfull_, initNotifications(), notifications_, printState(), subscriptionCycle_, and treeMutex_.

Referenced by fesa::FesaDeviceServer::monitorOn().

boost::shared_ptr< SubscriptionParameter > fesa::SubscriptionTreeManager::addSubscriptionParam ( const std::string &  paramName,
AbstractDevice device,
Property property,
const std::string &  cycleSelector,
const rdaData &  filter,
rdaValueChangeListener *  subscriber 
) [private]

This method provides a lock for reader - threads. Any number of reader threads may lock at the same time. Writer threads have to use lockSubscriptionTree_editTree. The method will wait, until the lock is granted.

Definition at line 255 of file SubscriptionTreeManager.cpp.

References fesa::Property::getClassName(), fesa::NotificationThreadFactory::getThread(), notificationThreadFactory_, subscriptions_, and useFastUpdate_.

Referenced by addSubscriber().

bool fesa::SubscriptionTreeManager::initialize (  ) 

After the build up of the class tree, the initialize method can be started.

Returns:
true, if sucessfull
void fesa::SubscriptionTreeManager::initNotifications (  )  [private]

This method fills the Notification Vector, with Notifications. The IDs are recieved from the Core::EquipmentData class.

Definition at line 281 of file SubscriptionTreeManager.cpp.

References fesa::NotificationIDManager::getInstance(), fesa::NotificationIDManager::getNotificationIDCol(), initializationSucessfull_, and notifications_.

Referenced by addSubscriber(), and notify().

void fesa::SubscriptionTreeManager::notify ( ManualNotificationMessage msg,
RequestType reqType 
)

The Core::NotificationConsumer calls this method, in order to notify all necessary subscribers.

Parameters:
ManualNotificationMessage 
reqType The type of this notification

Definition at line 198 of file SubscriptionTreeManager.cpp.

References fesa::SubscriptionCycle::matchContext(), fesa::ManualNotificationMessage::muxContext_, fesa::ManualNotificationMessage::propertiesAndDevicesCol_, subscriptionCycle_, subscriptions_, treeMutex_, and useFastUpdate_.

void fesa::SubscriptionTreeManager::notify ( uint32_t  IDKey,
MultiplexingContext muxContext,
RequestType reqType 
)

The Core::NotificationConsumer calls this method, in order to notify all necessary subscribers.

Parameters:
IDKey The ID, of the Notification, which is triggered
muxContext The Multiplexing Context, given by the RTAction
reqType The type of this notification

Definition at line 169 of file SubscriptionTreeManager.cpp.

References initializationSucessfull_, initNotifications(), notifications_, treeMutex_, and useFastUpdate_.

Referenced by fesa::NotificationConsumer::run().

SubscriptionTreeManager& fesa::SubscriptionTreeManager::operator= ( const SubscriptionTreeManager other  ) 
void fesa::SubscriptionTreeManager::printState ( std::string &  header  )  [private]
void fesa::SubscriptionTreeManager::removeSubscriber ( AbstractDevice device,
Property property,
const std::string &  cycleSelector,
rdaValueChangeListener *  subscriber 
)

This method removes a subscriber from the subscription tree. The subscriber is also deleted from the "Notification" vector.

Parameters:
property the corresponding property
cycleSelector the CycleSelecto of the subscriber
device to which device the subscriber has subscribed
subscriber a ref to the subscriber, which is to remove

Definition at line 120 of file SubscriptionTreeManager.cpp.

References fesa::AbstractDevice::getName(), notifications_, printState(), fesa::SubscriptionCycle::removeCycle(), subscriptionCycle_, subscriptions_, and treeMutex_.

Referenced by fesa::FesaDeviceServer::monitorOff().

void fesa::SubscriptionTreeManager::reportInternalError ( const std::string &  errorCategory,
int32_t  errorCode,
const std::string &  message 
)

Reports the error to all clients currently subscribed.

Parameters:
errorCategory 
errorCode 
message 

Definition at line 241 of file SubscriptionTreeManager.cpp.

References lastErrorCode_, subscriptions_, and treeMutex_.

Referenced by fesa::AbstractServerEquipment::waitSignal().


Member Data Documentation

True, if the initialization was successful.

Definition at line 153 of file SubscriptionTreeManager.h.

Referenced by addSubscriber(), initNotifications(), and notify().

If a subscriber subscribes, before the IDCollection is retrieved, he is temporary stored in this list.

LastErrorCode reported using reportInternalError

Definition at line 164 of file SubscriptionTreeManager.h.

Referenced by reportInternalError().

The factory in charge of the creation of the background threads for notifications.

Definition at line 176 of file SubscriptionTreeManager.h.

Referenced by addSubscriptionParam().

contains all the current cycleSelector used at the moment This object should return the list cycleSelector matching a given context

Definition at line 148 of file SubscriptionTreeManager.h.

Referenced by addSubscriber(), notify(), printState(), and removeSubscriber().

Since the deviceCollections on the RT side contain no global devices, and the knowledge if a property is global is kept on the server side, we have to add the information here.

Protect the SubscriptionParameter collection from concurrent access

Definition at line 127 of file SubscriptionTreeManager.h.

Referenced by addSubscriber(), notify(), removeSubscriber(), and reportInternalError().

Flag defining the client update policy fastUpdate =true: data are all first collected and flushed all at once. fastUpdate =false: data are collected and flushed one by one.

Definition at line 171 of file SubscriptionTreeManager.h.

Referenced by addSubscriptionParam(), and notify().


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

Generated on 18 Jan 2013 for Fesa by  doxygen 1.6.1