CUBRID Engine  latest
load_class_registry.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 /*
20  * load_class_registry.hpp - class registry for server loaddb
21  */
22 
23 #ifndef _LOAD_CLASS_REGISTRY_HPP_
24 #define _LOAD_CLASS_REGISTRY_HPP_
25 
26 #include "load_common.hpp"
28 #include "storage_common.h"
29 
30 #include <mutex>
31 #include <unordered_map>
32 #include <vector>
33 
34 namespace cubload
35 {
36 
37  class attribute
38  {
39  public:
40  attribute () = delete; // Not DefaultConstructible
41  attribute (const std::string &name, std::size_t index, or_attribute *repr);
42 
43  attribute (attribute &&other) = delete; // Not MoveConstructible
44  attribute (const attribute &copy) = delete; // Not CopyConstructible
45 
46  attribute &operator= (attribute &&other) = delete; // Not MoveAssignable
47  attribute &operator= (const attribute &copy) = delete; // Not CopyAssignable
48 
49  const char *get_name () const;
50  std::size_t get_index () const;
51  const or_attribute &get_repr () const;
52  const tp_domain &get_domain () const;
53 
54  private:
55  const std::string m_name;
56  const std::size_t m_index;
58  };
59 
61  {
62  public:
63  class_entry () = delete; // Not DefaultConstructible
64  class_entry (std::string &class_name, OID &class_oid, class_id clsid, std::vector<const attribute *> &attributes);
65  class_entry (std::string &class_name, class_id clsid, bool is_ignored);
66  ~class_entry ();
67 
68  class_entry (class_entry &&other) = delete; // Not MoveConstructible
69  class_entry (const class_entry &copy) = delete; // Not CopyConstructible
70  class_entry &operator= (class_entry &&other) = delete; // Not MoveAssignable
71  class_entry &operator= (const class_entry &copy) = delete; // Not CopyAssignable
72 
73  const OID &get_class_oid () const;
74  const char *get_class_name () const;
75  const attribute &get_attribute (std::size_t index) const;
76  size_t get_attributes_size () const;
77  bool is_ignored () const;
78 
79  private:
82  std::string m_class_name;
83  std::vector<const attribute *> m_attributes;
84  const bool m_is_ignored;
85  };
86 
88  {
89  public:
90  class_registry ();
91  ~class_registry ();
92 
93  class_registry (class_registry &&other) = delete; // Not MoveConstructible
94  class_registry (const class_registry &copy) = delete; // Not CopyConstructible
95 
96  class_registry &operator= (class_registry &&other) = delete; // Not MoveAssignable
97  class_registry &operator= (const class_registry &copy) = delete; // Not CopyAssignable
98 
99  const class_entry *get_class_entry (class_id clsid);
100  void get_all_class_entries (std::vector<const class_entry *> &entries) const;
101  void register_class (const char *class_name, class_id clsid, OID class_oid,
102  std::vector<const attribute *> &attributes);
103  void register_ignored_class (class_entry *cls_entry, class_id cls_id);
104 
105  private:
106  using class_map = std::map<class_id, const class_entry *, std::greater<class_id>>;
107 
110 
111  const class_entry *get_class_entry_without_lock (class_id clsid) ;
112  };
113 
114 } // namespace cubload
115 
116 #endif /* _LOAD_CLASS_REGISTRY_HPP_ */
std::map< class_id, const class_entry *, std::greater< class_id >> class_map
static API_MUTEX mutex
Definition: api_util.c:72
const tp_domain & get_domain() const
OID m_class_oid
const std::string m_name
std::size_t get_index() const
class_id m_clsid
std::string m_class_name
const char * get_name() const
const std::size_t m_index
attribute & operator=(attribute &&other)=delete
std::vector< const attribute * > m_attributes
const bool m_is_ignored
const or_attribute & get_repr() const
const or_attribute * m_repr
int class_id
Definition: load_common.hpp:40