1 #ifndef GAME_CONTAINER_H
2 #define GAME_CONTAINER_H
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 #include <dali/public-api/common/dali-vector.h>
25 * GameContainer is a vector which owns heap-allocated objects.
26 * Unlike vector this will call delete on the stored pointers during destruction.
27 * For example, you can define a vector of heap-allocated Node objects:
29 * typedef GameContainer< GameEntity* > EntityArray;
31 * EntityArray entites;
32 * entites.PushBack( new GameEntity() );
33 * // container is now responsible for calling delete on GameEntity
37 template< class T > class GameContainer : public Dali::Vector< T >
41 typedef typename Dali::Vector< T >::Iterator Iterator;
42 typedef typename Dali::Vector< T >::ConstIterator ConstIterator;
45 * Create a owner container.
52 * Non-virtual destructor; GameCache<T> is not suitable as base class.
57 Dali::VectorBase::Release();
61 * Destroy all of the elements in the container.
65 ConstIterator end = Dali::Vector< T >::End();
66 for( Iterator iter = Dali::Vector< T >::Begin(); iter != end; ++iter )
70 Dali::Vector< T >::Clear();
75 // Undefined copy constructor.
76 GameContainer( const GameContainer& );
78 // Undefined assignment operator.
79 GameContainer& operator=( const GameContainer& );