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 uint32_t GetItemsCount () const =0
 
virtual glm::vec3 GetInitialNodeSize (uint32_t uIndex) const =0
 
virtual void ConfigureProperties (uint32_t uIndex, CYISceneNode *pNode) const
 
IYIPropertiesSourceGetProperties (const CYIString &viewTemplateName) const
 
void SetProperties (const std::map< CYIString, IYIPropertiesSource * > &properties)
 
virtual std::unique_ptr< CYISceneNodeBuildNode (uint32_t uIndex, CYISceneManager *pSceneManager)=0
 
virtual void ReleaseNode (uint32_t uIndex, std::unique_ptr< CYISceneNode > pNode)=0
 
- Public Member Functions inherited from CYIScriptableObject
 CYIScriptableObject ()
 
 CYIScriptableObject (const CYIScriptableObject &other)
 
CYIScriptableObjectoperator= (const CYIScriptableObject &other)
 
virtual ~CYIScriptableObject ()
 
CYIBindingImplementationGetBindingImplementation () const
 
void SetBindingImplementation (CYIBindingImplementation *pBindingImplementation)
 
virtual const CYIRuntimeTypeInfoGetRuntimeTypeInfoForScriptObject () const
 

Public Attributes

CYISignal< uint32_t > ItemAddedAtIndex
 
CYISignal< uint32_t > ItemRemovedAtIndex
 
CYISignal< uint32_t, uint32_t > ItemMoved
 

Constructor & Destructor Documentation

CYINodeAdapter::CYINodeAdapter ( )
virtual CYINodeAdapter::~CYINodeAdapter ( )
virtual

Member Function Documentation

virtual std::unique_ptr<CYISceneNode> CYINodeAdapter::BuildNode ( uint32_t  uIndex,
CYISceneManager pSceneManager 
)
pure virtual

Override to provide the node representing the visual subtree at 0-based uIndex. 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.

virtual void CYINodeAdapter::ConfigureProperties ( uint32_t  uIndex,
CYISceneNode pNode 
) const
virtual

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

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

Subclasses should call CYINodeAdapter::ConfigureProperties.

See also
GetInitialNodeSize
CYISceneNode::SetProperty

Reimplemented in CYIViewAdapter.

virtual glm::vec3 CYINodeAdapter::GetInitialNodeSize ( uint32_t  uIndex) const
pure virtual

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

Implemented in CYIDelegatingNodeAdapter, and CYIViewAdapter.

virtual uint32_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.

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
virtual void CYINodeAdapter::ReleaseNode ( uint32_t  uIndex,
std::unique_ptr< CYISceneNode pNode 
)
pure virtual

Override to reclaim ownership of pNode, which represents the visual subtree at uIndex. 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.

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

CYISignal<uint32_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.
CYISignal<uint32_t , uint32_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'.
CYISignal<uint32_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: