37 template <
typename GUM_SCALAR >
43 template <
typename GUM_SCALAR >
50 template <
typename GUM_SCALAR >
52 for (Idx i = Size(m_imports.size()); i > 0; i--)
53 delete m_imports[i - 1];
55 for (Size i = Size(m_sessions.size()); i > 0; i--)
56 delete m_sessions[i - 1];
59 template <
typename GUM_SCALAR >
64 template <
typename GUM_SCALAR >
69 template <
typename GUM_SCALAR >
74 template <
typename GUM_SCALAR >
76 for (Idx i = Size(m_imports.size()); i > 0; i--)
77 if (m_imports[i - 1]->alias == alias)
return m_imports[i - 1]->value;
82 template <
typename GUM_SCALAR >
87 template <
typename GUM_SCALAR >
89 const std::string& import,
90 const std::string& alias) {
91 m_imports.push_back(
new ImportCommand(line, import, alias));
93 if (alias ==
"default") m_mainImport = m_imports.back();
96 template <
typename GUM_SCALAR >
99 m_imports.push_back(
new ImportCommand(line, import, import));
101 if (ismain) m_mainImport = m_imports.back();
104 template <
typename GUM_SCALAR >
109 template <
typename GUM_SCALAR >
111 m_sessions.push_back(
new O3prmrSession< GUM_SCALAR >(session));
114 template <
typename GUM_SCALAR >
118 if (!m_package.empty()) {
119 output +=
"package " +
m_package +
";\n";
123 for (
auto i = m_imports.begin(); i < m_imports.end(); i++)
124 output += (*i)->toString() +
"\n";
128 for (
auto i = m_sessions.begin(); i < m_sessions.end(); i++)
129 output += (*i)->toString() +
"\n";
134 template <
typename GUM_SCALAR >
136 const std::vector< ImportCommand* >& imports = c.imports();
138 for (std::vector< ImportCommand* >::const_iterator i = imports.begin(); i != imports.end();
142 const std::vector< O3prmrSession< GUM_SCALAR >* >& sessions = c.sessions();
144 if (sessions.size() == 1 && sessions.back()->name() ==
"default") {
145 *(
this->m_sessions.back()) += *(sessions.back());
147 for (
auto i = sessions.begin(); i != sessions.end(); i++)
155 template <
typename GUM_SCALAR >
160 template <
typename GUM_SCALAR >
166 template <
typename GUM_SCALAR >
168 for (Idx i = Size(m_commands.size()); i >= 1; i--)
169 delete m_commands[i - 1];
174 template <
typename GUM_SCALAR >
179 template <
typename GUM_SCALAR >
184 template <
typename GUM_SCALAR >
186 m_commands.push_back(command);
189 template <
typename GUM_SCALAR >
191 const std::string& leftValue,
192 const std::string& rightValue) {
193 addCommand(
new ObserveCommand< GUM_SCALAR >(line, leftValue, rightValue));
196 template <
typename GUM_SCALAR >
201 template <
typename GUM_SCALAR >
203 addCommand(
new QueryCommand< GUM_SCALAR >(line, value));
206 template <
typename GUM_SCALAR >
211 template <
typename GUM_SCALAR >
216 template <
typename GUM_SCALAR >
219 case O3prmrCommand::RequestType::SetEngine:
220 m_commands.push_back(
new SetEngineCommand(*(SetEngineCommand*)command));
223 case O3prmrCommand::RequestType::SetGndEngine:
224 m_commands.push_back(
new SetGndEngineCommand(*(SetGndEngineCommand*)command));
227 case O3prmrCommand::RequestType::Observe:
228 m_commands.push_back(
229 new ObserveCommand< GUM_SCALAR >(*(ObserveCommand< GUM_SCALAR >*)command));
232 case O3prmrCommand::RequestType::Unobserve:
233 m_commands.push_back(
234 new UnobserveCommand< GUM_SCALAR >(*(UnobserveCommand< GUM_SCALAR >*)command));
237 case O3prmrCommand::RequestType::Query:
238 m_commands.push_back(
239 new QueryCommand< GUM_SCALAR >(*(QueryCommand< GUM_SCALAR >*)command));
244 template <
typename GUM_SCALAR >
248 output +=
"request " +
m_name +
" {\n";
250 for (std::vector< O3prmrCommand* >::const_iterator i = m_commands.begin();
251 i < m_commands.end();
253 output +=
"\t" + (*i)->toString() +
"\n";
260 template <
typename GUM_SCALAR >
263 for (std::vector< O3prmrCommand* >::const_iterator i = c.m_commands.begin();
264 i < c.m_commands.end();
void addObserve(int line, const std::string &leftValue, const std::string &rightValue)
std::map< const PRMSystem< GUM_SCALAR > *, PRMInference< GUM_SCALAR > *> m_infEngineMap
void addSession(const O3prmrSession< GUM_SCALAR > &session)
virtual std::string toString() const
INLINE void emplace(Args &&... args)
void addImport(int line, const std::string &import, bool ismain)
PRMInference< GUM_SCALAR >::Chain chain
void addCommand(O3prmrCommand *command)
std::vector< ImportCommand *> imports() const
std::vector< O3prmrCommand *> commands() const
std::string filename() const
std::string aliasToImport(const std::string &alias)
void addImport(int line, const std::string &import, const std::string &alias)
SetGndEngineCommand(int line, const std::string &value)
O3prmrSession(const std::string &name=std::string())
void addUnobserve(int line, const std::string &value)
O3prmrSession(const O3prmrSession &s)
SetEngineCommand(int line, const std::string &value)
O3prmrContext(const std::string &filename=std::string())
O3prmrContext & operator+=(const O3prmrContext &c)
ParamScopeData(const std::string &s, const PRMReferenceSlot< GUM_SCALAR > &ref, Idx d)
PRMInference< GUM_SCALAR >::Chain chain
O3prmrContext(const O3prmrContext &s)
void setPackage(const std::string &package)
This is an abstract class.
Represent a o3prmr context, with an import, and some sequencials commands.
std::vector< O3prmrSession< GUM_SCALAR > *> sessions() const
ImportCommand * m_mainImport
void addQuery(int line, const std::string &value)
void addSetGndEngine(int line, const std::string &value)
virtual std::string toString() const
std::string package() const
PRMInference< GUM_SCALAR >::Chain chain
void addSetEngine(int line, const std::string &value)
virtual RequestType type() const =0
std::string m_name
The session name;.
void addCommand(const O3prmrCommand *command)
O3prmrSession & operator+=(const O3prmrSession &c)