NLMech  0.1.0
policy.h
1 // Copyright (c) 2019 Prashant K. Jha
3 // Copyright (c) 2019 Patrick Diehl
4 //
5 // Distributed under the Boost Software License, Version 1.0. (See accompanying
6 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 
9 #ifndef INP_POLICY_H
10 #define INP_POLICY_H
11 
12 #include <string>
13 #include <vector>
14 
15 // forward declaration of policy deck
16 namespace inp {
17 struct PolicyDeck;
18 }
19 
20 namespace inp {
21 
45 class Policy {
46 
47 public:
48 
55  static Policy *getInstance(inp::PolicyDeck *deck = nullptr);
56 
60  static void destroyInstance();
61 
72  void addToTags(const size_t &level, const std::string &tag);
73 
79  void removeTag(const std::string &tag);
80 
93  bool populateData(const std::string &tag);
94 
100 
105  bool enablePostProcessing();
106 
109 private:
114  explicit Policy(inp::PolicyDeck *deck = nullptr);
115 
117  Policy(Policy const &);
118 
123  const Policy &operator=(const Policy &);
124 
127 
129  void init();
130 
133 
141 
148 
150  std::string d_modelTag;
151 
153  size_t d_maxLevel;
154 
158  std::vector<std::vector<std::string>> d_lTags;
159 };
160 
161 } // namespace inp
162 
163 #endif // IO_POLICY_H
A class to enforce certain policies to reduce memory loads.
Definition: policy.h:45
void addToTags(const size_t &level, const std::string &tag)
Adds tag to specified level tag list.
Definition: policy.cpp:75
void removeTag(const std::string &tag)
Looks for tag in the level d_memControlFlag and if present removes it.
Definition: policy.cpp:80
~Policy()
Private destructor.
int getMemoryControlFlag()
Returns memory control flag.
Definition: policy.cpp:99
bool enablePostProcessing()
Returns true if post-processing computation is to be done.
Definition: policy.cpp:101
const Policy & operator=(const Policy &)
Private copy operator.
Policy(inp::PolicyDeck *deck=nullptr)
Private constructor.
Definition: policy.cpp:35
bool populateData(const std::string &tag)
Returns true/false depending on whether tag is found.
Definition: policy.cpp:90
bool d_enablePostProcessing
Enable post-processing calculation.
Definition: policy.h:147
std::vector< std::vector< std::string > > d_lTags
List of variable names in different levels to help enforce the memory control.
Definition: policy.h:158
int d_memControlFlag
Flag which indicates level of memory control to be enforced.
Definition: policy.h:140
static Policy * getInstance(inp::PolicyDeck *deck=nullptr)
Returns the pointer to static class. Creates instance in its first call.
Definition: policy.cpp:25
std::string d_modelTag
Specify model tag.
Definition: policy.h:150
Policy(Policy const &)
Private operator.
size_t d_maxLevel
Specify maximum level of memory control.
Definition: policy.h:153
static Policy * d_instance_p
Static instance of Policy class.
Definition: policy.h:132
static void destroyInstance()
Destroys the instance.
Definition: policy.cpp:31
void init()
Initializes the data.
Definition: policy.cpp:47
Collection of methods and database related to input.
Definition: main.cpp:21
Structure to read and store policy related input data.
Definition: policyDeck.h:23