GAMS  1.4.0
Containerize.h
Go to the documentation of this file.
1 
54 #ifndef _GAMS_UTILITY_CONTAINERIZE_H_
55 #define _GAMS_UTILITY_CONTAINERIZE_H_
56 
57 #include "gams/GamsExport.h"
58 
59 #include <string>
60 
61 #include "madara/knowledge/KnowledgeBase.h"
62 
63 namespace gams
64 {
65  namespace utility
66  {
72  {
73  public:
77  Containerize(const std::string& n = "");
78 
82  virtual ~Containerize();
83 
88  std::string get_name() const;
89 
94  void set_name(const std::string& n);
95 
99  void set_knowledge_base(madara::knowledge::KnowledgeBase* kb);
100 
105  void modify();
106 
111  void to_container(const std::string& name = "");
112 
118  void to_container(madara::knowledge::KnowledgeBase& kb,
119  const std::string& name = "");
120 
126  bool from_container(const std::string& name = "");
127 
135  madara::knowledge::KnowledgeBase& kb,
136  const std::string& name = "");
137 
138  protected:
140  const static std::string object_type_suffix_;
141 
143  std::string name_;
144 
146  madara::knowledge::KnowledgeBase* prev_kb_;
147 
154  enum Class_ID
155  {
156  REGION_TYPE_ID = 0x00000001,
157  PRIORITIZED_REGION_TYPE_ID = 0x00000002,
158  SEARCH_AREA_TYPE_ID = 0x00000004,
159  INVALID = 0x80000000,
160  };
161 
169  bool is_valid_type(madara::knowledge::KnowledgeBase& kb,
170  const std::string& name, const Class_ID& expected) const;
171 
178  static Class_ID get_type(madara::knowledge::KnowledgeBase& kb,
179  const std::string& name);
180 
181  private:
188  virtual bool check_valid_type(
189  madara::knowledge::KnowledgeBase& kb,
190  const std::string& name) const = 0;
191 
197  virtual void to_container_impl(
198  madara::knowledge::KnowledgeBase& kb,
199  const std::string& name) = 0;
200 
206  virtual bool from_container_impl(
207  madara::knowledge::KnowledgeBase& kb,
208  const std::string& name) = 0;
209  };
210  }
211 }
212 
213 #endif // _GAMS_UTILITY_CONTAINERIZE_H_
#define GAMS_EXPORT
Definition: GamsExport.h:20
A class meant to assist with retrieving information into GAMS containers.
Definition: Containerize.h:72
std::string name_
name of this object
Definition: Containerize.h:143
void set_knowledge_base(madara::knowledge::KnowledgeBase *kb)
Set knowledge base to use.
virtual bool check_valid_type(madara::knowledge::KnowledgeBase &kb, const std::string &name) const =0
Check if object is of correct type.
Containerize(const std::string &n="")
Constructor.
bool from_container(const std::string &name="")
Load object from knowledge base.
virtual bool from_container_impl(madara::knowledge::KnowledgeBase &kb, const std::string &name)=0
Load object from knowledge base.
virtual ~Containerize()
Destructor.
std::string get_name() const
Get name of the object.
void set_name(const std::string &n)
Set name of the object.
madara::knowledge::KnowledgeBase * prev_kb_
previous knowledge base used for sending objects
Definition: Containerize.h:146
bool from_container(madara::knowledge::KnowledgeBase &kb, const std::string &name="")
Load object from knowledge base.
void to_container(madara::knowledge::KnowledgeBase &kb, const std::string &name="")
Store object in knowledge base.
virtual void to_container_impl(madara::knowledge::KnowledgeBase &kb, const std::string &name)=0
Store object in knowledge base.
void modify()
Resend the information in the container using same knowledge base as previous to_container.
static Class_ID get_type(madara::knowledge::KnowledgeBase &kb, const std::string &name)
Gets type of object in database.
Class_ID
These are used to check on the type of the object in from_container.
Definition: Containerize.h:155
static const std::string object_type_suffix_
object type suffix
Definition: Containerize.h:140
void to_container(const std::string &name="")
Store object in knowledge base used previously.
bool is_valid_type(madara::knowledge::KnowledgeBase &kb, const std::string &name, const Class_ID &expected) const
Check if the type is correct.
Contains all GAMS-related tools, classes and code.