You.i Engine
CYINodeAdapter Class Referenceabstract

Detailed Description

Provides an interface for supplying and reclaiming nodes to and from CYIStreamer.

The responsibility of the adapter is to create and populate views that correspond to logical indices in a data model. Used in conjunction with CYIStreamer subclasses like CYIListView, adapters allow the representation of arbitrary data in a view. The association between adapters and streamers is a one-to-one association, in which the streamer retains ownership of the adapter.

Several CYINodeAdapter subclasses can be used as more specialized starting points for concrete implementations:

#include <streamer/YiNodeAdapter.h>

Inheritance diagram for CYINodeAdapter:

Public Member Functions

 CYINodeAdapter ()
 
virtual ~CYINodeAdapter ()
 
virtual size_t GetItemsCount () const =0
 
virtual glm::vec3 GetInitialNodeSize (size_t index) const =0
 
virtual void ConfigureProperties (size_t index, CYISceneNode *pNode) const
 
IYIPropertiesSourceGetProperties (const CYIString &viewTemplateName) const
 
void SetProperties (const std::map< CYIString, IYIPropertiesSource *> &properties)
 
virtual std::unique_ptr< CYISceneNodeBuildNode (size_t index, CYISceneManager *pSceneManager)=0
 
virtual void ReleaseNode (size_t index, std::unique_ptr< CYISceneNode > pNode)=0
 

Public Attributes

CYISignal< size_tItemAddedAtIndex
 
CYISignal< size_tItemRemovedAtIndex
 
CYISignal< size_t, size_tItemMoved
 

Constructor & Destructor Documentation

◆ CYINodeAdapter()

CYINodeAdapter::CYINodeAdapter ( )

◆ ~CYINodeAdapter()

virtual CYINodeAdapter::~CYINodeAdapter ( )
virtual

Member Function Documentation

◆ BuildNode()

virtual std::unique_ptr<CYISceneNode> CYINodeAdapter::BuildNode ( size_t  index,
CYISceneManager pSceneManager 
)
pure virtual

Override to provide the node representing the visual subtree at 0-based index. This may be a newly constructed CYISceneNode or one that is recycled, so long as it is fully initialized. The same CYISceneNode may not be re-used until CYINodeAdapter::ReleaseNode is called at which point the implementation is free to deallocate or recycle the node.

See also
ReleaseNode

Implemented in CYIViewAdapter, and CYIDelegatingNodeAdapter.

◆ ConfigureProperties()

virtual void CYINodeAdapter::ConfigureProperties ( size_t  index,
CYISceneNode pNode 
) const
virtual

Override to populate the properties for pNode at 0-based index index. The default implementation configures the size of pPlaceholder to the initial node size.

Note
pNode is not the node built at index index, but any properties set on pNode will be copied to the node built for index index.

Subclasses should call CYINodeAdapter::ConfigureProperties.

See also
GetInitialNodeSize
CYISceneNode::SetProperty

Reimplemented in CYIViewAdapter.

◆ GetInitialNodeSize()

virtual glm::vec3 CYINodeAdapter::GetInitialNodeSize ( size_t  index) const
pure virtual

Override to return the initial node size for 0-based adapter index index. This is only used when items are initially added and does not need to reflect changes in size.

Implemented in CYIDelegatingNodeAdapter, and CYIViewAdapter.

◆ GetItemsCount()

virtual size_t CYINodeAdapter::GetItemsCount ( ) const
pure virtual

Returns the number of items managed by this adapter. This may be queried throughout the lifetime of the adapter and must report the correct value as items are added and removed. The number of items will be used to produce the 0-based consecutive indices. Indices may be invalidated when the number of items have changed and may no longer correspond to the same visual representations.

See also
CYINodeAdapter::ItemAddedAtIndex
CYINodeAdapter::ItemRemovedAtIndex

Implemented in CYIDelegatingViewAdapter, CYIDelegatingNodeAdapter, and CYIViewAdapter.

◆ GetProperties()

IYIPropertiesSource* CYINodeAdapter::GetProperties ( const CYIString viewTemplateName) const

Return a IYIPropertiesSource for the CYIViewTemplate named viewTemplateName or null if there is no IYIPropertiesSource for the CYIViewTemplate named viewTemplateName.

Note
The caller does not take ownership of the returned IYIPropertiesSource
See also
SetProperties
CYIViewTemplate::GetName

◆ ReleaseNode()

virtual void CYINodeAdapter::ReleaseNode ( size_t  index,
std::unique_ptr< CYISceneNode pNode 
)
pure virtual

Override to reclaim ownership of pNode, which represents the visual subtree at index. pNode may be recycled or destroyed.

Note
By the time ReleaseNode has been called the node has already been detached from the scene tree.
See also
BuildNode

Implemented in CYIViewAdapter, and CYIDelegatingNodeAdapter.

◆ SetProperties()

void CYINodeAdapter::SetProperties ( const std::map< CYIString, IYIPropertiesSource *> &  properties)

Set the properties to be used to configure nodes created by this adapter. The map contains a mapping from CYIViewTemplate names to properties for those templates. The properties can be used to configure nodes created with this adapter.

Note
Does not take ownership of the IYIPropertiesSource in the properties map.
See also
CYIListView::GetItemProperties
CYIViewTemplate::GetName
CYINodeAdapter::ConfigureProperties

Member Data Documentation

◆ ItemAddedAtIndex

CYISignal<size_t > CYINodeAdapter::ItemAddedAtIndex

This signal must be called each time a new item is added to the adapter. The parameter of the signal is the 0-based index at which the new item was added.

Note
The index provided should be incremented for each item. Inserting multiple items at the same index will result in the data being streamed in out of order. For example, if the adapter has 5 items and 3 items need to be inserted in the middle this signal should be emitted 3 times with the indicies 2, 3, 4 and not 2, 2, 2.

◆ ItemMoved

CYISignal<size_t , size_t > CYINodeAdapter::ItemMoved

This signal should be called when an existing item is moved within the adapter's index list. The first parameter of the signal is the previous 0-based index of the item, and the second paramter is the new 0-based index of the item.

Note
The new index of the item assumes that the item has been removed from the items list. For example, if the items list contains 'A, B, C, D' and 'ItemMoved(0, 1)' is called, the new items list would be 'B, A, C, D'.

◆ ItemRemovedAtIndex

CYISignal<size_t > CYINodeAdapter::ItemRemovedAtIndex

This signal must be called each time an item is removed from the adapter. The parameter of the signal is the 0-based index at which the item was prior to being removed.


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