summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Naming/Persistent_Context_Index_T.h
blob: b3df8a6bbaee43556ac6fa44985c08af4cd9988d (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
/* -*- C++ -*- */
// $Id$

// ============================================================================
//
// = LIBRARY
//    cos
//
// = FILENAME
//    Persistent_Context_Index_T.h
//
// = AUTHOR
//    Marina Spivak <marina@cs.wustl.edu>
//
// ============================================================================

#ifndef TAO_PERSISTENT_CONTEXT_INDEX_T_H
#define TAO_PERSISTENT_CONTEXT_INDEX_T_H

#include "Persistent_Context_Index.h"

template <ACE_MEM_POOL_1, class ACE_LOCK>
class TAO_Persistent_Context_Index : public TAO_Index
{
  // = TITLE
  //
  //
  // = DESCRIPTION
  //   ACE_LOCK should either be ACE_Null_Mutex or ACE_Thread_Mutex.
  //   ACE_MEM_POOL_1 for now is ACE_MMAP_Memory_Pool, later may make
  //   sense with other pools.
public:
  // = Initialization and termination methods.
  TAO_Persistent_Context_Index (CORBA::ORB_ptr orb,
                                PortableServer::POA_ptr poa);
  // "Do-nothing" constructor.

  int open (LPCTSTR file_name,
            void * base_address = ACE_DEFAULT_BASE_ADDR);
  //

  int init (void);
  // go through the index of contexts and create a servant of each,
  // and register it with POA.  If no contexts are present, create one.

  ~TAO_Persistent_Context_Index (void);
  // destructor, do some cleanup :TBD: last dtor should "compress"
  // file

  virtual int bind (const char *poa_id,
                    ACE_UINT32 *&counter,
                    CONTEXT *hash_map);
  // Create an entry - new context is created.

  virtual int unbind (const char * poa_id);
  // Unbind an entry - a context is destroyed.

  virtual ACE_Allocator *allocator (void);
  // accessor.

  virtual CORBA::ORB_ptr orb (void);
  //

  char * root_ior (void);
  //

  typedef ACE_Allocator_Adapter <ACE_Malloc <ACE_MEM_POOL_2, ACE_LOCK>
  > ALLOCATOR;

private:

  int recreate_all (void);
  //

  int create_index (void);
  // Allocate the appropriate type of map manager that stores the
  // key/value binding.

  ACE_LOCK *lock_;
  // Lock to prevent multiple threads from modifying entries in the
  // hash map simultanneously.

  ALLOCATOR *allocator_;
  // Pointer to the allocator

  INDEX *index_;
  // Pointer to the allocated map manager.

  LPCTSTR index_file_;
  // Name of the file used for storage.

  void *base_address_;

  CORBA::ORB_var orb_;
  //

  PortableServer::POA_var poa_;
  //

  CORBA::String_var root_ior_;
  //
};

#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "Persistent_Context_Index_T.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */

#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("Persistent_Context_Index_T.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */

#endif /* TAO_PERSISTENT_CONTEXT_INDEX_T_H */