aGrUM  0.13.2
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 >:

Public Member Functions

 O3prmrContext (const std::string &filename=std::string())
 
 O3prmrContext (const O3prmrContext &s)
 
virtual ~O3prmrContext ()
 
const ImportCommandmainImport () const
 
std::string filename () const
 
std::string package () const
 
void setPackage (const std::string &package)
 
std::string aliasToImport (const std::string &alias)
 
std::vector< ImportCommand * > imports () const
 
void addImport (int line, const std::string &import, const std::string &alias)
 
void addImport (int line, const std::string &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
 
O3prmrContextoperator+= (const O3prmrContext &c)
 

Detailed Description

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

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

Definition at line 214 of file O3prmrContext.h.

Constructor & Destructor Documentation

template<typename GUM_SCALAR >
gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::O3prmrContext ( const std::string &  filename = std::string())
explicit

Definition at line 36 of file O3prmrContext_tpl.h.

36  {
38  m_mainImport = 0;
39  }
template<typename GUM_SCALAR >
gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::O3prmrContext ( const O3prmrContext< GUM_SCALAR > &  s)

Definition at line 42 of file O3prmrContext_tpl.h.

References gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::m_filename, and gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::m_mainImport.

42  {
43  m_filename = s.m_filename;
44  m_mainImport = s.m_mainImport;
45  *this += s;
46  }
template<typename GUM_SCALAR >
gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::~O3prmrContext ( )
virtual

Definition at line 49 of file O3prmrContext_tpl.h.

49  {
50  for (Idx i = Size(m_imports.size()); i > 0; i--)
51  delete m_imports[i - 1];
52 
53  for (Size i = Size(m_sessions.size()); i > 0; i--)
54  delete m_sessions[i - 1];
55  }
unsigned long Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:50
std::vector< O3prmrSession< GUM_SCALAR > * > m_sessions
std::vector< ImportCommand * > m_imports
unsigned long Idx
Type for indexes.
Definition: types.h:43

Member Function Documentation

template<typename GUM_SCALAR >
void gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::addImport ( int  line,
const std::string &  import,
const std::string &  alias 
)

Definition at line 87 of file O3prmrContext_tpl.h.

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

89  {
90  m_imports.push_back(new ImportCommand(line, import, alias));
91 
92  if (alias == "default") m_mainImport = m_imports.back();
93  }
std::vector< ImportCommand * > m_imports

+ Here is the caller graph for this function:

template<typename GUM_SCALAR >
void gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::addImport ( int  line,
const std::string &  import,
bool  ismain 
)

Definition at line 96 of file O3prmrContext_tpl.h.

98  {
99  m_imports.push_back(new ImportCommand(line, import, import));
100 
101  if (ismain) m_mainImport = m_imports.back();
102  }
std::vector< ImportCommand * > m_imports
template<typename GUM_SCALAR>
void gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::addImport ( const ImportCommand i)
inline

Definition at line 238 of file O3prmrContext.h.

238  {
239  m_imports.push_back(new ImportCommand(i.line, i.value, i.alias));
240 
241  if (i.alias == "default") m_mainImport = m_imports.back();
242  }
std::vector< ImportCommand * > m_imports
template<typename GUM_SCALAR>
void gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::addSession ( const O3prmrSession< GUM_SCALAR > &  session)

Definition at line 111 of file O3prmrContext_tpl.h.

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

112  {
113  m_sessions.push_back(new O3prmrSession< GUM_SCALAR >(session));
114  }
std::vector< O3prmrSession< GUM_SCALAR > * > m_sessions

+ Here is the caller graph for this function:

template<typename GUM_SCALAR >
std::string gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::aliasToImport ( const std::string &  alias)

Definition at line 74 of file O3prmrContext_tpl.h.

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

74  {
75  for (Idx i = Size(m_imports.size()); i > 0; i--)
76  if (m_imports[i - 1]->alias == alias) return m_imports[i - 1]->value;
77 
78  return std::string();
79  }
unsigned long Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:50
std::vector< ImportCommand * > m_imports
unsigned long Idx
Type for indexes.
Definition: types.h:43

+ Here is the caller graph for this function:

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

Definition at line 58 of file O3prmrContext_tpl.h.

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

58  {
59  return m_filename;
60  }

+ Here is the caller graph for this function:

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

Definition at line 82 of file O3prmrContext_tpl.h.

Referenced by gum::prm::o3prmr::O3prmrInterpreter::checkSemantic(), and gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::operator+=().

82  {
83  return m_imports;
84  }
std::vector< ImportCommand * > m_imports

+ Here is the caller graph for this function:

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

Definition at line 226 of file O3prmrContext.h.

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

226 { return m_mainImport; }

+ Here is the caller graph for this function:

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

Definition at line 138 of file O3prmrContext_tpl.h.

References gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::imports(), and gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::sessions().

Referenced by gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::toString().

138  {
139  const std::vector< ImportCommand* >& imports = c.imports();
140 
141  for (std::vector< ImportCommand* >::const_iterator i = imports.begin();
142  i != imports.end();
143  i++)
144  addImport(**i);
145 
146  const std::vector< O3prmrSession< GUM_SCALAR >* >& sessions = c.sessions();
147 
148  if (sessions.size() == 1 && sessions.back()->name() == "default") {
149  *(this->m_sessions.back()) += *(sessions.back());
150  } else
151  for (auto i = sessions.begin(); i != sessions.end(); i++)
152  addSession(**i);
153 
154  return *this;
155  }
void addSession(const O3prmrSession< GUM_SCALAR > &session)
std::vector< O3prmrSession< GUM_SCALAR > * > m_sessions
void addImport(int line, const std::string &import, const std::string &alias)
std::vector< ImportCommand * > imports() const
std::vector< O3prmrSession< GUM_SCALAR > * > sessions() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 63 of file O3prmrContext_tpl.h.

63  {
64  return m_package;
65  }
template<typename GUM_SCALAR >
std::vector< O3prmrSession< GUM_SCALAR > * > gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::sessions ( ) const

Definition at line 106 of file O3prmrContext_tpl.h.

Referenced by gum::prm::o3prmr::O3prmrInterpreter::checkSemantic(), gum::prm::o3prmr::O3prmrInterpreter::interpret(), and gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::operator+=().

106  {
107  return m_sessions;
108  }
std::vector< O3prmrSession< GUM_SCALAR > * > m_sessions

+ Here is the caller graph for this function:

template<typename GUM_SCALAR >
void gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::setPackage ( const std::string &  package)

Definition at line 68 of file O3prmrContext_tpl.h.

68  {
70  }
template<typename GUM_SCALAR >
std::string gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::toString ( ) const
virtual

Definition at line 117 of file O3prmrContext_tpl.h.

References gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::operator+=().

117  {
118  std::string output;
119 
120  if (!m_package.empty()) {
121  output += "package " + m_package + ";\n";
122  output += "\n";
123  }
124 
125  for (auto i = m_imports.begin(); i < m_imports.end(); i++)
126  output += (*i)->toString() + "\n";
127 
128  output += "\n";
129 
130  for (auto i = m_sessions.begin(); i < m_sessions.end(); i++)
131  output += (*i)->toString() + "\n";
132 
133  return output;
134  }
std::vector< O3prmrSession< GUM_SCALAR > * > m_sessions
std::vector< ImportCommand * > m_imports

+ Here is the call graph for this function:

Member Data Documentation

template<typename GUM_SCALAR>
std::string gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::m_filename
private
template<typename GUM_SCALAR>
std::vector< ImportCommand* > gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::m_imports
private

Definition at line 218 of file O3prmrContext.h.

template<typename GUM_SCALAR>
ImportCommand* gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::m_mainImport
private
template<typename GUM_SCALAR>
std::string gum::prm::o3prmr::O3prmrContext< GUM_SCALAR >::m_package
private

Definition at line 216 of file O3prmrContext.h.

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

Definition at line 217 of file O3prmrContext.h.


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