Minsky
minsky::VariablePtr Class Reference

#include <variable.h>

Inheritance diagram for minsky::VariablePtr:
Inheritance graph
Collaboration diagram for minsky::VariablePtr:
Collaboration graph

Public Member Functions

virtual int id () const
 
 VariablePtr (VariableBase::Type type=VariableBase::undefined, const std::string &name="")
 
virtual ~VariablePtr ()
 
template<class P >
 VariablePtr (P *var)
 
 VariablePtr (const classdesc::shared_ptr< VariableBase > &x)
 
 VariablePtr (const VariableBase &x)
 
void retype (VariableBase::Type type)
 changes type of variable to type More...
 
 VariablePtr (const ItemPtr &x)
 
void makeConsistentWithValue ()
 make variable's type consistent with the type of the valueId More...
 

Private Types

typedef classdesc::shared_ptr< VariableBasePtrBase
 

Detailed Description

Definition at line 314 of file variable.h.

Member Typedef Documentation

◆ PtrBase

typedef classdesc::shared_ptr<VariableBase> minsky::VariablePtr::PtrBase
private

Definition at line 317 of file variable.h.

Constructor & Destructor Documentation

◆ VariablePtr() [1/5]

minsky::VariablePtr::VariablePtr ( VariableBase::Type  type = VariableBase::undefined,
const std::string &  name = "" 
)
inline

Definition at line 320 of file variable.h.

321  :
322  PtrBase(VariableBase::create(type)) {get()->name(name);}
static VariableBase * create(Type type)
Definition: variable.cc:116
classdesc::shared_ptr< VariableBase > PtrBase
Definition: variable.h:317

◆ ~VariablePtr()

virtual minsky::VariablePtr::~VariablePtr ( )
inlinevirtual

Definition at line 323 of file variable.h.

323 {}

◆ VariablePtr() [2/5]

template<class P >
minsky::VariablePtr::VariablePtr ( P *  var)
inline

Definition at line 325 of file variable.h.

References minsky::var.

325  : PtrBase(dynamic_cast<VariableBase*>(var))
326  {
327  // check for incorrect type assignment
328  assert(!var || *this);
329  }
classdesc::shared_ptr< VariableBase > PtrBase
Definition: variable.h:317

◆ VariablePtr() [3/5]

minsky::VariablePtr::VariablePtr ( const classdesc::shared_ptr< VariableBase > &  x)
inline

Definition at line 330 of file variable.h.

330 : PtrBase(x) {}
classdesc::shared_ptr< VariableBase > PtrBase
Definition: variable.h:317

◆ VariablePtr() [4/5]

minsky::VariablePtr::VariablePtr ( const VariableBase x)
inline

Definition at line 331 of file variable.h.

331 : PtrBase(x.clone()) {}
classdesc::shared_ptr< VariableBase > PtrBase
Definition: variable.h:317

◆ VariablePtr() [5/5]

minsky::VariablePtr::VariablePtr ( const ItemPtr x)
inline

Definition at line 334 of file variable.h.

334  :
335  PtrBase(std::dynamic_pointer_cast<VariableBase>(x)) {}
classdesc::shared_ptr< VariableBase > PtrBase
Definition: variable.h:317

Member Function Documentation

◆ id()

virtual int minsky::VariablePtr::id ( ) const
inlinevirtual

Definition at line 319 of file variable.h.

319 {return -1;}

◆ makeConsistentWithValue()

void VariablePtr::makeConsistentWithValue ( )

make variable's type consistent with the type of the valueId

Definition at line 883 of file variable.cc.

References minsky::cminsky(), retype(), and minsky::valueId().

884 {
885  retype(minsky::cminsky().variableValues[get()->valueId()]->type());
886 }
void retype(VariableBase::Type type)
changes type of variable to type
Definition: variable.cc:516
string valueId(const string &name)
construct a valueId from fully qualified name @ name should not be canonicalised
Definition: valueId.cc:75
const Minsky & cminsky()
const version to help in const correctness
Definition: minsky.h:549
Here is the call graph for this function:

◆ retype()

void VariablePtr::retype ( VariableBase::Type  type)

changes type of variable to type

Definition at line 516 of file variable.cc.

References minsky::VariableBase::create(), and reset().

Referenced by makeConsistentWithValue(), and minsky::VariableBase::retype().

517 {
518  const VariablePtr tmp(*this);
519  if (tmp && tmp->type()!=type)
520  {
522  static_cast<VariableBase&>(*get()) = *tmp;
523  for (size_t i=0; i<get()->portsSize() && i< tmp->portsSize(); ++i)
524  for (auto w: tmp->ports(i).lock()->wires())
525  {
526  if (get()->ports(i).lock()->input())
527  w->moveToPorts(w->from(), get()->ports(i).lock());
528  else
529  w->moveToPorts(get()->ports(i).lock(), w->to());
530  }
531  get()->ensureValueExists(nullptr,"");
532  }
533 }
reset
Definition: minsky.tcl:1325
static VariableBase * create(Type type)
Definition: variable.cc:116
Here is the call graph for this function:
Here is the caller graph for this function:

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