Minsky
schema3::PhillipsDiagram Struct Reference

#include <schema3.h>

Collaboration diagram for schema3::PhillipsDiagram:
Collaboration graph

Public Member Functions

 PhillipsDiagram ()=default
 
 PhillipsDiagram (const minsky::PhillipsDiagram &)
 
void populatePhillipsDiagram (minsky::PhillipsDiagram &) const
 populate a Phillips Diagram from this More...
 

Public Attributes

std::vector< Itemstocks
 
std::vector< PhillipsFlowflows
 

Detailed Description

Definition at line 225 of file schema3.h.

Constructor & Destructor Documentation

◆ PhillipsDiagram() [1/2]

schema3::PhillipsDiagram::PhillipsDiagram ( )
default

◆ PhillipsDiagram() [2/2]

schema3::PhillipsDiagram::PhillipsDiagram ( const minsky::PhillipsDiagram pd)

Definition at line 411 of file schema3.cc.

References schema3::IdMap::emplaceIf(), minsky::PhillipsDiagram::flows, and minsky::PhillipsDiagram::stocks.

412  {
413  IdMap itemMap;
414  for (auto& [key,stock]: pd.stocks)
415  itemMap.emplaceIf<minsky::VariableBase>(stocks, &stock);
416 
417  for (auto& [key,flow]: pd.flows)
418  {
419  flows.emplace_back(itemMap[&flow], flow);
420  assert(itemMap.count(flow.from().get()) && itemMap.count(flow.to().get()));
421  flows.back().from=itemMap[flow.from().get()];
422  flows.back().to=itemMap[flow.to().get()];
423  for (auto& term: flow.terms)
424  flows.back().terms.emplace_back(term.first, Item(-1,term.second,{}));
425  }
426  }
std::vector< Item > stocks
Definition: schema3.h:227
std::vector< PhillipsFlow > flows
Definition: schema3.h:228
std::map< std::pair< std::string, std::string >, PhillipsFlow > flows
std::map< std::string, PhillipsStock > stocks
Here is the call graph for this function:

Member Function Documentation

◆ populatePhillipsDiagram()

void schema3::PhillipsDiagram::populatePhillipsDiagram ( minsky::PhillipsDiagram pd) const

populate a Phillips Diagram from this

Definition at line 850 of file schema3.cc.

References minsky::PhillipsDiagram::flows, schema1::itemFactory, minsky::PhillipsStock::numPorts(), schema3::populateItem(), schema3::populateWire(), minsky::PhillipsDiagram::stocks, and minsky::VariableBase::valueId().

Referenced by minsky::Minsky::undo().

851  {
852  static const MinskyItemFactory itemFactory;
853  map<int, weak_ptr<minsky::Port>> portMap;
854  for (auto& i: stocks)
855  {
856  minsky::PhillipsStock stock;
857  populateItem(stock, i);
858  auto& item=pd.stocks[stock.valueId()]=stock;
859  for (size_t j=0; j<std::min(i.ports.size(), stock.numPorts()); ++j)
860  portMap[i.ports[j]]=item.ports(j);
861  }
862 
863  for (auto& i: flows)
864  {
865  assert(portMap[i.from].lock() && portMap[i.to].lock());
866  minsky::PhillipsFlow flow(portMap[i.from],portMap[i.to]);
867  populateWire(flow, i);
868  for (auto& j: i.terms)
869  {
870  flow.terms.emplace_back(j.first, minsky::FlowVar{});
871  populateItem(flow.terms.back().second, j.second);
872  }
873  auto fromId=flow.from()->item().variableCast()->valueId();
874  auto toId=flow.to()->item().variableCast()->valueId();
875  auto success=pd.flows.emplace(make_pair(fromId, toId), flow).second; //NOLINT
876  assert(success);
877  }
878  }
std::size_t numPorts() const override
void populateWire(minsky::Wire &x, const Wire &y)
Definition: schema3.cc:598
std::vector< Item > stocks
Definition: schema3.h:227
std::vector< PhillipsFlow > flows
Definition: schema3.h:228
virtual std::string valueId() const
string used to link to the VariableValue associated with this
Definition: variable.cc:186
std::map< std::pair< std::string, std::string >, PhillipsFlow > flows
std::map< std::string, PhillipsStock > stocks
ItemFactory itemFactory
Definition: schema1.cc:176
void populateItem(minsky::Item &x, const Item &y)
Definition: schema3.cc:475
virtual std::weak_ptr< Port > ports(std::size_t i) const
callback to be run when item deleted from group
Definition: item.h:180
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ flows

std::vector<PhillipsFlow> schema3::PhillipsDiagram::flows

Definition at line 228 of file schema3.h.

◆ stocks

std::vector<Item> schema3::PhillipsDiagram::stocks

Definition at line 227 of file schema3.h.


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