Minsky
schema3::MinskyItemFactory Struct Reference
Inheritance diagram for schema3::MinskyItemFactory:
Inheritance graph
Collaboration diagram for schema3::MinskyItemFactory:
Collaboration graph

Public Member Functions

template<class T >
void registerClassType ()
 
 MinskyItemFactory ()
 
minsky::Itemcreate (const string &t) const
 

Detailed Description

Definition at line 213 of file schema3.cc.

Constructor & Destructor Documentation

◆ MinskyItemFactory()

schema3::MinskyItemFactory::MinskyItemFactory ( )
inline

Definition at line 225 of file schema3.cc.

226  {
227  registerClassType<minsky::Item>();
228  registerClassType<minsky::IntOp>();
229  registerClassType<minsky::DataOp>();
230  registerClassType<minsky::UserFunction>();
231  registerClassType<minsky::Ravel>();
232  registerClassType<minsky::Lock>();
233  registerClassType<minsky::Sheet>();
234  registerClassType<minsky::VarConstant>();
235  registerClassType<minsky::GodleyIcon>();
236  registerClassType<minsky::PlotWidget>();
237  registerClassType<minsky::SwitchIcon>();
238  }

Member Function Documentation

◆ create()

minsky::Item* schema3::MinskyItemFactory::create ( const string &  t) const
inline

Definition at line 241 of file schema3.cc.

References minsky::OperationType::correlation, minsky::OperationBase::create(), minsky::VariableBase::create(), and schema3::anonymous_namespace{schema3.cc}::matchesStart().

242  {
243  if (t=="Operation:rho") // handle legacy names after operation rename
245  if (matchesStart(t,"Operation:"))
247  (enum_keys<minsky::OperationType::Type>()
248  (t.substr(t.find(':')+1)));
249  if (matchesStart(t,"Variable:"))
251  (enum_keys<minsky::VariableType::Type>()
252  (t.substr(t.find(':')+1)));
253  try
254  {
255  return classdesc::Factory<minsky::Item,string>::create("::minsky::"+t);
256  }
257  catch (...)
258  {
259  assert(!"item type not registered");
260  return nullptr;
261  }
262  }
static VariableBase * create(Type type)
Definition: variable.cc:116
static OperationBase * create(Type type)
factory method.
Definition: operation.cc:545
bool matchesStart(const string &x, const string &y)
Definition: schema3.cc:206
Here is the call graph for this function:

◆ registerClassType()

template<class T >
void schema3::MinskyItemFactory::registerClassType ( )
inline

Definition at line 216 of file schema3.cc.

216  {
217  auto s=typeName<T>();
218  // remove minsky namespace
219  static const char* ns="minsky::";
220  static const int eop=strlen(ns);
221  if (s.substr(0,eop)==ns)
222  s=s.substr(eop);
223  registerType<T>(s);
224  }

The documentation for this struct was generated from the following file: