1%%%%%%%%%%%%%%%%%%%
2% XLiFE++ is an extended library of finite elements written in C++
3%     Copyright (C) 2014  Lunéville, Eric; Kielbasiewicz, Nicolas; Lafranche, Yvon; Nguyen, Manh-Ha; Chambeyron, Colin
4%
5%     This program is free software: you can redistribute it and/or modify
6%     it under the terms of the GNU General Public License as published by
7%     the Free Software Foundation, either version 3 of the License, or
8%     (at your option) any later version.
9%     This program is distributed in the hope that it will be useful,
10%     but WITHOUT ANY WARRANTY; without even the implied warranty of
11%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12%     GNU General Public License for more details.
13%     You should have received a copy of the GNU General Public License
14%     along with this program.  If not, see <http://www.gnu.org/licenses/>.
15%%%%%%%%%%%%%%%%%%%
16
17\section{The {\class Environment} class}
18The {\class Environment} class collects all stuff related to the \xlifepp execution context : machine, operating system, processors-thread, some paths, message language, ...
19
20\vspace{.1cm}
21\begin{lstlisting}
22class Environment
23{
24private:
25const int theLanguageAsAnInt_;   // language as an int
26string_t theXlifeppVersion_;     // version number of XLiFE++
27string_t theXlifeppDate_;        // version date of XLiFE++
28string_t theOS_;                 // OS name
29string_t theProcessor_;          // processor or machine type
30string_t theMachineName_;        // machine name
31string_t thePathToMessageFiles_; // path to error files
32string_t thePathToGeoMacroFile_; // path to geo macro file
33
34static const string_t theInstallPath_;         // xlife++ installation path
35static const string_t theGmshPath_;            // gmsh binary path
36static const string_t theParaviewPath_;        // paraview binary path
37static bool running_;                          // true when running
38static bool parallelOn_;                       // parallel flag (default on)
39static const int theNumberOfLanguages = 2;     // number of languages
40static const string_t theLanguageNames_[];     // language [ "en","fr" ]
41static std::map<string_t, std::vector<string_t> > enumWords_; // global enums
42static std::map<string_t, string_t> words_;    // global words
43\end{lstlisting}
44\vspace{.1cm}
45At initialization (see init.cpp), the {\class Environment} pointer {\var theEnvironment\_p} is allocated and initialized.\\
46
47Only one constructor from language is allowed :
48\vspace{.1cm}
49\begin{lstlisting}
50Environment(int lang = _en );
51\end{lstlisting}
52\vspace{.1cm}
53Copy constructor and assign operator are not available.\\
54
55As all member data are private, there exists their corresponding accessors:
56\vspace{.1cm}
57\begin{lstlisting}
58static bool running();
59static bool parallelOn();
60static string_t installPath();
61static string_t gmshPath();
62static string_t paraviewPath();
63static int numberOfLanguages();
64int language() const;
65string_t osName() const;
66string_t processorName() const;
67string_t machineName() const;
68string_t msgFilePath() const;
69string_t geoMacroFilePath() const;
70bool known() const;
71static void parallel(bool);
72void names();
73void processor();
74void setMsgFilePath();
75void setGeoMacroFilePath();
76void localizedStrings();
77void version();
78string_t languageString() const;
79\end{lstlisting}
80\vspace{.2cm}
81Besides some utilities are provided:
82\vspace{.1cm}
83\begin{lstlisting}
84int returnedFunctionType(const string_t& s);
85int returnedKernelType(const string_t& s);
86void printHeader(const Timer&);
87void printHeader(std::ofstream&);
88void printDictionary(std::ostream&);
89\end{lstlisting}
90\vspace{.2cm}
91Other utilities are provided as non member functions:
92\vspace{.1cm}
93\begin{lstlisting}
94bool is32bits();
95bool is64bits();
96bool parallelOn();
97void parallel(bool);
98number_t numberOfThreads(int n=-1);  //if omp is available
99number_t currentThread();            //if omp is available
100\end{lstlisting}
101
102\subsection{Using the dictionary}
103The {\class Environment} class provides 4 external functions to deal with localized strings:
104
105\begin{lstlisting}
106String words(const String&);
107String words(const char*);
108String words(const bool b);
109String words(const String&, const int);
110\end{lstlisting}
111
112The last function deals with enumeration items. You give the family and the enum item and you get the localized string. The two first functions deals with dictionary words. You give the dictionary keyword :
113
114\begin{lstlisting}
115std::cout << words("shape",_segment) << std::endl;
116std::cout << words("access type",_sym) << std::endl;
117std::cout << words("constructors for real matrix") << std::endl;
118\end{lstlisting}
119
120\displayInfos{library=utils, header=Environment.hpp, implementation=Environment.cpp, test=,
121header dep={config.h, String.hpp, Timer.hpp, Messages.hpp, logo.hpp}}
122
123