Choreonoid  1.5
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
cnoid::Item Class Reference

#include <Item.h>

Inheritance diagram for cnoid::Item:
cnoid::Referenced cnoid::AbstractSeqItem cnoid::AbstractTextItem cnoid::AudioItem cnoid::BodyItem cnoid::BodyTrackingCameraItem cnoid::ControllerItem cnoid::ExtCommandItem cnoid::FolderItem cnoid::MediaItem cnoid::MultiPointSetItem cnoid::OpenHRPInterpreterServiceItem cnoid::OpenHRPOnlineViewerItem cnoid::PointSetItem cnoid::PoseSeqItem cnoid::RootItem cnoid::RTCItem cnoid::SceneItem cnoid::SensorVisualizerItem cnoid::SimulatorItem cnoid::SubSimulatorItem cnoid::WorldItem cnoid::WorldLogFileItem

Public Types

enum  Attribute { SUB_ITEM, TEMPORAL, LOAD_ONLY, NUM_ATTRIBUTES }
 

Public Member Functions

virtual ~Item ()
 
const std::string & name () const
 
virtual void setName (const std::string &name)
 
bool hasAttribute (Attribute attribute) const
 
ItemchildItem () const
 
ItemprevItem () const
 
ItemnextItem () const
 
ItemparentItem () const
 
bool addChildItem (Item *item, bool isManualOperation=false)
 
bool addSubItem (Item *item)
 
bool isSubItem () const
 
void detachFromParentItem ()
 
void emitSigDetachedFromRootForSubTree ()
 
bool insertChildItem (Item *item, Item *nextItem, bool isManualOperation=false)
 
bool insertSubItem (Item *item, Item *nextItem)
 
bool isTemporal () const
 
void setTemporal (bool on=true)
 
RootItemfindRootItem () const
 
ItemfindItem (const std::string &path) const
 
template<class ItemType >
ItemType * findItem (const std::string &path) const
 
template<class ItemType >
ItemType * find (const std::string &path)
 
ItemfindChildItem (const std::string &path) const
 
template<class ItemType >
ItemType * findChildItem (const std::string &path) const
 
ItemfindSubItem (const std::string &path) const
 
template<class ItemType >
ItemType * findSubItem (const std::string &path) const
 
ItemheadItem () const
 
template<class ItemType >
ItemType * findOwnerItem (bool includeSelf=false)
 
bool isOwnedBy (Item *item) const
 
bool traverse (boost::function< bool(Item *)> function)
 
template<class ItemType >
bool traverse (boost::function< bool(ItemType *item)> function)
 
Itemduplicate () const
 
ItemduplicateAll () const
 
void assign (Item *srcItem)
 
bool load (const std::string &filename, const std::string &format=std::string())
 
bool load (const std::string &filename, Item *parent, const std::string &format=std::string())
 
bool save (const std::string &filename, const std::string &format=std::string())
 
bool overwrite (bool forceOverwrite=false, const std::string &format=std::string())
 
const std::string & filePath () const
 
const std::string & fileFormat () const
 
std::time_t fileModificationTime () const
 
bool isConsistentWithFile () const
 
void clearFileInformation ()
 
void suggestFileUpdate ()
 
void putProperties (PutPropertyFunction &putProperty)
 
virtual void notifyUpdate ()
 
SignalProxy< void(const std::string &oldName)> sigNameChanged ()
 
SignalProxy< void()> sigUpdated ()
 
SignalProxy< void()> sigPositionChanged ()
 
SignalProxy< void()> sigDetachedFromRoot ()
 
SignalProxy< void()> sigDisconnectedFromRoot ()
 
SignalProxy< void()> sigSubTreeChanged ()
 
virtual bool store (Archive &archive)
 
virtual bool restore (const Archive &archive)
 
ReferencedcustomData (int id)
 
const ReferencedcustomData (int id) const
 
void setCustomData (int id, ReferencedPtr data)
 
void clearCustomData (int id)
 
- Public Member Functions inherited from cnoid::Referenced
virtual ~Referenced ()
 
void addRef ()
 
void releaseRef ()
 

Static Public Member Functions

static Itemfind (const std::string &path)
 
static SignalProxy< void(const char *type_info_name)> sigClassUnregistered ()
 

Protected Member Functions

 Item ()
 
 Item (const Item &item)
 
virtual void onConnectedToRoot ()
 
virtual void onDisconnectedFromRoot ()
 
virtual void onPositionChanged ()
 
virtual bool onChildItemAboutToBeAdded (Item *childItem, bool isManualOperation)
 
virtual ItemdoDuplicate () const
 
virtual void doAssign (Item *srcItem)
 
virtual void doPutProperties (PutPropertyFunction &putProperty)
 
void setAttribute (Attribute attribute)
 
void unsetAttribute (Attribute attribute)
 
- Protected Member Functions inherited from cnoid::Referenced
 Referenced ()
 
 Referenced (const Referenced &org)
 
int refCount () const
 

Friends

class RootItem
 
class ItemTreeArchiver
 
class ItemManagerImpl
 

Member Enumeration Documentation

Enumerator
SUB_ITEM 
TEMPORAL 
LOAD_ONLY 
NUM_ATTRIBUTES 

Constructor & Destructor Documentation

Item::Item ( )
protected
Item::Item ( const Item item)
protected
Item::~Item ( )
virtual

Member Function Documentation

bool Item::addChildItem ( Item item,
bool  isManualOperation = false 
)
bool Item::addSubItem ( Item item)
void Item::assign ( Item srcItem)

Copy item properties as much as possible like the assignment operator

Item* cnoid::Item::childItem ( ) const
inline
void Item::clearCustomData ( int  id)
void Item::clearFileInformation ( )

Use this function to disable the implicit overwrite next time

Referenced * Item::customData ( int  id)
const Referenced * Item::customData ( int  id) const
void Item::detachFromParentItem ( )
void Item::doAssign ( Item srcItem)
protectedvirtual

Implement the code to copy properties like the assingment operator

Reimplemented in cnoid::BodyItem.

Item * Item::doDuplicate ( ) const
protectedvirtual
void Item::doPutProperties ( PutPropertyFunction putProperty)
protectedvirtual
Item * Item::duplicate ( ) const
Item * Item::duplicateAll ( ) const
void Item::emitSigDetachedFromRootForSubTree ( )
const std::string& cnoid::Item::fileFormat ( ) const
inline
std::time_t cnoid::Item::fileModificationTime ( ) const
inline
const std::string& cnoid::Item::filePath ( ) const
inline
Item * Item::find ( const std::string &  path)
static
template<class ItemType >
ItemType* cnoid::Item::find ( const std::string &  path)
inline
Item * Item::findChildItem ( const std::string &  path) const

Find an item that has the corresponding path from a child item to it

template<class ItemType >
ItemType* cnoid::Item::findChildItem ( const std::string &  path) const
inline
Item * Item::findItem ( const std::string &  path) const

Find an item that has the corresponding path to it in the sub tree

template<class ItemType >
ItemType* cnoid::Item::findItem ( const std::string &  path) const
inline
template<class ItemType >
ItemType* cnoid::Item::findOwnerItem ( bool  includeSelf = false)
inline
RootItem * Item::findRootItem ( ) const
Item * Item::findSubItem ( const std::string &  path) const

Find a sub item that has the corresponding path from a direct sub item to it

template<class ItemType >
ItemType* cnoid::Item::findSubItem ( const std::string &  path) const
inline
bool cnoid::Item::hasAttribute ( Attribute  attribute) const
inline
Item * Item::headItem ( ) const
Returns
When the item is embeded one, this function returs the first parent item which is not an embeded one. Otherwise the item itself is returned.
bool Item::insertChildItem ( Item item,
Item nextItem,
bool  isManualOperation = false 
)
bool Item::insertSubItem ( Item item,
Item nextItem 
)
bool cnoid::Item::isConsistentWithFile ( ) const
inline
bool Item::isOwnedBy ( Item item) const
bool Item::isSubItem ( ) const
bool Item::isTemporal ( ) const

If this is true, the item is not automatically saved or overwritten when a project is saved. For example, a motion item which is produced as a simulation result may be an temporal item because a user may not want to save the result. If a user manually save the item, the item becomes a non-temporal item. Or if a child item is manually attached to a temporal item, the item becomes non-temporal one, too.

bool Item::load ( const std::string &  filename,
const std::string &  format = std::string() 
)

This function loads the data of the item from a file by using a pre-registered loading function.

To make this function available, a loading function has to be registered to an ItemManager in advance by calling the addLoader() or addLoaderAndSaver() function. Otherwise, this function cannot be used. Note that this function should not be overloaded or overridden in the derived classes.

bool Item::load ( const std::string &  filename,
Item parent,
const std::string &  format = std::string() 
)
Parameters
parentItemspecify this when the item is newly created one and will be attached to a parent item if loading succeeds.
const std::string& cnoid::Item::name ( ) const
inline
Item* cnoid::Item::nextItem ( ) const
inline
void Item::notifyUpdate ( )
virtual
bool Item::onChildItemAboutToBeAdded ( Item childItem,
bool  isManualOperation 
)
protectedvirtual

This function is called when a child item is about to added to this item.

Returns
false if the item cannot be accepted as a child item
Note
The childItem is not actually connected to the item when this function is called.

Reimplemented in cnoid::BodyMotionItem.

void Item::onConnectedToRoot ( )
protectedvirtual
void Item::onDisconnectedFromRoot ( )
protectedvirtual
void Item::onPositionChanged ( )
protectedvirtual
bool Item::overwrite ( bool  forceOverwrite = false,
const std::string &  format = std::string() 
)

This function save the data of the item to the file from which the data of the item has been loaded.

If the data has not been loaded from a file, a file save dialog opens and user specifies a file.

Item* cnoid::Item::parentItem ( ) const
inline
Item* cnoid::Item::prevItem ( ) const
inline
void Item::putProperties ( PutPropertyFunction putProperty)
bool Item::restore ( const Archive archive)
virtual
bool Item::save ( const std::string &  filename,
const std::string &  format = std::string() 
)

This function saves the data of the item to a file by using a pre-registered saving function.

To make this function available, a saving function has to be registered to an ItemManager in advance by calling the addSaver() or addLoaderAndSaver() function. Otherwise, this function cannot be used. Note that this function should not be overloaded or overridden in the derived classes.

void cnoid::Item::setAttribute ( Attribute  attribute)
inlineprotected
void Item::setCustomData ( int  id,
ReferencedPtr  data 
)
void Item::setName ( const std::string &  name)
virtual
void Item::setTemporal ( bool  on = true)
static SignalProxy<void(const char* type_info_name)> cnoid::Item::sigClassUnregistered ( )
inlinestatic
SignalProxy<void()> cnoid::Item::sigDetachedFromRoot ( )
inline
Note
obsolete.
SignalProxy<void()> cnoid::Item::sigDisconnectedFromRoot ( )
inline
Note
Please use this instead of sigDetachedFromRoot()
SignalProxy<void(const std::string& oldName)> cnoid::Item::sigNameChanged ( )
inline
SignalProxy<void()> cnoid::Item::sigPositionChanged ( )
inline

This signal is emitted when the position of this item in the item tree is changed. Being added to the tree and being removed from the tree are also the events to emit this signal. This signal is also emitted for descendent items when the position of an ancestor item is changed. This signal is emitted before RootItem::sigTreeChanged();

SignalProxy<void()> cnoid::Item::sigSubTreeChanged ( )
inline
SignalProxy<void()> cnoid::Item::sigUpdated ( )
inline
Todo:
Remove this signal and define 'sigPropertyChanged' instead of it
bool Item::store ( Archive archive)
virtual
void cnoid::Item::suggestFileUpdate ( )
inline
bool Item::traverse ( boost::function< bool(Item *)>  function)
template<class ItemType >
bool cnoid::Item::traverse ( boost::function< bool(ItemType *item)>  function)
inline
void cnoid::Item::unsetAttribute ( Attribute  attribute)
inlineprotected

Friends And Related Function Documentation

friend class ItemManagerImpl
friend
friend class ItemTreeArchiver
friend
friend class RootItem
friend

The documentation for this class was generated from the following files: