diff options
Diffstat (limited to 'TAO/orbsvcs/orbsvcs/Notify/Notify_Types.h')
-rw-r--r-- | TAO/orbsvcs/orbsvcs/Notify/Notify_Types.h | 222 |
1 files changed, 222 insertions, 0 deletions
diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Types.h b/TAO/orbsvcs/orbsvcs/Notify/Notify_Types.h new file mode 100644 index 00000000000..9e904e2b732 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Types.h @@ -0,0 +1,222 @@ +// $Id$ +// ========================================================================== +// +// = LIBRARY +// Orbsvcs +// +// = FILENAME +// Notify_Types.h +// +// = DESCRIPTION +// Internal types used by Notify +// +// = AUTHOR +// Pradeep Gore <pradeep@cs.wustl.edu> +// +// ========================================================================== + +#ifndef TAO_NOTIFY_TYPES_H +#define TAO_NOTIFY_TYPES_H +#include "ace/pre.h" + +#include "orbsvcs/CosNotifyFilterC.h" +#include "orbsvcs/CosNotifyCommC.h" +#include "ace/Containers_T.h" + +class TAO_Notify_EventListener; +class TAO_Notify_UpdateListener; + +class TAO_Notify_EventType +{ + // = TITLE + // TAO_Notify_EventType + // + // = DESCRIPTION + // This type is used to compare different event types. + // It is used by the Event Manager as a key to find subscription lists. + // +public: + // = Initialization and termination + TAO_Notify_EventType (void); + TAO_Notify_EventType (const char* domain_name, const char* type_name); + TAO_Notify_EventType (const CosNotification::EventType& event_type); + // Constuctor + + ~TAO_Notify_EventType (); + // Destructor + + u_long hash (void) const; + // hash value + + void operator=(const CosNotification::EventType& event_type); + // Assignment from CosNotification::EventType + + int operator==(const TAO_Notify_EventType& notify_event_type) const; + // == operator + + static TAO_Notify_EventType& special_event_type (void); + // Return the special event type. + + CORBA::Boolean is_special (void) const; + // Is this the special event (accept everything). + + const CosNotification::EventType& get_native (void) const; + // Get the type underneath us. + +protected: + void recompute_hash (void); + // Recompute the hash value. + + // = Data Members + CosNotification::EventType event_type_; + // The event_type that we're decorating. + + u_long hash_value_; + // The hash value computed. + + static TAO_Notify_EventType special_event_type_; + // A special event type +}; + +// **************************************************************** +// @@ Pradeep: please remember to separate your classes with a line +// like the one above. Or better yet, do not put multiple classes in +// the same file. + +class TAO_Notify_Event +{ + // = TITLE + // TAO_Notify_Event + // + // = DESCRIPTION + // Abstraction for an event + // This class allows us to treat event types homogenously. + // Derived types for anys and structured events provide the implementation. + // This the the "prototype" creational pattern. + // +public: + virtual CORBA::Boolean is_special_event_type (void) const = 0; + // Is this the "special" event type. + + virtual const TAO_Notify_EventType& event_type (void) const = 0; + // Get the event type. + + virtual TAO_Notify_Event* clone (void) = 0; + // We may need to make a copy of the underlying data if it is not owned + // by us. + // Note this behaviour: If this object owns the data, then we *transfer* + // ownership of the data to the new object otherwise we copy the data + // for the new object. + + virtual CORBA::Boolean do_match (CosNotifyFilter::Filter_ptr filter, CORBA::Environment &ACE_TRY_ENV) const = 0; + // Returns true if the filter matches. + + virtual void do_push (CosEventComm::PushConsumer_ptr consumer, CORBA::Environment &ACE_TRY_ENV) const = 0; + virtual void do_push (CosNotifyComm::StructuredPushConsumer_ptr consumer, CORBA::Environment &ACE_TRY_ENV) const = 0; + // Push self to <consumer> +}; + +// **************************************************************** + +class TAO_Notify_Any : public TAO_Notify_Event +{ + // = TITLE + // TAO_Notify_Any + // + // = DESCRIPTION + // This class is the concrete prototype for the Any type. + // + +public: + TAO_Notify_Any (void); + TAO_Notify_Any (const CORBA::Any & data); + virtual ~TAO_Notify_Any (); + + virtual TAO_Notify_Event* clone (void); + + void operator=(const TAO_Notify_Any& notify_any); + + virtual CORBA::Boolean is_special_event_type (void) const; + virtual const TAO_Notify_EventType& event_type (void) const; + virtual CORBA::Boolean do_match (CosNotifyFilter::Filter_ptr filter, CORBA::Environment &ACE_TRY_ENV) const; + virtual void do_push (CosEventComm::PushConsumer_ptr consumer, CORBA::Environment &ACE_TRY_ENV) const; + virtual void do_push (CosNotifyComm::StructuredPushConsumer_ptr consumer, CORBA::Environment &ACE_TRY_ENV) const; + +protected: + CORBA::Any* data_; + // The data + + CORBA::Boolean is_owner_; + // Do we own the data. +}; + +// **************************************************************** + +class TAO_Notify_StructuredEvent : public TAO_Notify_Event +{ + // = TITLE + // TAO_Notify_StructuredEvent + // + // = DESCRIPTION + // This class is the concrete prototype for the Structured Event Type. + // +public: + TAO_Notify_StructuredEvent (void); + TAO_Notify_StructuredEvent (const CosNotification::StructuredEvent & notification); + virtual ~TAO_Notify_StructuredEvent (); + + virtual TAO_Notify_Event* clone (void); + void operator=(const TAO_Notify_StructuredEvent &structured_event); + + virtual CORBA::Boolean is_special_event_type (void) const; + virtual const TAO_Notify_EventType& event_type (void) const; + virtual CORBA::Boolean do_match (CosNotifyFilter::Filter_ptr filter, CORBA::Environment &ACE_TRY_ENV) const; + virtual void do_push (CosEventComm::PushConsumer_ptr consumer, CORBA::Environment &ACE_TRY_ENV) const; + virtual void do_push (CosNotifyComm::StructuredPushConsumer_ptr consumer, CORBA::Environment &ACE_TRY_ENV) const; + +protected: + CosNotification::StructuredEvent* data_; + // The data + + TAO_Notify_EventType event_type_; + // The event type of <data_> + + CORBA::Boolean is_owner_; + // Do we own the data. +}; + +// **************************************************************** + +class TAO_Notify_EventType_List : public ACE_Unbounded_Set <TAO_Notify_EventType> +{ + // = TITLE + // TAO_Notify_EventType_List + // + // = DESCRIPTION + // Allows operations using the CosNotification::EventTypeSeq type. + // + + typedef ACE_Unbounded_Set <TAO_Notify_EventType> inherited; + +public: + void populate (CosNotification::EventTypeSeq& event_type_seq); + // Populate <event_type_seq> with the contents of this object. + + void insert_seq (const CosNotification::EventTypeSeq& event_type_seq); + // insert the contents of <event_type_seq> into this object. + + void remove_seq (const CosNotification::EventTypeSeq& event_type_seq); + // remove the contents of <event_type_seq> from this object. +}; + +// **************************************************************** + +// = typedefs +typedef ACE_Unbounded_Set<TAO_Notify_EventListener*> TAO_Notify_EventListener_List; +// A list of event listeners that are looking for the same event type. + +typedef ACE_Unbounded_Set<TAO_Notify_UpdateListener*> TAO_Notify_UpdateListener_List; +// A list of update listeners who want to be notified about publish/subscribe changes. + +#include "ace/post.h" +#endif /* TAO_NOTIFY_TYPES_H */ |