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

◆ Attribute

Enumerator
SUB_ITEM 
TEMPORAL 
LOAD_ONLY 
NUM_ATTRIBUTES 

Constructor & Destructor Documentation

◆ Item() [1/2]

Item::Item ( )
protected

◆ Item() [2/2]

Item::Item ( const Item item)
protected

◆ ~Item()

Item::~Item ( )
virtual

Member Function Documentation

◆ addChildItem()

bool Item::addChildItem ( Item item,
bool  isManualOperation = false 
)

◆ addSubItem()

bool Item::addSubItem ( Item item)

◆ assign()

void Item::assign ( Item srcItem)

Copy item properties as much as possible like the assignment operator

◆ childItem()

Item* cnoid::Item::childItem ( ) const
inline

◆ clearCustomData()

void Item::clearCustomData ( int  id)

◆ clearFileInformation()

void Item::clearFileInformation ( )

Use this function to disable the implicit overwrite next time

◆ customData() [1/2]

Referenced * Item::customData ( int  id)

◆ customData() [2/2]

const Referenced * Item::customData ( int  id) const

◆ detachFromParentItem()

void Item::detachFromParentItem ( )

◆ doAssign()

void Item::doAssign ( Item srcItem)
protectedvirtual

Implement the code to copy properties like the assingment operator

Reimplemented in cnoid::BodyItem.

◆ doDuplicate()

Item * Item::doDuplicate ( ) const
protectedvirtual

◆ doPutProperties()

void Item::doPutProperties ( PutPropertyFunction putProperty)
protectedvirtual

◆ duplicate()

Item * Item::duplicate ( ) const

◆ duplicateAll()

Item * Item::duplicateAll ( ) const

◆ emitSigDetachedFromRootForSubTree()

void Item::emitSigDetachedFromRootForSubTree ( )

◆ fileFormat()

const std::string& cnoid::Item::fileFormat ( ) const
inline

◆ fileModificationTime()

std::time_t cnoid::Item::fileModificationTime ( ) const
inline

◆ filePath()

const std::string& cnoid::Item::filePath ( ) const
inline

◆ find() [1/2]

Item * Item::find ( const std::string &  path)
static

◆ find() [2/2]

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

◆ findChildItem() [1/2]

Item * Item::findChildItem ( const std::string &  path) const

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

◆ findChildItem() [2/2]

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

◆ findItem() [1/2]

Item * Item::findItem ( const std::string &  path) const

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

◆ findItem() [2/2]

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

◆ findOwnerItem()

template<class ItemType >
ItemType* cnoid::Item::findOwnerItem ( bool  includeSelf = false)
inline

◆ findRootItem()

RootItem * Item::findRootItem ( ) const

◆ findSubItem() [1/2]

Item * Item::findSubItem ( const std::string &  path) const

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

◆ findSubItem() [2/2]

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

◆ hasAttribute()

bool cnoid::Item::hasAttribute ( Attribute  attribute) const
inline

◆ headItem()

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.

◆ insertChildItem()

bool Item::insertChildItem ( Item item,
Item nextItem,
bool  isManualOperation = false 
)

◆ insertSubItem()

bool Item::insertSubItem ( Item item,
Item nextItem 
)

◆ isConsistentWithFile()

bool cnoid::Item::isConsistentWithFile ( ) const
inline

◆ isOwnedBy()

bool Item::isOwnedBy ( Item item) const

◆ isSubItem()

bool Item::isSubItem ( ) const

◆ isTemporal()

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.

◆ load() [1/2]

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.

◆ load() [2/2]

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.

◆ name()

const std::string& cnoid::Item::name ( ) const
inline

◆ nextItem()

Item* cnoid::Item::nextItem ( ) const
inline

◆ notifyUpdate()

void Item::notifyUpdate ( )
virtual

◆ onChildItemAboutToBeAdded()

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.

◆ onConnectedToRoot()

void Item::onConnectedToRoot ( )
protectedvirtual

◆ onDisconnectedFromRoot()

void Item::onDisconnectedFromRoot ( )
protectedvirtual

◆ onPositionChanged()

void Item::onPositionChanged ( )
protectedvirtual

◆ overwrite()

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.

◆ parentItem()

Item* cnoid::Item::parentItem ( ) const
inline

◆ prevItem()

Item* cnoid::Item::prevItem ( ) const
inline

◆ putProperties()

void Item::putProperties ( PutPropertyFunction putProperty)

◆ restore()

bool Item::restore ( const Archive archive)
virtual

◆ save()

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.

◆ setAttribute()

void cnoid::Item::setAttribute ( Attribute  attribute)
inlineprotected

◆ setCustomData()

void Item::setCustomData ( int  id,
ReferencedPtr  data 
)

◆ setName()

void Item::setName ( const std::string &  name)
virtual

◆ setTemporal()

void Item::setTemporal ( bool  on = true)

◆ sigClassUnregistered()

static SignalProxy<void(const char* type_info_name)> cnoid::Item::sigClassUnregistered ( )
inlinestatic

◆ sigDetachedFromRoot()

SignalProxy<void()> cnoid::Item::sigDetachedFromRoot ( )
inline
Note
obsolete.

◆ sigDisconnectedFromRoot()

SignalProxy<void()> cnoid::Item::sigDisconnectedFromRoot ( )
inline
Note
Please use this instead of sigDetachedFromRoot()

◆ sigNameChanged()

SignalProxy<void(const std::string& oldName)> cnoid::Item::sigNameChanged ( )
inline

◆ sigPositionChanged()

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();

◆ sigSubTreeChanged()

SignalProxy<void()> cnoid::Item::sigSubTreeChanged ( )
inline

◆ sigUpdated()

SignalProxy<void()> cnoid::Item::sigUpdated ( )
inline
Todo:
Remove this signal and define 'sigPropertyChanged' instead of it

◆ store()

bool Item::store ( Archive archive)
virtual

◆ suggestFileUpdate()

void cnoid::Item::suggestFileUpdate ( )
inline

◆ traverse() [1/2]

bool Item::traverse ( boost::function< bool(Item *)>  function)

◆ traverse() [2/2]

template<class ItemType >
bool cnoid::Item::traverse ( boost::function< bool(ItemType *item)>  function)
inline

◆ unsetAttribute()

void cnoid::Item::unsetAttribute ( Attribute  attribute)
inlineprotected

Friends And Related Function Documentation

◆ ItemManagerImpl

friend class ItemManagerImpl
friend

◆ ItemTreeArchiver

friend class ItemTreeArchiver
friend

◆ RootItem

friend class RootItem
friend

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