summaryrefslogtreecommitdiff
path: root/TAO/CIAO/tools/Assembly_Deployer/Assembly_Visitors.h
blob: fa3f5072cab6a2e993c11fa06837b3d57020db7a (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
// -*- 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 "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;
    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::Container_ptr
    get_current_container (void);

  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_;

    /// 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 */