Get Canvas/PropertyBasedElement by name
This commit is contained in:
parent
2aed93a576
commit
904d714d6d
@ -55,6 +55,12 @@ namespace canvas
|
||||
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)
|
||||
{
|
||||
|
@ -55,6 +55,14 @@ namespace canvas
|
||||
*/
|
||||
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;
|
||||
|
@ -655,6 +655,9 @@ namespace nasal
|
||||
|
||||
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
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include "PropertyBasedMgr.hxx"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
@ -65,6 +67,20 @@ namespace simgear
|
||||
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
|
||||
{
|
||||
|
@ -53,6 +53,13 @@ namespace simgear
|
||||
*/
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user