00001 // -*- C++ -*- 00002 00003 /** 00004 * @file ECG_Complex_Address_Server.h 00005 * 00006 * ECG_Complex_Address_Server.h,v 1.11 2006/03/15 07:52:21 jtc Exp 00007 * 00008 * @author Marina Spivak (marina@atdesk.com) 00009 * 00010 */ 00011 00012 #ifndef TAO_ECG_COMPLEX_ADDRESS_SERVER_H 00013 #define TAO_ECG_COMPLEX_ADDRESS_SERVER_H 00014 00015 #include /**/ "ace/pre.h" 00016 00017 #include /**/ "orbsvcs/Event/event_serv_export.h" 00018 00019 #include "orbsvcs/RtecUDPAdminS.h" 00020 #include "ace/Hash_Map_Manager_T.h" 00021 #include "ace/INET_Addr.h" 00022 #include "ace/Null_Mutex.h" 00023 00024 #include "orbsvcs/Event/EC_Lifetime_Utils_T.h" 00025 00026 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00027 00028 /** 00029 * @class TAO_ECG_Complex_Address_Server 00030 * 00031 * @brief Implementation of RtecUDPAdmin idl interface, which returns 00032 * a different multicast address based on event source (or event type 00033 * - depending on how the server is configured). 00034 * 00035 * INITIALIZATION STRING FORMAT 00036 * 00037 * The string is a sequence of <key>@<value> pairs separated by 00038 * a single space, where <key> is event source (or type) 00039 * and <value> is the corresponding mcast address. Example: 00040 * "34@230.100.0.2:2300 45@230.100.123.43:2300" 00041 * The string above represents two key-value pairs. 00042 * 00043 * A special key "*" is used to specify the default mcast address, 00044 * i.e., the one that will be returned for event sources that weren't 00045 * explicitly specified in the initialization string. Example: 00046 * "*@230.100.0.2:2300 45@230.100.123.43:2300" 00047 * 00048 */ 00049 class TAO_RTEvent_Serv_Export TAO_ECG_Complex_Address_Server : 00050 public virtual POA_RtecUDPAdmin::AddrServer 00051 { 00052 public: 00053 00054 /// Create a new TAO_ECG_Complex_Address_Server object. 00055 /* 00056 * (Constructor access is restricted to insure that all 00057 * TAO_ECG_Complex_Address_Server objects are heap-allocated.) 00058 * <is_source_mapping> flag indicates whether this 00059 * server maps based on event header source or event header type. 00060 */ 00061 static TAO_EC_Servant_Var<TAO_ECG_Complex_Address_Server> 00062 create (int is_source_mapping = 1); 00063 00064 /// Destructor 00065 virtual ~TAO_ECG_Complex_Address_Server (void); 00066 00067 /// Initializes the mapping from the <arg> string. See class notes 00068 /// for the expected format. 00069 int init (const char *arg); 00070 00071 // = The RtecUDPAdmin::AddrServer methods 00072 virtual void get_addr (const RtecEventComm::EventHeader& header, 00073 RtecUDPAdmin::UDP_Addr_out addr 00074 ACE_ENV_ARG_DECL) 00075 ACE_THROW_SPEC ((CORBA::SystemException)); 00076 00077 /// Prints out complete content of the address server. Useful for 00078 /// debugging. 00079 void dump_content (void); 00080 00081 protected: 00082 00083 /// Constructor (protected). Clients can create new 00084 /// TAO_ECG_Complex_Address_Server objects using the static create() 00085 /// method. 00086 /// <is_source_mapping> flag indicates whether this 00087 /// server maps based on event header source or event header type. 00088 TAO_ECG_Complex_Address_Server (int is_source_mapping = 1); 00089 00090 private: 00091 00092 /// Helper. Given key and mcast address in string form, add them to 00093 /// the mapping. 00094 int add_entry (const char * key, const char * mcast_addr); 00095 00096 /// Flag indicating whether this address server maps event source or 00097 /// event type to mcast groups. 00098 int is_source_mapping_; 00099 00100 typedef ACE_Hash_Map_Manager_Ex<CORBA::Long, ACE_INET_Addr, 00101 ACE_Hash<CORBA::Long>, ACE_Equal_To<CORBA::Long>, ACE_Null_Mutex> MAP; 00102 00103 MAP mcast_mapping_; 00104 00105 /// Mcast group to be used for all sources (or types) not explicitly 00106 /// mapped. 00107 ACE_INET_Addr default_addr_; 00108 }; 00109 00110 TAO_END_VERSIONED_NAMESPACE_DECL 00111 00112 #if defined(__ACE_INLINE__) 00113 #include "orbsvcs/Event/ECG_Complex_Address_Server.i" 00114 #endif /* __ACE_INLINE__ */ 00115 00116 #include /**/ "ace/post.h" 00117 00118 #endif /* TAO_ECG_COMPLEX_ADDRESS_SERVER_H */