summaryrefslogtreecommitdiff
path: root/TAO/CIAO/tools/Assembly_Deployer/Assembly_Visitors.h
blob: 298455eeddaae493cf10f0175cb0d9c777b59363 (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
// -*- C++ -*-

//=============================================================================
/**
 *  @file    Assembly_Visitors.h
 *
 *  $Id$
 *
 *  This file contains implementations for various visitors that
 *  traverse and process CIAO::Assembly_Spec.
 *
 *  @author Nanbor Wang <nanbor@cs.wustl.edu>
 */
//=============================================================================


#ifndef CIAO_ASSEMBLY_VISITOR_H
#define CIAO_ASSEMBLY_VISITOR_H
#include /**/ "ace/pre.h"

#include "ace/config-all.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "ciao/CCM_DeploymentS.h"
#include "ace/Hash_Map_Manager_T.h"
#include "../XML_Helpers/Assembly_Spec.h"
#include "Deployment_Configuration.h"

namespace CIAO
{
  /**
   * @typedef Assembly_Context
   *
   * This is a structure for collecting information of a running Assembly.
   */
  typedef struct _assembly_context
  {
    typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
                                    Components::CCMHome_var,
                                    ACE_Hash<ACE_CString>,
                                    ACE_Equal_To<ACE_CString>,
                                    ACE_Null_Mutex> HOME_MAP;
    HOME_MAP installed_homes_;

    typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
                                    Components::CCMObject_var,
                                    ACE_Hash<ACE_CString>,
                                    ACE_Equal_To<ACE_CString>,
                                    ACE_Null_Mutex> COMP_MAP;

    typedef COMP_MAP::iterator COMP_MAP_ITER;

    COMP_MAP instantiated_components_;

    typedef ACE_Unbounded_Queue<Components::Deployment::ComponentServer_var> SERVER_QUEUE;
    SERVER_QUEUE component_servers_;
  } Assembly_Context;

  /**
   * @class Assembly_Builder_Visitor
   *
   * @brief A visitor implementation that "build" up the application
   * ACE_Hash_Map_Manager_Exby visiting nodes in an Assembly_Spec
   */
  class Assembly_Builder_Visitor : public CIAO::Assembly_Placement::Visitor
  {
  public:
    /// Constructor
    Assembly_Builder_Visitor (CORBA::ORB_ptr o,
                              Assembly_Context &context,
                              CIAO::ID_IMPL_MAP &idmap,
                              Deployment_Configuration &config);

    /// Destructor
    virtual ~Assembly_Builder_Visitor (void);

    virtual int visit_Container (Assembly_Placement::Container *c
                                 ACE_ENV_ARG_DECL_WITH_DEFAULTS);

    virtual int visit_hostcollocation (Assembly_Placement::hostcollocation *hc
                                       ACE_ENV_ARG_DECL_WITH_DEFAULTS);

    virtual int visit_processcollocation (Assembly_Placement::processcollocation *pc
                                          ACE_ENV_ARG_DECL_WITH_DEFAULTS);

    virtual int visit_homeplacement (Assembly_Placement::homeplacement *hp
                                     ACE_ENV_ARG_DECL_WITH_DEFAULTS);

    virtual int visit_componentinstantiation (Assembly_Placement::componentinstantiation *ci
                                              ACE_ENV_ARG_DECL_WITH_DEFAULTS);

    Components::Deployment::ComponentServer_ptr
    get_current_componentserver (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);

    /// Return a container with the specified @c rtpolicy set name.
    /// This method doesn't necessary create a new container. It
    /// always compare the rtpolicy name of the cached "current
    /// container" and see if the cached container fits our needs.  If
    /// it does, then no new container is created.  I.e., if there are
    /// consecutive homeplacement elements with the same rtpolicy set
    /// name, they will be installed into a single container.
    Components::Deployment::Container_ptr
    get_container (const char *rtpolicy
                   ACE_ENV_ARG_DECL_WITH_DEFAULTS);

  protected:
    /// Registering a component using the info specified in @c i .
    void register_component (Assembly_Placement::componentinstantiation::Register_Info *i,
                             Components::CCMObject_ptr c
                             ACE_ENV_ARG_DECL_WITH_DEFAULTS);

    /// Current Component Server.
    Components::Deployment::ComponentServer_var compserv_;

    /// Current Container.  (This shouldn't be necessary because the
    /// component server supposedly should be able to figure out if a
    /// component home can be installed in the same container based on
    /// its configvalue.  However, our component server don't do that
    /// yet, so we just install all home in a process into one single
    /// container.)
    Components::Deployment::Container_var container_;

    /// The name of the RTPolicy_Set of the active (referenced by @c
    /// container_) container.
    ACE_CString rtpolicy_name_;

    /// Current Component Home.  We only support keyless home
    /// operations for now.
    Components::KeylessCCMHome_var home_;

    /// Keep a pointer to the managing ORB serving this servant.
    CORBA::ORB_var orb_;

    /// Context to build on.
    Assembly_Context &context_;

    /// Context to build on.
    CIAO::ID_IMPL_MAP &impl_idref_map_;

    /// Deployment Configuration Info.
    Deployment_Configuration &deployment_config_;
  };
}

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

#include /**/ "ace/post.h"
#endif /* CIAO_ASSEMBLY_VISITOR_H */