You.i Engine
CYIViewAdapter Class Referenceabstract

Detailed Description

A simplified CYINodeAdapter interface for automatically building views using provided view templates.

Adapters are responsible for the construction and population of views corresponding to indices in a data model. CYIViewAdapter provides this functionality through the use of CYIAssetViewTemplate and IYIViewRecycler. Concrete implementations of CYIViewAdapter associate data model indices with CYIAssetViewTemplate instances in CYIViewAdapter::GetViewTemplate. These views are populated according to the data they represent in CYIViewAdapter::PopulateView. The creation and destruction of these views is managed by the IYIViewRecycler optional component provided at construction time. If no view recycler is provided a CYICreateDeleteViewRecycler is used. This default recycler creates and deletes views each time, offering no recycling.

For the most generalized adapter interface see CYINodeAdapter. To implement CYIViewAdapter's responsibilities in an existing class, such as a derivative of CYIAbstractScreenViewController, see CYIDelegatingViewAdapter.

#include <streamer/YiViewAdapter.h>

Inheritance diagram for CYIViewAdapter:

Public Member Functions

 CYIViewAdapter (const std::shared_ptr< IYIViewRecycler > &pViewRecycler=std::shared_ptr< IYIViewRecycler >())
 
virtual ~CYIViewAdapter ()
 
virtual size_t GetItemsCount () const override=0
 
virtual glm::vec3 GetInitialNodeSize (size_t index) const override
 
virtual void ConfigureProperties (size_t index, CYISceneNode *pNode) const override
 
virtual std::unique_ptr< CYISceneNodeBuildNode (size_t index, CYISceneManager *pSceneManager) final override
 
virtual void ReleaseNode (size_t index, std::unique_ptr< CYISceneNode > pNode) final override
 
virtual std::shared_ptr< CYIAssetViewTemplateGetViewTemplate (size_t index) const =0
 
virtual const CYIRuntimeTypeInfoGetViewClass (size_t index) const
 
- Public Member Functions inherited from CYINodeAdapter
 CYINodeAdapter ()
 
virtual ~CYINodeAdapter ()
 
IYIPropertiesSourceGetProperties (const CYIString &viewTemplateName) const
 
void SetProperties (const std::map< CYIString, IYIPropertiesSource *> &properties)
 

Protected Member Functions

virtual void PopulateView (size_t index, CYISceneView *pView)=0
 
virtual void OnReleaseView (size_t index, CYISceneView *pView)
 

Additional Inherited Members

- Public Attributes inherited from CYINodeAdapter
CYISignal< size_tItemAddedAtIndex
 
CYISignal< size_tItemRemovedAtIndex
 
CYISignal< size_t, size_tItemMoved
 

Constructor & Destructor Documentation

◆ CYIViewAdapter()

CYIViewAdapter::CYIViewAdapter ( const std::shared_ptr< IYIViewRecycler > &  pViewRecycler = std::shared_ptr< IYIViewRecycler >())

Creates a new CYIViewAdapter with an optionally provided IYIViewRecycler, pViewRecycler. If no view recycler is provided, a CYICreateDeleteViewRecycler will be used.

◆ ~CYIViewAdapter()

virtual CYIViewAdapter::~CYIViewAdapter ( )
virtual

Member Function Documentation

◆ BuildNode()

virtual std::unique_ptr<CYISceneNode> CYIViewAdapter::BuildNode ( size_t  index,
CYISceneManager pSceneManager 
)
finaloverridevirtual

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

Implements CYINodeAdapter.

◆ ConfigureProperties()

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

The default implementation configures pNode with properties from the view template at index index, and with properties set explicitly using CYINodeAdapter::SetProperties(). Properties configured with CYINodeAdapter::SetProperties() will overwrite those from the template.

Note
pNode is not the node built at index index, but any properties set on pNode using CYISceneNode::SetProperty() will be copied to the node built for index index.

This method calls CYINodeAdapter::ConfigureProperties. Subclasses should call CYIViewAdapter::ConfigureProperties.

See also
CYINodeAdapter::ConfigureProperties
CYINodeAdapter::GetProperties

Reimplemented from CYINodeAdapter.

◆ GetInitialNodeSize()

virtual glm::vec3 CYIViewAdapter::GetInitialNodeSize ( size_t  index) const
overridevirtual

Returns the initial node size of the view template for 0-based adapter index index.

See also
GetViewTemplate
CYINodeAdapter::GetInitialNodeSize

Implements CYINodeAdapter.

◆ GetItemsCount()

virtual size_t CYIViewAdapter::GetItemsCount ( ) const
overridepure 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

Implements CYINodeAdapter.

Implemented in CYIDelegatingViewAdapter.

◆ GetViewClass()

virtual const CYIRuntimeTypeInfo* CYIViewAdapter::GetViewClass ( size_t  index) const
virtual

Returns the class type for the item at adapter index index. Returns nullptr by default, indicating that the class type from the view template should be used. The class type must be derived from CYISceneView. Subclasses can override this function to provide a view class for the item at adapter index index.

See also
GetViewTemplate
CYIViewTemplate::GetViewClassName

Reimplemented in CYIDelegatingViewAdapter.

◆ GetViewTemplate()

virtual std::shared_ptr<CYIAssetViewTemplate> CYIViewAdapter::GetViewTemplate ( size_t  index) const
pure virtual

Returns the view template that will be used to construct the item at adapter index index. The size of this template will be used as the initial node size for adapter index index.

Implemented in CYIDelegatingViewAdapter.

◆ OnReleaseView()

virtual void CYIViewAdapter::OnReleaseView ( size_t  index,
CYISceneView pView 
)
protectedvirtual

Called before pView is recycled. If this adaper is using a CYIPooledViewRecycler, this is the ideal time to reset pView before it is returned to the pool.

Warning
Do not retain a pointer to pView as ownership is relinquished to the IYIViewRecycler after this function is called.
See also
IYIViewRecycler
CYIPooledViewRecycler

Reimplemented in CYIDelegatingViewAdapter.

◆ PopulateView()

virtual void CYIViewAdapter::PopulateView ( size_t  index,
CYISceneView pView 
)
protectedpure virtual

Populates the view pView, which is associated with adapter index index.

Implemented in CYIDelegatingViewAdapter.

◆ ReleaseNode()

virtual void CYIViewAdapter::ReleaseNode ( size_t  index,
std::unique_ptr< CYISceneNode pNode 
)
finaloverridevirtual

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

Implements CYINodeAdapter.


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