8#include "Arp/System/Core/AppDomainSingleton.hxx"
9#include "Arp/System/Core/Endianness.hpp"
16namespace Arp {
namespace System {
namespace Commons
22 static const char* ArpBinaryDirVariableName;
25 static void Setup(
void);
26 static void SetupSettings(
int core);
27 static void SetupSecuritySettings(
const String& securitySettingsPath);
28 static void SetupTrustStore(
const std::vector<String>& trustStorePaths,
const String& trustStoreEditPath);
29 static void SetupIdentityStore(
const std::vector<String>& identityStorePaths,
const String& identityStoreEditPath);
30 static void Dispose(
void);
33 static int64 GetTickCount(
void);
35 static String GetVariable(
const char* variableName);
37 static bool GetVariableValue(
const char* variableName, T& result);
38 static bool GetVariableValue(
const char* variableName,
String& value);
40 static bool GetDefaultVariableValue(
const char* variableName, T& result);
41 static bool GetDefaultVariableValue(
const char* variableName,
String& value);
43 static bool AddVariable(
const char* variableName,
const T& value);
44 static bool AddVariable(
const char* variableName,
const String& value);
46 static bool AddOverriddenVariable(
const char* variableName,
const T& value);
47 static bool AddOverriddenVariable(
const char* variableName,
const String& value);
48 static bool SetVariable(
const char* variableName,
const String& value);
49 static void LogVariables(
void);
50 static void RegisterEnvironmentVariables(
void);
53 static bool RegisterEnvironmentVariable(
const String& name,
const char* value);
61 using VariableNames = std::set<String>;
62 using EnvironmentVariables = std::map<String, String>;
66 ~Data(
void) =
default;
69 bool AddDefaultVariable(
const char* variableName,
const String& value);
70 bool AddOverriddenVariable(
const char* variableName,
const String& value);
71 bool SetDefaultVariable(
const char* variableName,
const String& value);
72 bool SetOverriddenVariable(
const char* variableName,
const String& value);
73 bool GetCurrentVariableValue(
const char* variableName,
const char*& pResult)
const;
74 bool GetDefaultVariableValue(
const char* variableName,
const char*& pResult)
const;
75 bool GetOverriddenVariableValue(
const char* variableName,
const char*& pResult)
const;
78 void GetVariableNames(VariableNames& result);
79 void LogVariables(
void);
82 static bool GetVariableValueFrom(
const EnvironmentVariables& items,
const char* variableName,
const char*& pResult);
85 EnvironmentVariables environmentVariables;
86 EnvironmentVariables overriddenVariables;
92inline int64 Environment::GetTickCount()
94 return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now().time_since_epoch()).count();
97inline Endianness Environment::GetEndianness(
void)
103inline bool Environment::GetVariableValue<String>(
const char* variableName,
String& result)
105 return GetVariableValue(variableName, result);
109inline bool Environment::GetVariableValue(
const char* variableName, T& result)
112 if (!GetVariableValue(variableName, value))
117 std::istringstream iss(value.CStr());
118 iss >> std::boolalpha >> result;
122inline String Environment::GetVariable(
const char* variableName)
125 if (GetVariableValue(variableName, result))
134inline bool Environment::GetDefaultVariableValue<String>(
const char* variableName,
String& result)
136 return GetDefaultVariableValue(variableName, result);
140inline bool Environment::GetDefaultVariableValue(
const char* variableName, T& result)
143 if (!GetDefaultVariableValue(variableName, value))
148 std::istringstream iss(value.CStr());
149 iss >> std::boolalpha >> result;
154inline bool Environment::AddVariable(
const char* variableName,
const T& value)
156 std::stringstream ss;
157 ss << std::boolalpha << value;
158 return Environment::AddVariable(variableName,
String(ss.str()));
161inline bool Environment::AddVariable(
const char* variableName,
const String& value)
163 return Data::GetInstance().AddDefaultVariable(variableName, value);
167inline bool Environment::AddOverriddenVariable(
const char* variableName,
const T& value)
169 std::stringstream ss;
170 ss << std::boolalpha << value;
171 return Environment::AddOverriddenVariable(variableName,
String(ss.str()));
174inline bool Environment::AddOverriddenVariable(
const char* variableName,
const String& value)
176 return Data::GetInstance().AddOverriddenVariable(variableName, value);
181inline bool Environment::Data::GetCurrentVariableValue(
const char* variableName,
const char*& pResult)
const
184 if (GetOverriddenVariableValue(variableName, pResult))
189 return GetDefaultVariableValue(variableName, pResult);
192inline bool Environment::Data::GetDefaultVariableValue(
const char* variableName,
const char*& pResult)
const
194 return GetVariableValueFrom(this->environmentVariables, variableName, pResult);
197inline bool Environment::Data::GetOverriddenVariableValue(
const char* variableName,
const char*& pResult)
const
199 return GetVariableValueFrom(this->overriddenVariables, variableName, pResult);
This class implements the singleton pattern for singletons with process wide scope.
Definition: AppDomainSingleton.hxx:25
Definition: Environment.hpp:20
static const SelfType Empty
An emtpy static string instance.
Definition: BasicString.hxx:224
Arp::BasicString< char8 > String
The Arp String class.
Definition: TypeSystem.h:27
std::int64_t int64
The Arp integer type of 8 byte size.
Definition: PrimitiveTypes.hpp:42
@ System
System components used by the System, Device, Plc or Io domains.
Root namespace for the PLCnext API
Endianness
This enum defines the endinannes of the target architecture.
Definition: Endianness.hpp:13
@ Current
Determines the current endianness.