summaryrefslogtreecommitdiff
path: root/modules/CIAO/ciao/Deployment/Handlers/CIAO_State.h
blob: 557f827745aaff6958779eb42718ee5b3d7e0b35 (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
/**
 * @file CIAO_State.h
 * @author William R. Otte <wotte@dre.vanderbilt.edu>
 * 
 * $Id$
 */

#ifndef CIAO_STATE_H
#define CIAO_STATE_H

#include <map>
#include <string>

#include "ace/Singleton.h"
#include "ciao/Containers/Container_BaseC.h"
#include "ccm/CCM_HomeC.h"
#include "ccm/CCM_ObjectC.h"
#include "CIAO_Locality_Handler_Export.h"
#include "ciao/Deployment/Handlers/Connection_Handler.h"

namespace CIAO
{
  /**
   * @class Deployment_State
   * @brief Singleton collecting state for the instance handlers.
   *  
   */
  class CIAO_Locality_Handler_Export Deployment_State
  {
  public:
    
    void add_container (const char *id,
                        CIAO::Container_ptr container);
    
    void remove_container (const char *id);
    
    CIAO::Container_ptr fetch_container (const char *id);
    
    const char * instance_to_container (const char *id);

    void add_home (const char *id, const char *container_id,
                   Components::CCMHome_ptr home);
    
    void remove_home (const char *id);
    
    Components::CCMHome_ptr fetch_home (const char *id);
    
    void add_component (const char *id, const char *container_id,
                        Components::CCMObject_ptr component);
    
    void remove_component (const char *id);
    
    Components::CCMObject_ptr fetch_component (const char *id);
    
    Connection_Handler connection_handler;

  private:
    typedef std::map < std::string,
                       CIAO::Container_var > CONTAINERS;
    
    CONTAINERS containers_;
    
    typedef std::map < std::string, std::string > INSTANCE_CONTAINER;
      
    /// maps instance ids to containers.
    INSTANCE_CONTAINER instance_container_;
    
    typedef std::map < std::string,
      Components::CCMHome_var > HOMES;
    
    HOMES homes_;

    typedef std::map < std::string,
      Components::CCMObject_var > COMPONENTS;
    
    COMPONENTS components_;
  };
  
  typedef ACE_Singleton <Deployment_State,
                         ACE_SYNCH_MUTEX> DEPLOYMENT_STATE;

}

CIAO_LOCALITY_HANDLER_SINGLETON_DECLARE (ACE_Singleton,
                                         CIAO::Deployment_State,
                                         ACE_SYNCH_MUTEX);

#endif