Documentation of CSL
librarygroup.h
1 // This file is part of MARTY.
2 //
3 // MARTY is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // MARTY is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with MARTY. If not, see <https://www.gnu.org/licenses/>.
15 
16  #pragma once
17 
18 #include <string>
19 #include "libraryfunction.h"
20 
21 namespace csl {
22 
23  class LibraryGroup {
24 
25  public:
26 
28  std::string t_name,
29  bool t_complexReturn
30  )
31  :name(t_name),
32  paramName(
33  "param"
34  + ((name.empty()) ? std::string("") : "_" + name)
35  + "_t"),
36  complexReturn(t_complexReturn)
37  {}
38 
39  LibraryGroup(LibraryGroup const &) = default;
40  LibraryGroup &operator=(LibraryGroup const &) = default;
41 
42  bool empty() const { return functions.empty(); }
43 
44  bool hasComplexReturn() const { return complexReturn; }
45 
46  std::string const &getName() const { return name; }
47 
48  std::string getParamName() const {
49  return paramName;
50  }
51 
52  void setParamName(std::string const &t_paramName) {
53  paramName = t_paramName;
54  }
55 
56  std::vector<LibParameter> const &getParameters() const {
57  return parameters;
58  }
59  std::vector<LibParameter> &getParameters() {
60  return parameters;
61  }
62 
63  std::vector<LibFunction> const &getFunctions() const {
64  return functions;
65  }
66  std::vector<LibFunction> &getFunctions() {
67  return functions;
68  }
69 
70  LibFunction &addFunction(LibFunction &&func)
71  {
72  functions.emplace_back(std::move(func));
73  return functions.back();
74  }
75 
76  std::vector<LibParameter> const &getForcedParameters() const {
77  return forcedParameters;
78  }
79 
80  void setForcedParameters(std::vector<LibParameter> const &t_params);
81 
82  static
83  std::vector<LibParameter> gatherParameters(
84  std::vector<std::shared_ptr<LibraryGroup>> &groups,
85  std::string const &paramName
86  );
87 
88  void gatherParameters();
89 
90  static
91  void printResetParameterList(
92  std::string const &nameContainer,
93  std::vector<LibParameter> const &params,
94  std::ostream &out,
95  int nIndent
96  );
97 
98  void printResetDefinition(
99  std::ostream &out,
100  int nIndent
101  ) const;
102 
103  static
104  void printPrintParameterList(
105  std::string const &nameContainer,
106  std::vector<LibParameter> const &params,
107  std::ostream &out,
108  int nIndent
109  );
110 
111  void printPrintDefinition(
112  std::ostream &out,
113  int nIndent
114  ) const;
115 
116  void printNameMapElement(
117  std::ostream &out,
118  int nIndent,
119  LibParameter const &param,
120  std::string const &type
121  ) const;
122 
123  void printNameMap(
124  std::ostream &out,
125  int nIndent
126  ) const;
127 
128  void printStructDefinition(
129  std::ostream &out,
130  int nIndent
131  ) const;
132 
133  void printFunctionStack(
134  std::ostream &out,
135  int nIndent
136  ) const;
137 
138  void printParameterDefinition(
139  std::ostream &out,
140  bool unusedParam
141  ) const;
142 
143  void printParameterInitialization(
144  std::ostream &out,
145  int nIndent
146  ) const;
147 
148  void printForwardDefinitions(
149  std::ostream &out,
150  int nIndent
151  ) const;
152 
153  void print(
154  std::ostream &out,
155  bool header
156  ) const;
157 
158  private:
159 
160  std::string name;
161  std::string paramName;
162  bool complexReturn;
163  mutable int posTensorParam;
164  mutable std::vector<LibParameter> parameters;
165  mutable std::vector<LibParameter> forcedParameters;
166  mutable std::vector<LibFunction> functions;
167  };
168 
169 } // namespace csl
Namespace for csl library.
Definition: abreviation.h:34
Definition: libraryfunction.h:45
Definition: libraryfunction.h:36
Definition: diagonalization.h:34
Definition: librarygroup.h:23