summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/AV/FlowSpec_Entry.h
blob: 3ecff97e0e036ef4d972e22c694d1aa4595da212 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/* -*- C++ -*- */

//$Id$

// ============================================================================
//
// = LIBRARY
//   ORBSVCS (AVStreams)
//
// = FILENAME
//   FlowSpec_Entry.h
//
// = AUTHOR
//    Nagarajan Surendran <naga@cs.wustl.edu>
//
//
// ============================================================================

#ifndef TAO_AV_FLOWSPEC_ENTRY_H
#define TAO_AV_FLOWSPEC_ENTRY_H

#include "orbsvcs/orbsvcs_export.h"
#include "AV_Core.h"
#include "ace/Addr.h"

class TAO_ORBSVCS_Export TAO_Tokenizer
{
public:
  TAO_Tokenizer (const char *string,char delimiter);
  // constructor.

  ~TAO_Tokenizer ();
  // destructor.

  int parse (const char *string,char delimiter);
  // parses the string and tokenizes it.

  char *token (void);
  // Returns the next token.

  int num_tokens (void);
  // Number of tokens.

  char *operator [] (size_t index) const;

protected:
  ACE_Array<char*> token_array_;
  size_t count_;
  size_t num_tokens_;
  char string_ [BUFSIZ];
};

// Forward declaration.
class TAO_AV_Transport;
class TAO_AV_Flow_Handler;
class TAO_AV_Protocol_Object;

class TAO_ORBSVCS_Export TAO_FlowSpec_Entry
{
public:
  // = TITLE
  //     An helper entry class in the flow spec sequence passed to bind_devs.
  enum Direction
  {
    TAO_AV_INVALID   = -1,
    TAO_AV_DIR_IN    =  0,
    TAO_AV_DIR_OUT   =  1
  };

  enum Role
  {
    TAO_AV_INVALID_ROLE = -1,
    TAO_AV_PRODUCER = 0,
    TAO_AV_CONSUMER = 1
  };

  TAO_FlowSpec_Entry (void);
  // default constructor.

  TAO_FlowSpec_Entry (const char *flowname,
                      const char *direction,
                      const char *format_name,
                      const char *flow_protocol,
                      const char *carrier_protocol,
                      ACE_Addr *address);
  // constructor to construct an entry from the arguments.

  TAO_FlowSpec_Entry (const char *flowname,
                      const char *direction,
                      const char *format_name,
                      const char *flow_protocol,
                      const char *address);

  virtual int parse (const char* flowSpec_entry) = 0;
  // construct the entry from a string specified by the flowSpec grammar.

  virtual ~TAO_FlowSpec_Entry (void);
  // virtual destructor.

  int direction (void);
  // accessor to the direction.

  virtual Role role (void) = 0;
  char * direction_str (void);
  // string version of direction .

  char *flow_protocol_str (void);
  // accesor to the flow protocol string.

  ACE_Addr *address (void);
  // Address of the carrier protocol.

  char * address_str (void);
  // Address in string format i. hostname:port.

  TAO_AV_Core::Protocol carrier_protocol (void);
  // carrier protocol i.e TCP,UDP,RTP/UDP.

  char * carrier_protocol_str (void);
  // string version of carrier protocol.

  char *format (void);
  // format to be used for this flow.

  const char *flowname (void);
  // name of this flow.

  virtual char *entry_to_string (void) = 0;
  // converts the entry to a string.

  int set_peer_addr (ACE_Addr *peer_addr);
  ACE_Addr *get_peer_addr (void);
  int set_local_addr (ACE_Addr *peer_addr);
  ACE_Addr *get_local_addr (void);
  char *get_local_addr_str (void);
  TAO_AV_Transport *transport (void);
  void transport (TAO_AV_Transport *transport);
  TAO_AV_Flow_Handler* handler (void);
  void handler (TAO_AV_Flow_Handler *handler);
  TAO_AV_Protocol_Object* protocol_object (void);
  void protocol_object (TAO_AV_Protocol_Object *object);

  int parse_address (char *format_string);
  // sets the address for this flow.

  int is_multicast (void);
  // returns true for a multicast address.

protected:

  int parse_flow_protocol_string (char *flow_options_string);
  // parses the flow protocol string with tokens separated by :

  int set_direction (char *direction_string);
  // sets the direction flag.


  int set_protocol (void);
  // sets the protocol_ enum from the carrier_protocol_ string.

  ACE_Addr *address_;
  // Addr information for the carrier protocol.

  char *address_str_;
  // Addr in string format i.e hostname:port.

  char *format_;
  // format string.

  Direction direction_;
  // Direction of this flow.

  char *direction_str_;
  // string representation of the direction.

  char *flowname_;
  // name of this flow.

  TAO_AV_Core::Protocol protocol_;
  // name of the protocol used.

  char *carrier_protocol_;
  // carrier protocol string.

  char *flow_protocol_;
  // flow protocol string.

  int use_flow_protocol_;
  char *entry_;
  // The flowspec entry;

  int is_multicast_;
  ACE_Addr *peer_addr_;
  ACE_Addr *local_addr_;
  TAO_AV_Transport *transport_;
  TAO_AV_Flow_Handler *handler_;
  TAO_AV_Protocol_Object *protocol_object_;
};

class TAO_ORBSVCS_Export TAO_Forward_FlowSpec_Entry
  :public TAO_FlowSpec_Entry
{
public:
  enum Position {TAO_AV_FLOWNAME = 0,
                 TAO_AV_DIRECTION = 1,
                 TAO_AV_FORMAT = 2,
                 TAO_AV_FLOW_PROTOCOL = 3,
                 TAO_AV_ADDRESS = 4};

  TAO_Forward_FlowSpec_Entry (void);
  // default constructor.

  TAO_Forward_FlowSpec_Entry (const char *flowname,
                              const char *direction,
                              const char *format_name,
                              const char *flow_protocol,
                              const char *carrier_protocol,
                              ACE_Addr *address);
  // constructor to construct an entry from the arguments.

  TAO_Forward_FlowSpec_Entry (const char *flowname,
                              const char *direction,
                              const char *format_name,
                              const char *flow_protocol,
                              const char *address);

  virtual char *entry_to_string (void);
  // converts the entry to a string.

  virtual Role role (void);
  virtual int parse (const char* flowSpec_entry);
  // construct the entry from a string specified by the flowSpec grammar.
};

class TAO_ORBSVCS_Export TAO_Reverse_FlowSpec_Entry
  :public TAO_FlowSpec_Entry
{
public:
  enum Position {TAO_AV_FLOWNAME = 0,
                 TAO_AV_ADDRESS = 1,
                 TAO_AV_FLOW_PROTOCOL = 2,
                 TAO_AV_DIRECTION = 3,
                 TAO_AV_FORMAT = 4};

  TAO_Reverse_FlowSpec_Entry (void);
  // default constructor.

  TAO_Reverse_FlowSpec_Entry (const char *flowname,
                              const char *direction,
                              const char *format_name,
                              const char *flow_protocol,
                              const char *carrier_protocol,
                              ACE_Addr *address);
  // constructor to construct an entry from the arguments.

  TAO_Reverse_FlowSpec_Entry (const char *flowname,
                              const char *direction,
                              const char *format_name,
                              const char *flow_protocol,
                              const char *address);
  // Takes the address in protocol=endpoint form.

  virtual char *entry_to_string (void);
  // converts the entry to a string.

  virtual Role role (void);
  virtual int parse (const char* flowSpec_entry);
  // construct the entry from a string specified by the flowSpec grammar.
};

#include "Transport.h"

#if defined (__ACE_INLINE__)
#include "FlowSpec_Entry.i"
#endif /* __ACE_INLINE__ */

#endif /* TAO_AV_FLOWSPEC_ENTRY_H */