Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends

TAO_Notify_EventType Class Reference

This type is used to compare different event types. It is used by the Event Manager as a key to find subscription lists. More...

#include <EventType.h>

Inheritance diagram for TAO_Notify_EventType:
Inheritance graph
[legend]
Collaboration diagram for TAO_Notify_EventType:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TAO_Notify_EventType (void)
 Constructor.
 TAO_Notify_EventType (const char *domain_name, const char *type_name)
 TAO_Notify_EventType (const CosNotification::EventType &event_type)
virtual ~TAO_Notify_EventType ()
 Destructor.
u_long hash (void) const
 hash value
TAO_Notify_EventTypeoperator= (const CosNotification::EventType &event_type)
 Assignment from CosNotification::EventType.
TAO_Notify_EventTypeoperator= (const TAO_Notify_EventType &event_type)
 Assignment operator.
bool operator== (const TAO_Notify_EventType &notify_event_type) const
 == operator
bool operator!= (const TAO_Notify_EventType &notify_event_type) const
 != operator
CORBA::Boolean is_special (void) const
 Is this the special event (accept everything).
const CosNotification::EventType & native (void) const
 Get the type underneath us.
void dump (void) const
 Helper to print contents.
bool init (const TAO_Notify::NVPList &attrs)
 Initialize from an NVPList, return false on failure.
virtual void save_persistent (TAO_Notify::Topology_Saver &saver)

Static Public Member Functions

static TAO_Notify_EventType special (void)
 Return the special event type.

Protected Member Functions

void init_i (const char *domain_name, const char *type_name)
 Init this object.
void recompute_hash (void)
 Recompute the hash value.
bool domain_is_wildcard (const char *domain) const
bool type_is_wildcard (const char *type) const

Protected Attributes

CosNotification::EventType event_type_
 The event_type that we're decorating.
u_long hash_value_
 The hash value computed.

Friends

class TAO_Notify_Constraint_Interpreter

Detailed Description

This type is used to compare different event types. It is used by the Event Manager as a key to find subscription lists.

Definition at line 36 of file EventType.h.


Constructor & Destructor Documentation

TAO_Notify_EventType::TAO_Notify_EventType ( void   ) 

Constructor.

Definition at line 27 of file EventType.cpp.

{
}

TAO_Notify_EventType::TAO_Notify_EventType ( const char *  domain_name,
const char *  type_name 
)

Definition at line 46 of file EventType.cpp.

{
  this->init_i (domain_name, type_name);
}

TAO_Notify_EventType::TAO_Notify_EventType ( const CosNotification::EventType &  event_type  ) 

Definition at line 52 of file EventType.cpp.

{
  this->init_i (event_type.domain_name.in (), event_type.type_name.in ());
}

TAO_Notify_EventType::~TAO_Notify_EventType (  )  [virtual]

Destructor.

Definition at line 59 of file EventType.cpp.

{
}


Member Function Documentation

bool TAO_Notify_EventType::domain_is_wildcard ( const char *  domain  )  const [protected]

Definition at line 20 of file EventType.inl.

{
  return (domain == 0 || ACE_OS::strcmp (domain, "") == 0 ||
          ACE_OS::strcmp (domain, "*") == 0);
}

void TAO_Notify_EventType::dump ( void   )  const

Helper to print contents.

Definition at line 128 of file EventType.cpp.

{
  ACE_DEBUG ((LM_DEBUG,
              "(%s,%s)",
              this->event_type_.domain_name.in (),
              this->event_type_.type_name.in ()));
}

u_long TAO_Notify_EventType::hash ( void   )  const

hash value

Definition at line 8 of file EventType.inl.

{
  return this->hash_value_;
}

bool TAO_Notify_EventType::init ( const TAO_Notify::NVPList attrs  ) 

Initialize from an NVPList, return false on failure.

Definition at line 137 of file EventType.cpp.

{
  bool result = false;

  ACE_CString domain;
  ACE_CString type;
  if (attrs.load("Domain", domain) && attrs.load("Type", type))
  {
    this->init_i(domain.c_str(), type.c_str());
    result = true;
  }
  return result;

}

void TAO_Notify_EventType::init_i ( const char *  domain_name,
const char *  type_name 
) [protected]

Init this object.

Definition at line 32 of file EventType.cpp.

{
  this->event_type_.domain_name = domain_name;
  this->event_type_.type_name = type_name;

  if (this->is_special () == 1)
    {
      this->event_type_.domain_name = CORBA::string_dup ("*");
      this->event_type_.type_name = CORBA::string_dup ("%ALL");
    }

  this->recompute_hash ();
}

CORBA::Boolean TAO_Notify_EventType::is_special ( void   )  const

Is this the special event (accept everything).

Definition at line 121 of file EventType.cpp.

{
  return (this->domain_is_wildcard (this->event_type_.domain_name) &&
          this->type_is_wildcard (this->event_type_.type_name));
}

const CosNotification::EventType & TAO_Notify_EventType::native ( void   )  const

Get the type underneath us.

Definition at line 14 of file EventType.inl.

{
  return event_type_;
}

bool TAO_Notify_EventType::operator!= ( const TAO_Notify_EventType notify_event_type  )  const

!= operator

Definition at line 115 of file EventType.cpp.

{
  return !(*this == event_type);
}

TAO_Notify_EventType & TAO_Notify_EventType::operator= ( const CosNotification::EventType &  event_type  ) 

Assignment from CosNotification::EventType.

Definition at line 83 of file EventType.cpp.

{
  this->init_i (event_type.domain_name.in (),event_type.type_name.in ());

  return *this;
}

TAO_Notify_EventType & TAO_Notify_EventType::operator= ( const TAO_Notify_EventType event_type  ) 

Assignment operator.

Definition at line 91 of file EventType.cpp.

{
  if (this == &event_type)
    return *this;

  this->init_i (event_type.event_type_.domain_name.in (),event_type.event_type_.type_name.in ());

  return *this;
}

bool TAO_Notify_EventType::operator== ( const TAO_Notify_EventType notify_event_type  )  const

== operator

Definition at line 102 of file EventType.cpp.

{
  return (ACE_OS::strcmp (this->event_type_.domain_name,
                          event_type.event_type_.domain_name) == 0 ||
          this->domain_is_wildcard (this->event_type_.domain_name) ||
          this->domain_is_wildcard (event_type.event_type_.type_name)) &&
         (ACE_OS::strcmp (this->event_type_.type_name,
                          event_type.event_type_.type_name) == 0 ||
          this->type_is_wildcard (this->event_type_.type_name)   ||
          this->type_is_wildcard (event_type.event_type_.type_name));
}

void TAO_Notify_EventType::recompute_hash ( void   )  [protected]

Recompute the hash value.

Definition at line 64 of file EventType.cpp.

{
  // @@ Pradeep: this code is bound to crash someday if the strings
  // are too long....  See if the hash_pjw () function can be modified
  // to take accumulate multiple strings, as in:
  //   hash = ACE::hash_pjw_accummulate (0, str1);
  //   hash = ACE::hash_pjw_accummulate (hash, str2);
  //
  // @@ Or use grow the buffer when needed, or just add the two hash
  // values or something, but fix this code!
  //
  char buffer[BUFSIZ];
  ACE_OS::strcpy (buffer, this->event_type_.domain_name.in ());
  ACE_OS::strcat (buffer, this->event_type_.type_name.in ());

  this->hash_value_ =  ACE::hash_pjw (buffer);
}

void TAO_Notify_EventType::save_persistent ( TAO_Notify::Topology_Saver saver  )  [virtual]

Save our state to a Topology_Saver.

Use the methods of a Topology_Saver to store all information we want persisted. This function is called by our parent, which gives us a saver to use. In turn, we must call this function on all of our children. The implementation should look like: bool change = this->self_changed_; this->self_changed_ = false; this->children_changed_ = false; if (is_persistent ()) { bool want_all_children = saver.begin_object( this->id(), type, attrs, change); for all children { if (want_all_children || child.is_changed()) { child.save_persistent(saver); } } for all deleted children { saver.delete_child(child_type, child_id); } saver.end_object(this->id(), type); )

Implements TAO_Notify::Topology_Savable.

Definition at line 155 of file EventType.cpp.

{
  TAO_Notify::NVPList attrs;
  bool changed = true;

  attrs.push_back(TAO_Notify::NVP("Domain", this->event_type_.domain_name.in()));
  attrs.push_back(TAO_Notify::NVP("Type", this->event_type_.type_name.in()));
  saver.begin_object(0, "subscription", attrs, changed);

  saver.end_object(0, "subscription");
}

TAO_Notify_EventType TAO_Notify_EventType::special ( void   )  [static]

Return the special event type.

Definition at line 22 of file EventType.cpp.

{
  return TAO_Notify_EventType ("*", "%ALL");
}

bool TAO_Notify_EventType::type_is_wildcard ( const char *  type  )  const [protected]

Definition at line 27 of file EventType.inl.

{
  return (type == 0 || ACE_OS::strcmp (type, "") == 0 ||
          ACE_OS::strcmp (type, "*") == 0 ||
          ACE_OS::strcmp (type, "%ALL") == 0);
}


Friends And Related Function Documentation

friend class TAO_Notify_Constraint_Interpreter [friend]

Definition at line 84 of file EventType.h.


Member Data Documentation

CosNotification::EventType TAO_Notify_EventType::event_type_ [protected]

The event_type that we're decorating.

Definition at line 97 of file EventType.h.

The hash value computed.

Definition at line 100 of file EventType.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines