aGrUM 3.2.0
a C++ library for (probabilistic) graphical models
gum::prm::o3prmr::O3prmrContext< GUM_SCALAR > Class Template Reference

Represent a o3prmr context, with an import, and some sequencials commands. More...

#include <O3prmrContext.h>

Collaboration diagram for gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >:
[legend]

Public Member Functions

 O3prmrContext (std::string_view filename="")
 O3prmrContext (const O3prmrContext &s)
virtual ~O3prmrContext ()
const ImportCommand * mainImport () const
std::string filename () const
std::string package () const
void setPackage (std::string_view package)
std::string aliasToImport (std::string_view alias)
std::vector< ImportCommand * > imports () const
void addImport (int line, std::string_view import, std::string_view alias)
void addImport (int line, std::string_view import, bool ismain)
void addImport (const ImportCommand &i)
std::vector< O3prmrSession< GUM_SCALAR > * > sessions () const
void addSession (const O3prmrSession< GUM_SCALAR > &session)
virtual std::string toString () const
O3prmrContext & operator+= (const O3prmrContext &c)

Private Attributes

std::string m_filename
std::string m_package
std::vector< O3prmrSession< GUM_SCALAR > * > m_sessions
std::vector< ImportCommand * > m_imports
ImportCommand * m_mainImport

Detailed Description

template<GUM_Numeric GUM_SCALAR>
class gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >

Represent a o3prmr context, with an import, and some sequencials commands.

Definition at line 216 of file O3prmrContext.h.

Constructor & Destructor Documentation

◆ O3prmrContext() [1/2]

template<GUM_Numeric GUM_SCALAR>
gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::O3prmrContext ( std::string_view filename = "")
explicit

Definition at line 135 of file O3prmrContext_tpl.h.

References filename(), m_filename, and m_mainImport.

Referenced by O3prmrContext(), and operator+=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ O3prmrContext() [2/2]

template<GUM_Numeric GUM_SCALAR>
gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::O3prmrContext ( const O3prmrContext< GUM_SCALAR > & s)

Definition at line 141 of file O3prmrContext_tpl.h.

141 {
144 *this += s;
145 }
Represent a o3prmr context, with an import, and some sequencials commands.

References O3prmrContext(), m_filename, and m_mainImport.

Here is the call graph for this function:

◆ ~O3prmrContext()

template<GUM_Numeric GUM_SCALAR>
gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::~O3prmrContext ( )
virtual

Definition at line 148 of file O3prmrContext_tpl.h.

148 {
149 for (Idx i = Size(m_imports.size()); i > 0; i--)
150 delete m_imports[i - 1];
151
152 for (Size i = Size(m_sessions.size()); i > 0; i--)
153 delete m_sessions[i - 1];
154 }
std::vector< ImportCommand * > m_imports
std::vector< O3prmrSession< GUM_SCALAR > * > m_sessions

References m_imports, and m_sessions.

Member Function Documentation

◆ addImport() [1/3]

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::addImport ( const ImportCommand & i)

Definition at line 126 of file O3prmrContext_tpl.h.

126 {
127 m_imports.push_back(new ImportCommand(i.line, i.value, i.alias));
128
129 if (i.alias == "default") m_mainImport = m_imports.back();
130 }
ImportCommand(int line, std::string_view value, std::string_view alias)

References gum::prm::o3prmr::ImportCommand::ImportCommand(), gum::prm::o3prmr::ImportCommand::alias, gum::prm::o3prmr::ImportCommand::line, m_imports, m_mainImport, and gum::prm::o3prmr::ImportCommand::value.

Here is the call graph for this function:

◆ addImport() [2/3]

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::addImport ( int line,
std::string_view import,
bool ismain )

Definition at line 194 of file O3prmrContext_tpl.h.

194 {
195 m_imports.push_back(new ImportCommand(line, import, import));
196
197 if (ismain) m_mainImport = m_imports.back();
198 }

References gum::prm::o3prmr::ImportCommand::ImportCommand(), m_imports, and m_mainImport.

Here is the call graph for this function:

◆ addImport() [3/3]

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::addImport ( int line,
std::string_view import,
std::string_view alias )

Definition at line 185 of file O3prmrContext_tpl.h.

187 {
188 m_imports.push_back(new ImportCommand(line, import, alias));
189
190 if (alias == "default") m_mainImport = m_imports.back();
191 }

References gum::prm::o3prmr::ImportCommand::ImportCommand(), m_imports, and m_mainImport.

Referenced by gum::prm::o3prmr::O3prmrInterpreter::checkSemantic().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addSession()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::addSession ( const O3prmrSession< GUM_SCALAR > & session)

Definition at line 206 of file O3prmrContext_tpl.h.

206 {
208 }

References m_sessions.

Referenced by gum::prm::o3prmr::O3prmrInterpreter::checkSemantic().

Here is the caller graph for this function:

◆ aliasToImport()

template<GUM_Numeric GUM_SCALAR>
std::string gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::aliasToImport ( std::string_view alias)

Definition at line 172 of file O3prmrContext_tpl.h.

172 {
173 for (Idx i = Size(m_imports.size()); i > 0; i--)
174 if (m_imports[i - 1]->alias == alias) return m_imports[i - 1]->value;
175
176 return {};
177 }

References m_imports.

Referenced by gum::prm::o3prmr::O3prmrInterpreter::findSystemName().

Here is the caller graph for this function:

◆ filename()

template<GUM_Numeric GUM_SCALAR>
std::string gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::filename ( ) const

Definition at line 157 of file O3prmrContext_tpl.h.

157 {
158 return m_filename;
159 }

References m_filename.

Referenced by O3prmrContext(), gum::prm::o3prmr::O3prmrInterpreter::addError(), gum::prm::o3prmr::O3prmrInterpreter::addWarning(), and gum::prm::o3prmr::O3prmrInterpreter::import().

Here is the caller graph for this function:

◆ imports()

template<GUM_Numeric GUM_SCALAR>
std::vector< ImportCommand * > gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::imports ( ) const

Definition at line 180 of file O3prmrContext_tpl.h.

180 {
181 return m_imports;
182 }

References m_imports.

Referenced by gum::prm::o3prmr::O3prmrInterpreter::checkSemantic().

Here is the caller graph for this function:

◆ mainImport()

template<GUM_Numeric GUM_SCALAR>
const ImportCommand * gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::mainImport ( ) const

Definition at line 121 of file O3prmrContext_tpl.h.

121 {
122 return m_mainImport;
123 }

References m_mainImport.

Referenced by gum::prm::o3prmr::O3prmrInterpreter::system().

Here is the caller graph for this function:

◆ operator+=()

template<GUM_Numeric GUM_SCALAR>
O3prmrContext< GUM_SCALAR > & gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::operator+= ( const O3prmrContext< GUM_SCALAR > & c)

Definition at line 231 of file O3prmrContext_tpl.h.

231 {
233
235 i++)
236 addImport(**i);
237
239
240 if (sessions.size() == 1 && sessions.back()->name() == "default") {
241 *(this->m_sessions.back()) += *(sessions.back());
242 } else
243 for (auto i = sessions.begin(); i != sessions.end(); i++)
244 addSession(**i);
245
246 return *this;
247 }
void addImport(int line, std::string_view import, std::string_view alias)
std::vector< O3prmrSession< GUM_SCALAR > * > sessions() const
void addSession(const O3prmrSession< GUM_SCALAR > &session)
std::vector< ImportCommand * > imports() const

References O3prmrContext().

Here is the call graph for this function:

◆ package()

template<GUM_Numeric GUM_SCALAR>
std::string gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::package ( ) const

Definition at line 162 of file O3prmrContext_tpl.h.

162 {
163 return m_package;
164 }

References m_package.

Referenced by setPackage().

Here is the caller graph for this function:

◆ sessions()

template<GUM_Numeric GUM_SCALAR>
std::vector< O3prmrSession< GUM_SCALAR > * > gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::sessions ( ) const

Definition at line 201 of file O3prmrContext_tpl.h.

201 {
202 return m_sessions;
203 }

References m_sessions.

Referenced by gum::prm::o3prmr::O3prmrInterpreter::checkSemantic(), and gum::prm::o3prmr::O3prmrInterpreter::interpret().

Here is the caller graph for this function:

◆ setPackage()

template<GUM_Numeric GUM_SCALAR>
void gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::setPackage ( std::string_view package)

Definition at line 167 of file O3prmrContext_tpl.h.

167 {
169 }

References m_package, and package().

Here is the call graph for this function:

◆ toString()

template<GUM_Numeric GUM_SCALAR>
std::string gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::toString ( ) const
virtual

Definition at line 211 of file O3prmrContext_tpl.h.

211 {
213
214 if (!m_package.empty()) {
215 output += "package " + m_package + ";\n";
216 output += "\n";
217 }
218
219 for (auto i = m_imports.begin(); i < m_imports.end(); i++)
220 output += (*i)->toString() + "\n";
221
222 output += "\n";
223
224 for (auto i = m_sessions.begin(); i < m_sessions.end(); i++)
225 output += (*i)->toString() + "\n";
226
227 return output;
228 }
virtual std::string toString() const

References m_imports, and m_package.

Member Data Documentation

◆ m_filename

template<GUM_Numeric GUM_SCALAR>
std::string gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::m_filename
private

Definition at line 217 of file O3prmrContext.h.

Referenced by O3prmrContext(), O3prmrContext(), and filename().

◆ m_imports

template<GUM_Numeric GUM_SCALAR>
std::vector< ImportCommand* > gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::m_imports
private

◆ m_mainImport

template<GUM_Numeric GUM_SCALAR>
ImportCommand* gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::m_mainImport
private

◆ m_package

template<GUM_Numeric GUM_SCALAR>
std::string gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::m_package
private

Definition at line 218 of file O3prmrContext.h.

Referenced by package(), setPackage(), and toString().

◆ m_sessions

template<GUM_Numeric GUM_SCALAR>
std::vector< O3prmrSession< GUM_SCALAR >* > gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::m_sessions
private

Definition at line 219 of file O3prmrContext.h.

Referenced by ~O3prmrContext(), addSession(), and sessions().


The documentation for this class was generated from the following files: