Minsky: 3.17.0
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 302 of file variable.h.

Member Typedef Documentation

◆ PtrBase

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

Definition at line 305 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 308 of file variable.h.

309  :
310  PtrBase(VariableBase::create(type)) {get()->name(name);}
static VariableBase * create(Type type)
Definition: variable.cc:101
classdesc::shared_ptr< VariableBase > PtrBase
Definition: variable.h:305

◆ ~VariablePtr()

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

Definition at line 311 of file variable.h.

311 {}

◆ VariablePtr() [2/5]

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

Definition at line 313 of file variable.h.

References minsky::var.

313  : PtrBase(dynamic_cast<VariableBase*>(var))
314  {
315  // check for incorrect type assignment
316  assert(!var || *this);
317  }
classdesc::shared_ptr< VariableBase > PtrBase
Definition: variable.h:305

◆ VariablePtr() [3/5]

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

Definition at line 318 of file variable.h.

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

◆ VariablePtr() [4/5]

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

Definition at line 319 of file variable.h.

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

◆ VariablePtr() [5/5]

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

Definition at line 322 of file variable.h.

322  :
323  PtrBase(std::dynamic_pointer_cast<VariableBase>(x)) {}
classdesc::shared_ptr< VariableBase > PtrBase
Definition: variable.h:305

Member Function Documentation

◆ id()

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

Definition at line 307 of file variable.h.

307 {return -1;}

◆ makeConsistentWithValue()

void VariablePtr::makeConsistentWithValue ( )

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

Definition at line 877 of file variable.cc.

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

878 {
879  retype(minsky::cminsky().variableValues[get()->valueId()]->type());
880 }
void retype(VariableBase::Type type)
changes type of variable to type
Definition: variable.cc:510
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:538
Here is the call graph for this function:

◆ retype()

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

changes type of variable to type

Definition at line 510 of file variable.cc.

Referenced by minsky::VariableBase::retype().

511 {
512  const VariablePtr tmp(*this);
513  if (tmp && tmp->type()!=type)
514  {
515  reset(VariableBase::create(type));
516  static_cast<VariableBase&>(*get()) = *tmp;
517  for (size_t i=0; i<get()->portsSize() && i< tmp->portsSize(); ++i)
518  for (auto w: tmp->ports(i).lock()->wires())
519  {
520  if (get()->ports(i).lock()->input())
521  w->moveToPorts(w->from(), get()->ports(i).lock());
522  else
523  w->moveToPorts(get()->ports(i).lock(), w->to());
524  }
525  get()->ensureValueExists(nullptr,"");
526  }
527 }
static VariableBase * create(Type type)
Definition: variable.cc:101
Here is the caller graph for this function:

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