本文整理汇总了C++中Link::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Link::clear方法的具体用法?C++ Link::clear怎么用?C++ Link::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Link
的用法示例。
在下文中一共展示了Link::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeLink
/**
* Remove a Link.
*/
void LinkMaster::removeLink(int id)
{
Link* linkPtr = &link(id);
int atom0Id;
int atom1Id;
if (!link(id).isActive()) {
UTIL_THROW("Attempt to remove a nonactive link");
}
atom0Id = linkPtr->atom0().id();
atom1Id = linkPtr->atom1().id();
// Remove link from atom0 and atom1 link sets
if (!atomLinkSets_[atom0Id].isElement(*linkPtr)) {
UTIL_THROW("Link is not in atomLinkSets of atom0");
}
if (!atomLinkSets_[atom1Id].isElement(*linkPtr)) {
UTIL_THROW("Link is not in atomLinkSets of atom1");
}
atomLinkSets_[atom0Id].remove(*linkPtr);
atomLinkSets_[atom1Id].remove(*linkPtr);
// Notify observers of removal of this Link.
// Notify before clearing Link so atomPtrs and typeId are available.
LinkRemoveEvent event(linkPtr);
Notifier<LinkRemoveEvent>::notifyObservers(event);
// Clear the link: nullify atomPtrs, set typeId = -1, isActive = false
linkPtr->clear();
// Return link to reservoir
linkSet_.remove(*linkPtr);
reservoir_.push(*linkPtr);
}
示例2: parseLink
bool parseLink(Link &link, TiXmlElement* config)
{
link.clear();
const char *name_char = config->Attribute("name");
if (!name_char)
{
logError("No name given for the link.");
return false;
}
link.name = std::string(name_char);
// Inertial (optional)
TiXmlElement *i = config->FirstChildElement("inertial");
if (i)
{
resetPtr(link.inertial,new Inertial());
if (!parseInertial(*link.inertial, i))
{
logError("Could not parse inertial element for Link [%s]", link.name.c_str());
return false;
}
}
// Multiple Visuals (optional)
for (TiXmlElement* vis_xml = config->FirstChildElement("visual"); vis_xml; vis_xml = vis_xml->NextSiblingElement("visual"))
{
VisualPtr vis;
resetPtr(vis,new Visual());
if (parseVisual(*vis, vis_xml))
{
link.visual_array.push_back(vis);
}
else
{
resetPtr(vis);
logError("Could not parse visual element for Link [%s]", link.name.c_str());
return false;
}
}
// Visual (optional)
// Assign the first visual to the .visual ptr, if it exists
if (!link.visual_array.empty())
link.visual = link.visual_array[0];
// Multiple Collisions (optional)
for (TiXmlElement* col_xml = config->FirstChildElement("collision"); col_xml; col_xml = col_xml->NextSiblingElement("collision"))
{
CollisionPtr col;
resetPtr(col,new Collision());
if (parseCollision(*col, col_xml))
{
link.collision_array.push_back(col);
}
else
{
resetPtr(col);
logError("Could not parse collision element for Link [%s]", link.name.c_str());
return false;
}
}
// Collision (optional)
// Assign the first collision to the .collision ptr, if it exists
if (!link.collision_array.empty())
link.collision = link.collision_array[0];
}