);
}
+ //----------------------------------------------------------------------------
+ GroupPtr Canvas::getGroup(const std::string& name)
+ {
+ return boost::dynamic_pointer_cast<Group>
+ (
+ _root_group->getChild(name)
+ );
+ }
+
//----------------------------------------------------------------------------
GroupPtr Canvas::getRootGroup()
{
void removeChildCanvas(const CanvasWeakPtr& canvas);
GroupPtr createGroup(const std::string& name = "");
+ GroupPtr getGroup(const std::string& name);
GroupPtr getRootGroup();
/**
return child->second;
}
+ //----------------------------------------------------------------------------
+ ElementPtr Group::getChild(const std::string& id)
+ {
+ for( ChildList::iterator child = _children.begin();
+ child != _children.end();
+ ++child )
+ {
+ if( child->second->get<std::string>("id") == id )
+ return child->second;
+ }
+
+ return ElementPtr();
+ }
+
//----------------------------------------------------------------------------
ElementPtr Group::getElementById(const std::string& id)
{
ElementPtr createChild( const std::string& type,
const std::string& id = "" );
ElementPtr getChild(const SGPropertyNode* node);
+ ElementPtr getChild(const std::string& id);
/**
* Get first child with given id (breadth-first search)
setValue(_node->getNode(name, true), val);
}
+ template<class T>
+ T get( const std::string& name,
+ typename boost::call_traits<T>::param_type def = T() )
+ {
+ SGPropertyNode const* child = _node->getNode(name);
+ if( !child )
+ return def;
+
+ return getValue<T>(child);
+ }
+
virtual void setSelf(const PropertyBasedElementPtr& self);
protected:
return node->getStringValue ();
}
+template<>
+inline std::string getValue<std::string>(const SGPropertyNode* node)
+{
+ return node->getStringValue();
+}
+
inline bool setValue(SGPropertyNode* node, bool value)
{
return node->setBoolValue(value);