neic-glass3  1.4.6
baseclass.h
Go to the documentation of this file.
1 /*****************************************
2  * This file is documented for Doxygen.
3  * If you modify this file please update
4  * the comments so that Doxygen will still
5  * be able to work.
6  ****************************************/
7 #ifndef BASECLASS_H
8 #define BASECLASS_H
9 
10 #include <json.h>
11 #include <mutex>
12 #include <atomic>
13 #include <memory>
14 #include <string>
15 
16 namespace glass3 {
17 namespace util {
30 class BaseClass {
31  public:
38  BaseClass();
39 
45  virtual ~BaseClass();
46 
58  virtual bool setup(std::shared_ptr<const json::Object> config);
59 
69  virtual void clear();
70 
71  /* \brief Retrieves a pointer to the class member json::Object that holds
72  * the configuration.
73  *
74  * \return returns a share_ptr to a json::Object containing the configuration
75  */
76  const std::shared_ptr<const json::Object> getConfig();
77 
82  bool getSetup();
83 
92  const std::string& getDefaultAgencyId();
93 
102  void setDefaultAgencyId(const std::string &id);
103 
112  const std::string& getDefaultAuthor();
113 
122  void setDefaultAuthor(const std::string &author);
123 
124  protected:
128  std::shared_ptr<const json::Object> m_Config;
129 
134  std::atomic<bool> m_bIsSetup;
135 
140  std::string m_DefaultAgencyID;
141 
146  std::string m_DefaultAuthor;
147 
148  private:
153  std::mutex & getMutex();
154 
158  std::mutex m_Mutex;
159 };
160 } // namespace util
161 } // namespace glass3
162 #endif // BASECLASS_H
virtual ~BaseClass()
BaseClass destructor.
Definition: baseclass.cpp:17
const std::string & getDefaultAuthor()
Function to retrieve the name of the default author.
Definition: baseclass.cpp:77
std::shared_ptr< const json::Object > m_Config
A shared pointer to the json::Object that holds the configuration.
Definition: baseclass.h:128
The neic-glass3 project namespace containing all the classes and functions that make up neic-glass3...
glass3::util::BaseClass class - encapsulates the most basic setup and configuration logic...
Definition: baseclass.h:30
std::string m_DefaultAgencyID
A std::string containing the default agency id to use in parsing if one is not provided.
Definition: baseclass.h:140
void setDefaultAgencyId(const std::string &id)
Function to set the name of the default agency id.
Definition: baseclass.cpp:71
virtual bool setup(std::shared_ptr< const json::Object > config)
BaseClass configuration function.
Definition: baseclass.cpp:21
const std::shared_ptr< const json::Object > getConfig()
Definition: baseclass.cpp:49
std::atomic< bool > m_bIsSetup
the boolean flag indicating whether the class has been setup, set to true if setup was successful...
Definition: baseclass.h:134
void setDefaultAuthor(const std::string &author)
Function to set the name of the default author.
Definition: baseclass.cpp:83
std::string m_DefaultAuthor
A std::string containing the default author to use in parsing if one is not provided.
Definition: baseclass.h:146
BaseClass()
BaseClass constructor.
Definition: baseclass.cpp:12
const std::string & getDefaultAgencyId()
Function to retrieve the name of the default agency id.
Definition: baseclass.cpp:65
bool getSetup()
Retrieves the class member boolean flag indicating whether the class has been setup, set to true if setup was successful.
Definition: baseclass.cpp:55
virtual void clear()
BaseClass clear function.
Definition: baseclass.cpp:37