summaryrefslogtreecommitdiff
path: root/TAO/CIAO/tools/XML_Helpers/Assembly_Spec.h
blob: ea46579c43c80f2d836f9563a68aa653cfdb417e (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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
// $Id$

//=============================================================================
/**
 *  @file Assembly_Spec.h
 *
 *  $Id$
 *
 *  @author Nanbor Wang <nanbor@cs.wustl.edu>
 */
//=============================================================================

#ifndef CIAO_ASSEMBLY_SPEC_H
#define CIAO_ASSEMBLY_SPEC_H

#include "ace/Hash_Map_Manager_T.h"
#include "ace/Containers_T.h"
#include "ace/SString.h"
#include "ace/CORBA_macros.h"
#include "ace/Null_Mutex.h"
#include "tao/Environment.h"
#include "XML_Helpers_Export.h"

namespace CIAO
{
  /**
   * @typedef ID_IMPL_MAP
   *
   * A hash map type for indexing implmentation IDs to corresponding
   * softpkg paths.
   */
  typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
                                  ACE_CString,
                                  ACE_Hash<ACE_CString>,
                                  ACE_Equal_To<ACE_CString>,
                                  ACE_Null_Mutex> ID_IMPL_MAP;

  namespace Assembly_Placement
  {
    /**
     * @enum Node Type
     */
    typedef enum _nodetype
    {
      INVALID_NODE,
      INVALID_CONTAINER,
      HOST,
      PROCESS,
      HOME,
      COMPONENT
    } Node_Type;

    // Forward declaration.
    class Visitor;

    /**
     * @class Node
     *
     * Abstract base class for placement information
     */
    class CIAO_XML_HELPERS_Export Node
    {
    public:
      /// Default constructor.
      Node (const char *id = 0);

      /// Accepting a visitor.
      virtual int accept (Visitor &v
                          ACE_ENV_ARG_DECL_WITH_DEFAULTS);

      virtual ~Node ();

      void usagename (const char *un);
      const char *usagename (void) const;

      const char *id (void) const;

      /// Double linked list required internal data
      Node *prev_;
      Node *next_;

    protected:
      /// Node ID.
      ACE_CString id_;

      /// Usage information.
      ACE_CString usagename_;
    };

    /**
     * @class Container
     *
     * Abstract base class for container type placement node
     */
    class CIAO_XML_HELPERS_Export Container
      : public Node,
        public ACE_Double_Linked_List<Node>
    {
    public:
      Container (const char *id,
                 unsigned long cardinality);

      /// Accepting a visitor.
      virtual int accept (Visitor &v
                          ACE_ENV_ARG_DECL_WITH_DEFAULTS);

      //@{
      /** Accesor/mutator for destination information */
      void destination (const char *des);
      const char *destination (void) const;

      unsigned long cardinality (void) const;
      //@}

    protected:
      /// A corbaloc string pointing to a CIAO_Daemon interface.
      ACE_CString destination_;

      // cardinality
      unsigned long cardinality_;
    };

    /**
     * @class componentinstantiation
     */
    class CIAO_XML_HELPERS_Export componentinstantiation
      : public Node
    {
    public:
      typedef enum _if_register_type
        {
          COMPONENT,
          PROVIDESID,
          CONSUMESID
        } IF_Register_Type;

      typedef enum _register_method
        {
          NAMINGSERVICE,
          IORFILE               // CIAO extension
        } Register_Method;

      typedef struct _register_info
      {
        IF_Register_Type type_;
        Register_Method method_;

        ACE_CString port_id_;
        ACE_CString name_;

        void reset ()
        {
          type_ = COMPONENT;
          port_id_.clear ();
          name_.clear ();
        }
      } Register_Info;

      componentinstantiation (const char *id);


      /// Accepting a visitor.
      virtual int accept (Visitor &v
                          ACE_ENV_ARG_DECL_WITH_DEFAULTS);

      virtual ~componentinstantiation ();

      typedef ACE_Unbounded_Queue <Register_Info> REGISTRATION_QUEUE;
      REGISTRATION_QUEUE register_info_;

    protected:
    };

    /**
     * @class homeplacement
     */
    class CIAO_XML_HELPERS_Export homeplacement
      : public Container
    {
    public:
      typedef enum _register_method
        {
          HOMEFINDER,
          NAMING,
          TRADER                // No implementation for trader yet.
        } Register_Method;

      typedef struct _register_info
      {
        /// Register_Method
        Register_Method type_;

        /// Name to be registered with the finder/namingservice
        ACE_CString name_;
      } Register_Info;

      homeplacement (const char *id,
                     unsigned long cardinality = 1);
      /// Accepting a visitor.
      virtual int accept (Visitor &v
                          ACE_ENV_ARG_DECL_WITH_DEFAULTS);

      virtual ~homeplacement ();

      //@{
      /** Accessor/mutator functions  */
      void componentfileref (const char *file);
      const char *componentfileref (void) const;
      void rtpolicyset_ref (const char *file);
      const char *rtpolicyset_ref (void) const;
      //@}

      ACE_Unbounded_Queue <Register_Info> register_info_;

    protected:
      // idref to component implementation file.
      ACE_CString componentfileref_;

      // idref to the name of RTPolicySet
      ACE_CString rtpolicyset_ref_;
    };

    /**
     * @class hostcollocation
     */
    class CIAO_XML_HELPERS_Export hostcollocation
      : public Container
    {
    public:
      hostcollocation (const char *id,
                       unsigned long cardinality = 1);

      /// Accepting a visitor.
      virtual int accept (Visitor &v
                          ACE_ENV_ARG_DECL_WITH_DEFAULTS);

      virtual ~hostcollocation ();

    protected:
    };

    /**
     * @class processcollocation
     */
    class CIAO_XML_HELPERS_Export processcollocation
      : public Container
    {
    public:
      processcollocation (const char *id,
                          unsigned long cardinality = 1);

      /// Accepting a visitor.
      virtual int accept (Visitor &v
                          ACE_ENV_ARG_DECL_WITH_DEFAULTS);

      virtual ~processcollocation ();

      //@{
      /** Accessor/mutator functions  */
      void rtcad_filename (const char *file);
      const char *rtcad_filename (void) const;
      //@}

    protected:
      /**
       * Filename of CIAO's RT cad extension descriptors.  We are
       * deferring the parsing of this file until deployment time.
       * Why?  Because we want to separate the handling of the
       * extension file from the "standard" feature.  This filename is
       * specified in the <extension> tag.
       */
      ACE_CString rtcad_filename_;
    };

    /**
     * @class Placement_Visitor
     *
     * Abstract Base class for placement node visitor.
     */
    class CIAO_XML_HELPERS_Export Visitor
    {
    public:
      Visitor ();

      virtual ~Visitor () = 0;

      virtual int visit_Container (Container *c
                                   ACE_ENV_ARG_DECL_WITH_DEFAULTS) = 0;

      virtual int visit_hostcollocation (hostcollocation *hc
                                         ACE_ENV_ARG_DECL_WITH_DEFAULTS) = 0;

      virtual int visit_processcollocation (processcollocation *pc
                                            ACE_ENV_ARG_DECL_WITH_DEFAULTS) = 0;

      virtual int visit_homeplacement (homeplacement *hp
                                       ACE_ENV_ARG_DECL_WITH_DEFAULTS) = 0;

      virtual int visit_componentinstantiation (componentinstantiation *ci
                                                ACE_ENV_ARG_DECL_WITH_DEFAULTS) = 0;

    protected:
    };
  }

  namespace Assembly_Connection
  {
    /**
     *
     */
    typedef enum _if_resolution
      {
        PROVIDER,               // Requires a component ref. (compound)
        CONSUMER,               // Requires a component ref. (compound)
        COMP_IDREF,             // Requires an idref
        HOME_IDREF,             // Requires an idref
        NAMINGSERVICE,          // Requires a name
        STRINGIFIEDOBJECTREF,   // Requires an IOR
        HOMEFINDER,             // Requries a name (similar to naming)
        TRADERQUERY             // Require trader query structure.  No support for now.
      } IF_Resolution_Method;

    typedef enum _conxion_type
      {
        INTERFACE,
        EMITTER_CONSUMER,
        PUBLISHER_CONSUMER,
        HOME,
        INVALID_CONN
      } Connection_Type;

    class CIAO_XML_HELPERS_Export IF_Resolver_Info
    {
    public:
      IF_Resolver_Info (IF_Resolution_Method type,
                        const char *info,
                        IF_Resolver_Info *nested = 0);

      ~IF_Resolver_Info ();

      IF_Resolution_Method resolver_type (void) const;

      /// The string we use to resolve the interface.
      const char *resolver_info (void) const;

      /// Return a nested resolver this resolver depends on.
      IF_Resolver_Info *nested_resolver (void);

      /// Return the trader structure.  (Not implemented yet.
      /// therefore, we are returning void * for now.)
      void *traderquery (void) const;

    protected:
      /// Hints the kind of resolve info.
      IF_Resolution_Method resolver_type_;

      /// Information this info contains
      ACE_CString resolver_info_;

      /// Dependent resolver info.
      IF_Resolver_Info *nested_resolver_;

      /// @@@ Future placeholder for trader query info.
      void *traderquery_;
    };

    /**
     *
     */
    typedef struct CIAO_XML_HELPERS_Export _CII
    {
      _CII ();

      ~_CII ();

      // The kind of connection this info describes.
      Connection_Type type_;

      /// The id of the connection.
      ACE_CString id_;

      /// The name of the receptacle or consumer.
      ACE_CString name_;

      /// The component that uses the receptacle or consumes the event.
      IF_Resolver_Info *component_;

      /// The interface that is to be connected to the port.
      IF_Resolver_Info *interface_;

    } Connect_Info;
  }

  /**
   *
   */
  typedef struct CIAO_XML_HELPERS_Export _ASpec
  {
    _ASpec ();

    /// ID to implementation map.
    ID_IMPL_MAP componentfiles_;

    /// Partitioning data
    Assembly_Placement::Container partitioning_;

    /// Connection data
    typedef ACE_Unbounded_Queue<Assembly_Connection::Connect_Info> CONNECTION_QUEUE;
    CONNECTION_QUEUE connections_;
  } Assembly_Spec;
}

#if defined (__ACE_INLINE__)
# include "Assembly_Spec.inl"
#endif /* __ACE_INLINE__ */
#endif /* CIAO_ASSEMBLY_SPEC_H */