This class provides a collection of views that can be re-used.
State and any other management of the views is up to the user. The view may be reset to an initial state before returning them to the pool via the CYISceneView::Reset method or a manual reset process specific to your implementation; they can also be reset once they have been acquired, but this may produce visual artifacts, depending on the time needed to reset your custom view to an initial state.
Views returned to the view pool using ReleaseView() will be deleted when the view pool is deleted. Users must ensure that any views that have not been returned are deleted in another manner. Views that are attached to the scene tree will be managed by the scene manager and will automatically be deleted.
#include <deprecated/YiViewPool.h>
Public Types | |
| enum | TYPE { STATIC, GROWING } |
Public Member Functions | |
| CYIViewPool (CYISceneManager *pSceneManager, TYPE eType=STATIC) | |
| virtual | ~CYIViewPool () |
| void | AddViewType (const CYIString &viewTemplateName, const CYIRuntimeTypeInfo &viewType, int32_t nPreAllocate) |
| std::unique_ptr< CYISceneView > | TakeView (const CYIString &viewTemplateName, const CYIRuntimeTypeInfo &viewType) |
| void | ReleaseView (std::unique_ptr< CYISceneView > pView) |
| int32_t | GetAllocatedAmount (const CYIString &templateName, const CYIRuntimeTypeInfo &viewType) const |
| int32_t | GetAllocatedAmountRemaining (const CYIString &templateName, const CYIRuntimeTypeInfo &viewType) const |
| yi::deprecated::CYIViewPool::CYIViewPool | ( | CYISceneManager * | pSceneManager, |
| TYPE | eType = STATIC |
||
| ) |
|
virtual |
| void yi::deprecated::CYIViewPool::AddViewType | ( | const CYIString & | viewTemplateName, |
| const CYIRuntimeTypeInfo & | viewType, | ||
| int32_t | nPreAllocate | ||
| ) |
Specify a type of view and the associated template name that this pool manages. This version allows for specializing view types, when views share a common RTTI type, but use different templates. Pass in a value to nPreAllocate to specify how many views should be allocated, initialized and added to the pool right away.
| int32_t yi::deprecated::CYIViewPool::GetAllocatedAmount | ( | const CYIString & | templateName, |
| const CYIRuntimeTypeInfo & | viewType | ||
| ) | const |
Returns the currently allocated amount of views with the matching templateName and viewType.
| int32_t yi::deprecated::CYIViewPool::GetAllocatedAmountRemaining | ( | const CYIString & | templateName, |
| const CYIRuntimeTypeInfo & | viewType | ||
| ) | const |
Returns the currently allocated amount of views not in use with the matching templateName and viewType. If the pool type is GROWING this is not the true limit.
| void yi::deprecated::CYIViewPool::ReleaseView | ( | std::unique_ptr< CYISceneView > | pView | ) |
Release pView back to the pool. If pView didn't belong to the pool, pView is immediately deleted. The CYISceneView::Reset method will be called prior to the view being released back into the pool.
| std::unique_ptr<CYISceneView> yi::deprecated::CYIViewPool::TakeView | ( | const CYIString & | viewTemplateName, |
| const CYIRuntimeTypeInfo & | viewType | ||
| ) |
Returns a view of the type specified by viewType and assetViewTemplateName. If this a STATIC pool and no views are available, will return nullptr. If this is a GROWING pool and no views are available, a new one will be allocated and initialized, added to the pool, and returned to the caller.