FlowSpec_Entry.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // ============================================================================
00004 /**
00005  *  @file    FlowSpec_Entry.h
00006  *
00007  *  $Id: FlowSpec_Entry.h 81401 2008-04-23 18:12:56Z elliott_c $
00008  *
00009  *  @author  Nagarajan Surendran <naga@cs.wustl.edu>
00010  *
00011  */
00012 // ============================================================================
00013 
00014 #ifndef TAO_AV_FLOWSPEC_ENTRY_H
00015 #define TAO_AV_FLOWSPEC_ENTRY_H
00016 #include /**/ "ace/pre.h"
00017 
00018 #include "orbsvcs/AV/AV_export.h"
00019 #include "orbsvcs/AV/AV_Core.h"
00020 #include "ace/Addr.h"
00021 #include "ace/Containers.h"
00022 #include "ace/SString.h"
00023 
00024 
00025 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00026 
00027 /**
00028  * @class TAO_Tokenizer
00029  * @brief
00030  */
00031 class TAO_AV_Export TAO_Tokenizer
00032 {
00033 public:
00034   /// constructor.
00035   TAO_Tokenizer (const char *string,char delimiter);
00036 
00037   /// destructor.
00038   ~TAO_Tokenizer (void);
00039 
00040   /// parses the string and tokenizes it.
00041   int parse (const char *string,char delimiter);
00042 
00043   /// Returns the next token.
00044   char *token (void);
00045 
00046   /// Number of tokens.
00047   int num_tokens (void);
00048 
00049   const char *operator [] (size_t index) const;
00050 
00051 protected:
00052   ACE_Array<char*> token_array_;
00053   size_t count_;
00054   size_t num_tokens_;
00055   char string_ [BUFSIZ];
00056 };
00057 
00058 // Forward declaration.
00059 class TAO_AV_Transport;
00060 class TAO_AV_Flow_Handler;
00061 class TAO_AV_Protocol_Object;
00062 
00063 /**
00064  * @class TAO_FlowSpec_Entry
00065  * @brief  A helper entry class in the flow spec sequence passed to
00066  *         bind_devs.
00067  */
00068 class TAO_AV_Export TAO_FlowSpec_Entry
00069 {
00070 public:
00071 
00072   enum Direction
00073   {
00074     TAO_AV_INVALID   = -1,
00075     TAO_AV_DIR_IN    =  0,
00076     TAO_AV_DIR_OUT   =  1
00077   };
00078 
00079   enum Role
00080   {
00081     TAO_AV_INVALID_ROLE = -1,
00082     TAO_AV_PRODUCER = 0,
00083     TAO_AV_CONSUMER = 1
00084   };
00085 
00086   /// default constructor.
00087   TAO_FlowSpec_Entry (void);
00088 
00089   /// constructor to construct an entry from the arguments.
00090   TAO_FlowSpec_Entry (const char *flowname,
00091                       const char *direction,
00092                       const char *format_name,
00093                       const char *flow_protocol,
00094                       const char *carrier_protocol,
00095                       ACE_Addr *fwd_address,
00096                       //ACE_Addr *peer_address,
00097                       ACE_Addr *control_address = 0);
00098 
00099   TAO_FlowSpec_Entry (const char *flowname,
00100                       const char *direction,
00101                       const char *format_name,
00102                       const char *flow_protocol,
00103                       const char *fwd_address);
00104                       //const char *peer_address);
00105 
00106   /// construct the entry from a string specified by the flowSpec grammar.
00107   virtual int parse (const char* flowSpec_entry) = 0;
00108 
00109   /// virtual destructor.
00110   virtual ~TAO_FlowSpec_Entry (void);
00111 
00112   /// accessor to the direction.
00113   int direction (void);
00114 
00115   virtual Role role (void) = 0;
00116   void role (Role role);
00117   /// accessor to string version of direction .
00118   const char * direction_str (void) const;
00119 
00120   /// accessor to the flow protocol string.
00121   const char *flow_protocol_str (void) const;
00122 
00123   /// set the flow protocol string.
00124   void flow_protocol_str (const char *flow_protocol_str);
00125 
00126   /// accessor to address of the carrier protocol.
00127   //ACE_Addr *fwd_address (void);
00128   ACE_Addr *address (void);
00129   ACE_Addr *control_address (void);
00130   void address (ACE_Addr *address, bool cleanup = false);
00131   void control_address (ACE_Addr *address);
00132 
00133   /// Address in string format i. hostname:port.
00134   const char *address_str (void) const;
00135   //  const char * peer_address_str (void) const;
00136 
00137   /// accessor to carrier protocol i.e TCP,UDP,RTP/UDP.
00138   TAO_AV_Core::Protocol carrier_protocol (void);
00139 
00140   /// accessor to string version of carrier protocol.
00141   const char * carrier_protocol_str (void) const;
00142 
00143   /// accessor to format to be used for this flow.
00144   const char *format (void) const;
00145 
00146   /// accessor to name of this flow.
00147   const char *flowname (void) const;
00148 
00149   /// converts the entry to a string.
00150   virtual const char *entry_to_string (void) = 0;
00151 
00152   int set_peer_addr (ACE_Addr *peer_addr);
00153   ACE_Addr *get_peer_addr (void);
00154   int set_peer_control_addr (ACE_Addr *peer_control_addr);
00155   ACE_Addr *get_peer_control_addr (void);
00156 
00157   int set_local_sec_addr (char** local_sec_addr, int size);
00158   char** get_local_sec_addr (void);
00159   int num_local_sec_addrs (void);
00160 
00161   int set_peer_sec_addr (char** peer_sec_addr, int size);
00162   char** get_peer_sec_addr (void);
00163   int num_peer_sec_addrs (void);
00164 
00165   int set_local_addr (ACE_Addr *local_addr);
00166   ACE_Addr *get_local_addr (void);
00167   char *get_local_addr_str (void);
00168   int set_local_control_addr (ACE_Addr *local_control_addr);
00169   ACE_Addr *get_local_control_addr (void);
00170   char *get_local_control_addr_str (void);
00171 
00172   TAO_AV_Transport *transport (void);
00173   void transport (TAO_AV_Transport *transport);
00174   TAO_AV_Transport *control_transport (void);
00175   void control_transport (TAO_AV_Transport *control_transport);
00176 
00177   TAO_AV_Flow_Handler* handler (void);
00178   void handler (TAO_AV_Flow_Handler *handler);
00179   TAO_AV_Flow_Handler* control_handler (void);
00180   void control_handler (TAO_AV_Flow_Handler *control_handler);
00181 
00182   TAO_AV_Protocol_Object* protocol_object (void);
00183   void protocol_object (TAO_AV_Protocol_Object *object);
00184   TAO_AV_Protocol_Object* control_protocol_object (void);
00185   void control_protocol_object (TAO_AV_Protocol_Object *object);
00186 
00187   /// sets the address for this flow.
00188   int parse_address (const char *format_string,
00189                      TAO_AV_Core::Flow_Component flow_component);
00190 
00191   /// returns true for a multicast address.
00192   int is_multicast (void);
00193 
00194 protected:
00195 
00196   /// parses the flow protocol string with tokens separated by :
00197   int parse_flow_protocol_string (const char *flow_options_string);
00198 
00199   /// sets the direction flag.
00200   int set_direction (const char *direction_string);
00201 
00202   /// sets the protocol_ enum from the carrier_protocol_ string.
00203   int set_protocol (void);
00204 
00205   /// Addr information for the carrier protocol.
00206   ACE_Addr *address_;
00207   int clean_up_address_;         // added to clean up a memory leak
00208   ACE_Addr *control_address_;
00209   int clean_up_control_address_; // added to clean up a memory leak
00210 
00211   /// Fwd Addr in string format i.e hostname:port.
00212   ACE_CString address_str_;
00213 
00214   /// Peer Addr in string format i.e hostname:port.
00215   ACE_CString peer_address_str_;
00216 
00217   /// format string.
00218   ACE_CString format_;
00219 
00220   /// Direction of this flow.
00221   Direction direction_;
00222 
00223   /// string representation of the direction.
00224   ACE_CString direction_str_;
00225 
00226   /// name of this flow.
00227   ACE_CString flowname_;
00228 
00229   /// name of the protocol used.
00230   TAO_AV_Core::Protocol protocol_;
00231 
00232   /// carrier protocol string.
00233   ACE_CString carrier_protocol_;
00234 
00235   /// flow protocol string.
00236   ACE_CString flow_protocol_;
00237 
00238   int use_flow_protocol_;
00239 
00240   /// The flowspec entry;
00241   ACE_CString entry_;
00242 
00243   int is_multicast_;
00244   bool delete_peer_addr_;
00245   ACE_Addr *peer_addr_;
00246   char** local_sec_addr_;
00247   int num_local_sec_addrs_;
00248   char** peer_sec_addr_;
00249   int num_peer_sec_addrs_;
00250   ACE_Addr *peer_control_addr_;
00251   ACE_Addr *local_addr_;
00252   ACE_Addr *local_control_addr_;
00253   TAO_AV_Transport *transport_;
00254   TAO_AV_Transport *control_transport_;
00255   TAO_AV_Flow_Handler *handler_;
00256   TAO_AV_Flow_Handler *control_handler_;
00257   TAO_AV_Protocol_Object *protocol_object_;
00258   TAO_AV_Protocol_Object *control_protocol_object_;
00259   Role role_;
00260 };
00261 
00262 
00263 /**
00264  * @class TAO_Forward_FlowSpec_Entry
00265  */
00266 class TAO_AV_Export TAO_Forward_FlowSpec_Entry
00267   : public TAO_FlowSpec_Entry
00268 {
00269 public:
00270   enum Position {TAO_AV_FLOWNAME = 0,
00271                  TAO_AV_DIRECTION = 1,
00272                  TAO_AV_FORMAT = 2,
00273                  TAO_AV_FLOW_PROTOCOL = 3,
00274                  TAO_AV_ADDRESS = 4,
00275                  TAO_AV_PEER_ADDR = 5};
00276 
00277   /// default constructor.
00278   TAO_Forward_FlowSpec_Entry (void);
00279 
00280   /// constructor to construct an entry from the arguments.
00281   TAO_Forward_FlowSpec_Entry (const char *flowname,
00282                               const char *direction,
00283                               const char *format_name,
00284                               const char *flow_protocol,
00285                               const char *carrier_protocol,
00286                               ACE_Addr *address,
00287                               ACE_Addr *control_address = 0);
00288 
00289   TAO_Forward_FlowSpec_Entry (const char *flowname,
00290                               const char *direction,
00291                               const char *format_name,
00292                               const char *flow_protocol,
00293                               const char *address);
00294 
00295   virtual ~TAO_Forward_FlowSpec_Entry (void);
00296 
00297   /// converts the entry to a string.
00298   virtual const char *entry_to_string (void);
00299 
00300   virtual Role role (void);
00301 
00302   /// construct the entry from a string specified by the flowSpec grammar.
00303   virtual int parse (const char* flowSpec_entry);
00304 };
00305 
00306 /**
00307  * @class TAO_Reverse_FlowSpec_Entry
00308  * @brief
00309  */
00310 class TAO_AV_Export TAO_Reverse_FlowSpec_Entry
00311   :public TAO_FlowSpec_Entry
00312 {
00313 public:
00314   enum Position {TAO_AV_FLOWNAME = 0,
00315                  TAO_AV_ADDRESS = 1,
00316                  TAO_AV_FLOW_PROTOCOL = 2,
00317                  TAO_AV_DIRECTION = 3,
00318                  TAO_AV_FORMAT = 4};
00319 
00320   // default constructor.
00321   TAO_Reverse_FlowSpec_Entry (void);
00322 
00323   // constructor to construct an entry from the arguments.
00324   TAO_Reverse_FlowSpec_Entry (const char *flowname,
00325                               const char *direction,
00326                               const char *format_name,
00327                               const char *flow_protocol,
00328                               const char *carrier_protocol,
00329                               ACE_Addr *address,
00330                               ACE_Addr *control_address = 0);
00331 
00332   // Takes the address in protocol=endpoint form.
00333   TAO_Reverse_FlowSpec_Entry (const char *flowname,
00334                               const char *direction,
00335                               const char *format_name,
00336                               const char *flow_protocol,
00337                               const char *address);
00338 
00339   virtual ~TAO_Reverse_FlowSpec_Entry (void);
00340 
00341   /// converts the entry to a string.
00342   virtual const char *entry_to_string (void);
00343 
00344   virtual Role role (void);
00345 
00346   /// construct the entry from a string specified by the flowSpec grammar.
00347   virtual int parse (const char* flowSpec_entry);
00348 };
00349 
00350 TAO_END_VERSIONED_NAMESPACE_DECL
00351 
00352 #include "orbsvcs/AV/Transport.h"
00353 
00354 #if defined (__ACE_INLINE__)
00355 #include "orbsvcs/AV/FlowSpec_Entry.inl"
00356 #endif /* __ACE_INLINE__ */
00357 
00358 #include /**/ "ace/post.h"
00359 #endif /* TAO_AV_FLOWSPEC_ENTRY_H */

Generated on Tue Feb 2 17:47:49 2010 for TAO_AV by  doxygen 1.4.7