本文整理汇总了C++中NodePtr::createPort方法的典型用法代码示例。如果您正苦于以下问题:C++ NodePtr::createPort方法的具体用法?C++ NodePtr::createPort怎么用?C++ NodePtr::createPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodePtr
的用法示例。
在下文中一共展示了NodePtr::createPort方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
Architecture::ToAddToRemove Architecture::load(const Json::Value& json,
bool clearFirst,
bool recreateUUIDs,
bool metadata) {
set<NodePtr> newnodes;
set<ConnectionPtr> newconnections;
set<NodePtr> killednodes;
set<ConnectionPtr> killedconnections;
auto version = json.get("encoding_version", "<undefined>").asString();
DEBUG("Reading the architecture (encoding: v." << version << ")..."
<< endl);
if(metadata) {
name = json.get("name", "<no name>").asString();
version = json.get("version", "0.1").asString();
description = json.get("description", "(no description yet)").asString();
if(!recreateUUIDs) {
uuid = get_uuid(json["uuid"].asString(), "Architecture");
}
}
set<boost::uuids::uuid> existing_uuids;
if (clearFirst) {
killednodes = _nodes;
killedconnections = _connections;
_nodes.clear();
_connections.clear();
}
for (auto n : _nodes) {
existing_uuids.insert(n->uuid);
}
for (auto c : _connections) {
existing_uuids.insert(c->uuid);
}
//////////////////////////////////////////
///// NODES
//////////////////////////////////////////
for (auto n : json["nodes"]) {
auto uuid = get_uuid(n["uuid"].asString(), "Node");
NodePtr node;
if (!recreateUUIDs && existing_uuids.count(uuid)) {
cerr << "Already existing UUID <" << uuid << ">! ";
cerr << "Skipping this node." << endl;
continue;
}
if (!recreateUUIDs) {
node = createNode(uuid);
} else {
node = createNode();
}
DEBUG("Adding node <" << n["name"].asString() << ">" << endl);
node->cognitive_function(get_cognitive_function_by_name(
n.get("cognitive_function", "").asString()));
if (n.isMember("position")) {
node->x(n["position"][0].asDouble());
node->y(n["position"][1].asDouble());
}
for (auto p : n["ports"]) {
Port::Type type;
if (p["type"].asString() == "latent")
type = Port::Type::LATENT;
else if (p["type"].asString() == "explicit")
type = Port::Type::EXPLICIT;
else
type = Port::Type::OTHER;
node->createPort({p["name"].asString(),
p["direction"].asString() == "in"
? Port::Direction::IN
: Port::Direction::OUT,
type
});
}
node->name(n["name"].asString());
newnodes.insert(node);
}
//////////////////////////////////////////
///// CONNECTIONS
//////////////////////////////////////////
for (auto c : json["connections"]) {
auto uuid = get_uuid(c["uuid"].asString(), "Connection");
if (!recreateUUIDs && existing_uuids.count(uuid)) {
cerr << "Already existing UUID <" << uuid << ">! ";
cerr << "Skipping this connection." << endl;
continue;
//.........这里部分代码省略.........