return boost::static_pointer_cast<Canvas>( getElement(index) );
}
+ //----------------------------------------------------------------------------
+ CanvasPtr CanvasMgr::getCanvas(const std::string& name) const
+ {
+ return boost::static_pointer_cast<Canvas>( getElement(name) );
+ }
+
//----------------------------------------------------------------------------
void CanvasMgr::elementCreated(PropertyBasedElementPtr element)
{
*/
CanvasPtr getCanvas(size_t index) const;
+ /**
+ * Get ::Canvas by name
+ *
+ * @param name Value of child node "name" in
+ * /canvas/by-index/texture[i]/name
+ */
+ CanvasPtr getCanvas(const std::string& name) const;
+
protected:
SystemAdapterPtr _system_adapter;
static naRef makeGhost(naContext c, void *ptr)
{
+ if( !Ghost::getRawPtr(ptr) )
+ return naNil();
+
naGhostType* ghost_type = 0;
if( Ghost::returns_dynamic_type::value )
// For pointer policies already returning instances of an object with
#include "PropertyBasedMgr.hxx"
+#include <boost/foreach.hpp>
+
#include <stdexcept>
#include <string>
return _elements[index];
}
+ //----------------------------------------------------------------------------
+ PropertyBasedElementPtr
+ PropertyBasedMgr::getElement(const std::string& name) const
+ {
+ if( name.empty() )
+ return PropertyBasedElementPtr();
+
+ BOOST_FOREACH(PropertyBasedElementPtr el, _elements)
+ if( el->getProps()->getStringValue("name") == name )
+ return el;
+
+ return PropertyBasedElementPtr();
+ }
+
//----------------------------------------------------------------------------
const SGPropertyNode* PropertyBasedMgr::getPropertyRoot() const
{
*/
PropertyBasedElementPtr getElement(size_t index) const;
+ /**
+ * Get an existing PropertyBasedElement by its name
+ *
+ * @param name Name (value of child node "name" will be matched)
+ */
+ PropertyBasedElementPtr getElement(const std::string& name) const;
+
virtual const SGPropertyNode* getPropertyRoot() const;
protected: