19#ifndef _GENERIC_COMPOSITE_MODEL_H
20#define _GENERIC_COMPOSITE_MODEL_H
30 struct ParamAssignExpression;
32 struct RecipeParameter;
33 struct RecipeElementStep;
38 class TranslatedFrame;
41 class ExprRandomState;
44#ifdef PYTHON_SCRIPT_SUPPORT
48 enum GenericModelParamType {
49 GENERIC_MODEL_PARAM_TYPE_ELEMENT,
50 GENERIC_MODEL_PARAM_TYPE_ROTATED_FRAME,
51 GENERIC_MODEL_PARAM_TYPE_TRANSLATED_FRAME,
52 GENERIC_MODEL_PARAM_TYPE_VARIABLE
55 class GenericModelParam;
56 typedef std::map<std::string, GenericModelParam *> GenericEvaluatorSymbolDict;
61 virtual Real evaluate (Real
const *args,
unsigned argc) = 0;
65 const GenericEvaluatorSymbolDict *m_dict =
nullptr;
68 std::list<GenericCustomFunction *> m_funcList;
71 std::list<std::string> symbols()
const;
72 std::list<GenericCustomFunction *> functions()
const;
73 Real *resolve(std::string
const &);
80 virtual std::list<std::string> dependencies()
const = 0;
81 virtual bool compile(std::string
const &) = 0;
82 virtual Real evaluate() = 0;
87 GenericModelParamType type;
91 std::string assignString;
111 std::list<GenericComponentParamEvaluator *> dependencies;
121 std::string m_givenName =
"(no name)";
123 Recipe *m_recipe =
nullptr;
126 bool m_ownsRecipe =
false;
128 GenericEvaluatorSymbolDict m_global;
129 std::vector<ReferenceFrame *> m_frames;
130 std::vector<Element *> m_elements;
132 std::list<CompositeElementFactory *> m_customFactoryList;
133 std::map<std::string, CompositeElementFactory *> m_customFactories;
134 std::list<GenericComponentParamEvaluator *> m_expressions;
138#ifdef PYTHON_SCRIPT_SUPPORT
139 std::list<Script *> m_scripts;
142 unsigned int m_completedFrames = 0;
143 unsigned int m_completedElements = 0;
146 std::list<GenericModelParam *> m_genParamStorage;
149 std::map<std::string, GenericModelParam *> m_params;
150 std::map<std::string, GenericModelParam *> m_dofs;
152 std::string m_prefix;
154 bool m_constructed =
false;
157 ElementFactory *lookupElementFactory(
const std::string &,
bool &)
const;
160 void initGlobalScope();
161 void registerCustomElements();
165 void createDelayedElements();
169 void createScopedExpressions(
170 GenericEvaluatorSymbolDict &,
172 void createScopedVariables(
173 GenericEvaluatorSymbolDict &,
176 void delayedCreationLoop();
177 void createExpressions();
178 void exposeOpticalPaths();
182 std::string
const &expr,
183 const GenericEvaluatorSymbolDict *dict);
185 static bool getLastDottedElement(
188 std::string &suffix);
192 GenericEvaluatorSymbolDict
const &symbolDict()
const;
193 void setName(std::string
const &);
196 virtual void registerDof(
197 std::string
const &name,
200 virtual void registerParam(
201 std::string
const &name,
204 virtual void registerOpticalPath(
205 std::string
const &name,
206 std::list<std::string> ¶ms) = 0;
209 std::string
const &expr,
210 const GenericEvaluatorSymbolDict *dict,
211 std::list<GenericCustomFunction *>
const &functions,
214 virtual void exposePort(
215 std::string
const &name,
228 std::string givenName()
const;
229 std::list<std::string> params()
const;
230 std::list<std::string> dofs()
const;
236 bool loadScript(std::string
const &path);
237 bool setParam(std::string
const &, Real);
238 bool setDof(std::string
const &, Real);
240 std::string resolveFilePath(std::string
const &)
const;
242 void assignEverything();
243 void updateRandState();
249 void transferRecipeOwnership();
251 virtual void notifyDetector(
252 std::string
const &preferredName,
Definition: CompositeElement.h:97
Definition: Detector.h:116
Definition: Element.h:393
Definition: Element.h:173
Definition: GenericCompositeModel.h:120
Definition: GenericCompositeModel.h:64
Definition: OMModel.h:204
Definition: ReferenceFrame.h:59
Definition: RotatedFrame.h:25
Definition: TranslatedFrame.h:25
Definition: GenericCompositeModel.h:86
Definition: GenericCompositeModel.h:58
Definition: GenericCompositeModel.h:106