Elements 6.1.2
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches
Environment.h
Go to the documentation of this file.
1
27#ifndef ELEMENTSKERNEL_ELEMENTSKERNEL_ENVIRONMENT_H_
28#define ELEMENTSKERNEL_ELEMENTSKERNEL_ENVIRONMENT_H_
29
30#include <functional> // for reference_wrapper
31#include <iostream> // for ostream
32#include <map> // for map
33#include <string> // for string
34#include <vector> // for vector
35
36#include "ElementsKernel/Export.h" // for ELEMENTS_API
37
38namespace Elements {
39
45public:
46 class Variable;
47
48public:
50 explicit Environment(bool keep_same = true);
51 virtual ~Environment();
52
53 Variable operator[](const std::string&);
54 const Variable operator[](const std::string& index) const;
55 Environment& restore();
56 Environment& set(const std::string&, const std::string&);
57 Environment& unSet(const std::string&);
58 Environment& append(const std::string&, const std::string&);
59 Environment& prepend(const std::string&, const std::string&);
60 std::string get(const std::string& index, const std::string& default_value = "") const;
61 static bool hasKey(const std::string&);
62 void commit();
63
64 enum ShellType { sh, csh };
65
66 std::string generateScript(ShellType) const;
67
68private:
73 static void checkOutOfRange(const std::string&);
74
77
79
82};
83
89
90public:
91 Variable() = delete;
93 Variable(const Variable& other);
94 Variable(Variable&& other);
95 Variable& operator=(const Variable& other);
96 Variable& operator=(Variable&& other);
98 Variable& set(const std::string&);
99 Variable& unSet();
100 Variable& append(const std::string&);
104 const std::string& index() const;
105 Environment& env() const;
106 std::string value() const;
108 operator std::string() const;
109 bool empty() const;
110 bool exists() const;
111
112private:
113 void checkCompatibility(const Variable&);
114
117
120};
121
123
125
126} // namespace Elements
127
128#endif // ELEMENTSKERNEL_ELEMENTSKERNEL_ENVIRONMENT_H_
129
defines the macros to be used for explicit export of the symbols
proxy class to overload the assignment
Definition: Environment.h:88
Variable & operator=(const Variable &other)
Definition: Environment.cpp:57
Variable & set(const std::string &)
Definition: Environment.cpp:80
Variable & operator+=(const std::string &)
std::reference_wrapper< Environment > m_env
a copiable and movable reference
Definition: Environment.h:116
Variable & prepend(const std::string &)
std::string m_index
The Name of the variable.
Definition: Environment.h:119
Variable & append(const std::string &)
Definition: Environment.cpp:94
void checkCompatibility(const Variable &)
Variable operator+(const std::string &)
const std::string & index() const
Environment & env() const
Python dictionary-like Environment interface.
Definition: Environment.h:44
std::vector< std::string > m_added_variables
variable added to the environment
Definition: Environment.h:81
std::map< std::string, std::string > m_old_values
old value for changed variables
Definition: Environment.h:76
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
Definition: Export.h:74
ELEMENTS_API Environment::Variable operator+(const std::string &, const Environment::Variable &)
ELEMENTS_API std::ostream & operator<<(std::ostream &, const Environment::Variable &)