My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
ArrayMapBase.h
Go to the documentation of this file.
1 #ifndef GCP_UTIL_ARRAYMAPBASE_H
2 #define GCP_UTIL_ARRAYMAPBASE_H
3 
11 #include "gcp/control/code/unix/libunix_src/common/genericregs.h"
12 
13 namespace gcp {
14  namespace util {
15 
16  //------------------------------------------------------------
17  // A class to manage an arraymap pointer
18  //------------------------------------------------------------
19 
20  class ArrayMapPtr {
21  public:
22 
23  ArrayMap* arrayMap_;
24 
25  ArrayMapPtr() {
26  arrayMap_ = 0;
27  }
28 
29  ~ArrayMapPtr() {
30  if(arrayMap_) {
31  arrayMap_ = del_ArrayMap(arrayMap_);
32  }
33  }
34 
35  void allocateArrayMap() {
36  arrayMap_ = new_ArrayMap();
37  }
38 
39  };
40 
41  // An object which any class needing a copy of the GCP Array map
42  // should instantiate. This class manages a single static copy of
43  // the GCP array map, which is allocated on the first construction
44  // of this class, and deleted only when the last reference to any
45  // such object is deleted.
46 
47  class ArrayMapBase {
48  public:
49 
53  ArrayMapBase();
54 
58  ArrayMapBase(ArrayMapBase& arrayMap);
59  ArrayMapBase(const ArrayMapBase& arrayMap);
60  void operator=(const ArrayMapBase& arrayMap);
61  void operator=(ArrayMapBase& arrayMap);
62 
63  // Destructor.
64 
65  virtual ~ArrayMapBase();
66 
67  // Get a reference to the array map
68 
69  inline ArrayMap* arrayMap() {
70  return arrayMapPtr_.arrayMap_;
71  }
72 
73  public:
74 
75  // The underlying singleton array map
76 
77  static ArrayMapPtr arrayMapPtr_;
78 
79  }; // End class ArrayMapBase
80 
81  } // End namespace util
82 } // End namespace gcp
83 
84 
85 
86 #endif // End #ifndef GCP_UTIL_ARRAYMAPBASE_H
ArrayMapBase()
Definition: ArrayMapBase.cc:13
Definition: ArrayMapBase.h:20
virtual ~ArrayMapBase()
Definition: ArrayMapBase.cc:23
Definition: ArrayMapBase.h:47
Definition: arraymap.h:177