Elements 6.3.1
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() = default;
96 Variable& operator=(const Variable& other);
97 Variable& operator=(Variable&& other);
99 Variable& set(const std::string&);
100 Variable& unSet();
101 Variable& append(const std::string&);
105 const std::string& index() const;
106 Environment& env() const;
107 std::string value() const;
109 operator std::string() const;
110 bool empty() const;
111 bool exists() const;
112
113private:
114 void checkCompatibility(const Variable&);
115
118
121};
122
124
126
127} // namespace Elements
128
129#endif // ELEMENTSKERNEL_ELEMENTSKERNEL_ENVIRONMENT_H_
130
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)
Variable & set(const std::string &)
Variable & operator+=(const std::string &)
std::reference_wrapper< Environment > m_env
a copiable and movable reference
Variable & prepend(const std::string &)
std::string m_index
The Name of the variable.
Variable & append(const std::string &)
void checkCompatibility(const Variable &)
Variable operator+(const std::string &)
const std::string & index() 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 &)