# Coriolis Core (CRLCore) Documentation

# Coriolis Core (CRL) Documentation

Environment.h
1 // -*- C++ -*-
2 //
3 // This file is part of the Coriolis Software.
4 // Copyright (c) UPMC 2008-2018, All Rights Reserved
5 //
6 // +-----------------------------------------------------------------+
7 // | C O R I O L I S |
8 // | Alliance / Hurricane Interface |
9 // | |
10 // | Author : Jean-Paul CHAPUT |
11 // | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
12 // | =============================================================== |
13 // | C++ Header : "./crlcore/Environment.h" |
14 // +-----------------------------------------------------------------+
15
16
17 #pragma once
18 #include <regex.h>
19 #include <string>
20 #include "hurricane/Commons.h"
21 #include "crlcore/SearchPath.h"
22
23
24 namespace CRL {
25
26 using Hurricane::JsonObject;
27 using Hurricane::JsonStack;
28
29
30 // -------------------------------------------------------------------
31 // Class : "Environment".
32
33 class Environment {
34 public:
35 enum AddMode { Append=1, Prepend=2, Replace=3 };
36 public:
37 // Internal: Static Methods.
38 static const char* getEnv ( const char* variable, const char* defaultValue );
39 // Constructors & destructors.
40 Environment ();
41 ~Environment ();
42 // Accessors.
43 inline const std::string& getCORIOLIS_TOP () const;
44 inline const std::string& getDisplayStyle () const;
45 inline long getSCALE_X () const;
46 inline const std::string& getDISPLAY () const;
47 inline const std::string& getIN_LO () const;
48 inline const std::string& getIN_PH () const;
49 inline const std::string& getOUT_LO () const;
50 inline const std::string& getOUT_PH () const;
51 inline const std::string& getPOWER () const;
52 inline const std::string& getGROUND () const;
53 inline const std::string& getCLOCK () const;
54 inline const std::string& getBLOCKAGE () const;
55 inline const std::string& getPad () const;
56 inline const std::string& getCATALOG () const;
57 inline SearchPath& getLIBRARIES ();
58 std::string getLIBRARYPath ( size_t i );
59 // Predicates.
60 bool isPOWER ( const char* name ) const;
61 bool isGROUND ( const char* name ) const;
62 bool isCLOCK ( const char* name ) const;
63 bool isBLOCKAGE ( const char* name ) const;
64 bool isPad ( const char* name ) const;
65 // Modifiers.
66 void validate () const;
67 inline void setDisplayStyle ( const char* );
68 inline void setSCALE_X ( long value );
69 inline void setDISPLAY ( const char* value );
70 inline void setIN_LO ( const char* value );
71 inline void setIN_PH ( const char* value );
72 inline void setOUT_LO ( const char* value );
73 inline void setOUT_PH ( const char* value );
74 void setPOWER ( const char* value );
75 void setGROUND ( const char* value );
76 void setCLOCK ( const char* value );
77 void setBLOCKAGE ( const char* value );
78 void setPad ( const char* value );
79 inline void setCATALOG ( const char* value );
80 void setWORKING_LIBRARY ( const char* value );
81 void addSYSTEM_LIBRARY ( const char* value, const char* libName, unsigned int mode=Append );
82 // Methods.
83 std::string getPrint () const;
84 void toJson ( JsonWriter* ) const;
85 inline std::string _getTypeName () const;
86 std::string _getString () const;
87 Record* _getRecord () const;
88 protected:
89 // Internal: Attributes.
90 std::string _CORIOLIS_TOP;
91 std::string _displayStyle;
92 long _SCALE_X;
93 std::string _IN_LO;
94 std::string _IN_PH;
95 std::string _OUT_LO;
96 std::string _OUT_PH;
97 std::string _CATALOG;
98 std::string _POWER;
99 std::string _GROUND;
100 std::string _CLOCK;
101 std::string _BLOCKAGE;
102 std::string _pad;
103 SearchPath _LIBRARIES;
104 regex_t* _PowerRegex;
105 regex_t* _GroundRegex;
106 regex_t* _ClockRegex;
107 regex_t* _BlockageRegex;
108 regex_t* _padRegex;
109 private:
110 void _setRegex ( regex_t*& regex, const std::string& pattern, const char* name );
111 };
112
113
114 // Inline Member Functions.
115 inline const std::string& Environment::getCORIOLIS_TOP () const { return _CORIOLIS_TOP; }
116 inline const std::string& Environment::getDisplayStyle () const { return _displayStyle; }
117 inline long Environment::getSCALE_X () const { return _SCALE_X; }
118 inline const std::string& Environment::getIN_LO () const { return _IN_LO; }
119 inline const std::string& Environment::getIN_PH () const { return _IN_PH; }
120 inline const std::string& Environment::getOUT_LO () const { return _OUT_LO; }
121 inline const std::string& Environment::getOUT_PH () const { return _OUT_PH; }
122 inline const std::string& Environment::getPOWER () const { return _POWER; }
123 inline const std::string& Environment::getGROUND () const { return _GROUND; }
124 inline const std::string& Environment::getCLOCK () const { return _CLOCK; }
125 inline const std::string& Environment::getBLOCKAGE () const { return _BLOCKAGE; }
126 inline const std::string& Environment::getPad () const { return _pad; }
127 inline const std::string& Environment::getCATALOG () const { return _CATALOG; }
128 inline SearchPath& Environment::getLIBRARIES () { return _LIBRARIES; }
129
130 inline void Environment::setDisplayStyle ( const char* value ) { _displayStyle = value; }
131 inline void Environment::setSCALE_X ( long value ) { _SCALE_X = value; }
132 inline void Environment::setIN_LO ( const char* value ) { _IN_LO = value; }
133 inline void Environment::setIN_PH ( const char* value ) { _IN_PH = value; }
134 inline void Environment::setOUT_LO ( const char* value ) { _OUT_LO = value; }
135 inline void Environment::setOUT_PH ( const char* value ) { _OUT_PH = value; }
136 inline void Environment::setCATALOG ( const char* value ) { _CATALOG = value; }
137 inline std::string Environment::_getTypeName () const { return "Environment"; }
138
139
140 // -------------------------------------------------------------------
141 // Class : "JsonEnvironment".
142
143 class JsonEnvironment : public JsonObject {
144 public:
145 static void initialize ();
146 JsonEnvironment ( unsigned long flags );
147 virtual std::string getTypeName () const;
148 virtual JsonEnvironment* clone ( unsigned long flags ) const;
149 virtual void toData ( JsonStack& );
150 };
151
152
153 } // CRL namespace.
154
155
156 INSPECTOR_P_SUPPORT(CRL::Environment);
CRL::Environment::setCATALOG
void setCATALOG(const char *value)
Definition: Environment.h:136
CRL::Environment::isBLOCKAGE
bool isBLOCKAGE(const char *name) const
CRL::Environment::Append
Definition: Environment.h:35
CRL::Environment::setSCALE_X
void setSCALE_X(long value)
Definition: Environment.h:131
CRL::Environment::setBLOCKAGE
void setBLOCKAGE(const char *value)
CRL::Environment::isCLOCK
bool isCLOCK(const char *name) const
CRL::Environment::isPOWER
bool isPOWER(const char *name) const
CRL::Environment::getCATALOG
const std::string & getCATALOG() const
Definition: Environment.h:127
CRL::Environment::getLIBRARIES
SearchPath & getLIBRARIES()
Definition: Environment.h:128
CRL::Environment::setGROUND
void setGROUND(const char *value)
CRL::Environment::getIN_PH
const std::string & getIN_PH() const
Definition: Environment.h:119
CRL::Environment::getPad
const std::string & getPad() const
Definition: Environment.h:126
CRL::Environment::setWORKING_LIBRARY
void setWORKING_LIBRARY(const char *value)
Hurricane::JsonObject
CRL::Environment::getPrint
std::string getPrint() const
CRL::Environment::validate
void validate() const
CRL::Environment::Prepend
Definition: Environment.h:35
CRL::Environment::Replace
Definition: Environment.h:35
CRL::Environment::setPad
void setPad(const char *value)
CRL::Environment::getOUT_LO
const std::string & getOUT_LO() const
Definition: Environment.h:120
CRL::Environment::getDISPLAY
const std::string & getDISPLAY() const
CRL::Environment::addSYSTEM_LIBRARY
void addSYSTEM_LIBRARY(const char *value, const char *libName, unsigned int mode=Append)
CRL::Environment::setOUT_LO
void setOUT_LO(const char *value)
Definition: Environment.h:134
CRL::Environment::getGROUND
const std::string & getGROUND() const
Definition: Environment.h:123
CRL::Environment::isPad
bool isPad(const char *name) const
CRL::Environment::getOUT_PH
const std::string & getOUT_PH() const
Definition: Environment.h:121
CRL::Environment::setPOWER
void setPOWER(const char *value)
CRL::Environment::setIN_PH
void setIN_PH(const char *value)
Definition: Environment.h:133
Hurricane::JsonStack
CRL::Environment::isGROUND
bool isGROUND(const char *name) const
CRL::Environment::getBLOCKAGE
const std::string & getBLOCKAGE() const
Definition: Environment.h:125
CRL::Environment::getCORIOLIS_TOP
const std::string & getCORIOLIS_TOP() const
Definition: Environment.h:115
CRL::Environment::Environment
Environment()
CRL::Environment::~Environment
~Environment()
CRL::Environment::setIN_LO
void setIN_LO(const char *value)
Definition: Environment.h:132
CRL::Environment::getPOWER
const std::string & getPOWER() const
Definition: Environment.h:122
CRL::SearchPath
An ordered list of search pathes.
Definition: SearchPath.h:32
CRL::Environment::getCLOCK
const std::string & getCLOCK() const
Definition: Environment.h:124
CRL::Environment::getSCALE_X
long getSCALE_X() const
Definition: Environment.h:117
CRL::Environment::getDisplayStyle
const std::string & getDisplayStyle() const
Definition: Environment.h:116
CRL::Environment::setOUT_PH
void setOUT_PH(const char *value)
Definition: Environment.h:135
CRL::Environment::getIN_LO
const std::string & getIN_LO() const
Definition: Environment.h:118
CRL::Environment::AddMode
AddMode
Definition: Environment.h:35
CRL::Environment
Holds all the Alliance environment variables.
Definition: Environment.h:33
CRL::Environment::getLIBRARYPath
std::string getLIBRARYPath(size_t i)
CRL::Environment::setCLOCK
void setCLOCK(const char *value)
CRL::Environment::setDisplayStyle
void setDisplayStyle(const char *)
Definition: Environment.h:130
CRL
The namespace of Coriolis Core.
Definition: Environment.h:24
CRL::Environment::setDISPLAY
void setDISPLAY(const char *value)