Event.cpp

Go to the documentation of this file.
00001 // $Id: Event.cpp 79324 2007-08-13 11:20:01Z elliott_c $
00002 
00003 #include "orbsvcs/Notify/Event.h"
00004 
00005 #if ! defined (__ACE_INLINE__)
00006 #include "orbsvcs/Notify/Event.inl"
00007 #endif /* __ACE_INLINE__ */
00008 
00009 ACE_RCSID (Notify,
00010            TAO_Notify_Event,
00011            "$Id: Event.cpp 79324 2007-08-13 11:20:01Z elliott_c $")
00012 
00013 #include "tao/debug.h"
00014 #include "tao/CDR.h"
00015 #include "orbsvcs/CosNotificationC.h"
00016 // NOTE: unfortunately we must know about derived types to implement unmarshal
00017 #include "orbsvcs/Notify/Any/AnyEvent.h"
00018 #include "orbsvcs/Notify/Structured/StructuredEvent.h"
00019 
00020 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00021 
00022 TAO_Notify_Event::TAO_Notify_Event (void)
00023 : priority_ (CosNotification::Priority, CosNotification::DefaultPriority)
00024 , timeout_ (CosNotification::Timeout)
00025 , reliable_ (CosNotification::EventReliability, true)
00026 , clone_ (0)
00027 , is_on_heap_ (false)
00028 , time_ (ACE_OS::gettimeofday ())
00029 {
00030   //  if (TAO_debug_level > 0)
00031   //  ACE_DEBUG ((LM_DEBUG,"event:%x  created\n", this ));
00032 }
00033 
00034 TAO_Notify_Event::~TAO_Notify_Event ()
00035 {
00036   // if (TAO_debug_level > 1)
00037   //  ACE_DEBUG ((LM_DEBUG,"event:%x  destroyed\n", this ));
00038 }
00039 void
00040 TAO_Notify_Event::release (void)
00041 {
00042   delete this;
00043 }
00044 
00045 void
00046 TAO_Notify_Event::translate (const CORBA::Any& any, CosNotification::StructuredEvent& notification)
00047 {
00048   notification.remainder_of_body <<= any;
00049   notification.header.fixed_header.event_type.type_name = CORBA::string_dup ("%ANY");
00050   notification.header.fixed_header.event_type.domain_name = CORBA::string_dup ("");
00051 }
00052 
00053 void
00054 TAO_Notify_Event::translate (const CosNotification::StructuredEvent& notification, CORBA::Any& any)
00055 {
00056   any <<= notification;   // is the typecode set by this operation or do we need to set it explicity.
00057 }
00058 /// Unmarshal an event from a CDR. (for persistence)
00059 //static
00060 TAO_Notify_Event *
00061 TAO_Notify_Event::unmarshal (TAO_InputCDR & cdr)
00062 {
00063   TAO_Notify_Event * result = 0;
00064   ACE_CDR::Octet code = 0;
00065   if (cdr.read_octet (code))
00066   {
00067     switch (code)
00068     {
00069     case MARSHAL_ANY:
00070       result = TAO_Notify_AnyEvent::unmarshal (cdr);
00071       break;
00072     case MARSHAL_STRUCTURED:
00073       result = TAO_Notify_StructuredEvent::unmarshal (cdr);
00074       break;
00075     default:
00076       ACE_ERROR ((LM_ERROR,
00077         ACE_TEXT ("(%P|%t) TAO_Notify_Event::unmarshal: unknown event code %d\n"),
00078         code));
00079       break;
00080     }
00081   }
00082   return result;
00083 }
00084 
00085 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:45:29 2010 for TAO_CosNotification by  doxygen 1.4.7