本文整理汇总了C++中Simulator::addDynamics方法的典型用法代码示例。如果您正苦于以下问题:C++ Simulator::addDynamics方法的具体用法?C++ Simulator::addDynamics怎么用?C++ Simulator::addDynamics使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Simulator
的用法示例。
在下文中一共展示了Simulator::addDynamics方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createModel
void ModelFactory::createModel(Coordinator& coordinator,
vpz::AtomicModel* model,
const std::string& dynamics,
const std::vector < std::string >& conditions,
const std::string& observable)
{
const vpz::Dynamic& dyn = mDynamics.get(dynamics);
const SimulatorMap& result(coordinator.modellist());
if (result.find(model) != result.end()) {
throw utils::InternalError(fmt(_(
"The model '%1%' already exist in coordinator")) %
model->getName());
}
Simulator* sim = new Simulator(model);
coordinator.addModel(model, sim);
value::Map initValues;
if (not conditions.empty()) {
for (std::vector < std::string >::const_iterator it =
conditions.begin(); it != conditions.end(); ++it) {
const vpz::Condition& cnd(mExperiment.conditions().get(*it));
value::MapValue vl;
cnd.fillWithFirstValues(vl);
for (value::MapValue::const_iterator itv = vl.begin();
itv != vl.end(); ++itv) {
if (initValues.exist(itv->first)) {
initValues.value().clear();
throw utils::InternalError(fmt(_(
"Multiples condition with the same init port " \
"name '%1%'")) % itv->first);
}
initValues.add(itv->first, itv->second);
}
vl.clear();
}
}
try {
sim->addDynamics(attachDynamics(coordinator, sim, dyn, initValues));
} catch(const std::exception& /*e*/) {
initValues.value().clear();
throw;
}
initValues.value().clear();
if (not observable.empty()) {
vpz::Observable& ob(mExperiment.views().observables().get(observable));
const vpz::ObservablePortList& lst(ob.observableportlist());
for (vpz::ObservablePortList::const_iterator it = lst.begin();
it != lst.end(); ++it) {
const vpz::ViewNameList& vnlst(it->second.viewnamelist());
for (vpz::ViewNameList::const_iterator jt = vnlst.begin();
jt != vnlst.end(); ++jt) {
View* view = coordinator.getView(*jt);
if (not view) {
throw utils::InternalError(fmt(_(
"The view '%1%' is unknow of coordinator "
"view list")) % *jt);
}
view->addObservable(sim, it->first,
coordinator.getCurrentTime());
}
}
}
InternalEvent* evt = sim->init(coordinator.getCurrentTime());
if (evt) {
coordinator.eventtable().putInternalEvent(evt);
}
}