1 #ifndef DALI_INTERNAL_MEMORY_POOL_RELAYOUT_CONTAINER_H
2 #define DALI_INTERNAL_MEMORY_POOL_RELAYOUT_CONTAINER_H
5 * Copyright (c) 2021 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.
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/common/dali-vector.h>
24 #include <dali/public-api/size-negotiation/relayout-container.h>
26 #include <dali/internal/common/memory-pool-object-allocator.h>
33 * @brief Container to encapsulate information required for relayout.
35 * Uses a memory pool to manage data allocations.
37 class MemoryPoolRelayoutContainer : public RelayoutContainer
41 * Struct to store the relayout information
45 Dali::Actor actor; ///< The actor to relayout
46 Vector2 size; ///< The desired size of the actor
50 * @brief Default constructor
52 * @param objectAllocator A memory pool that can allocate memory for RelayoutInfos
54 MemoryPoolRelayoutContainer(MemoryPoolObjectAllocator<RelayoutInfo>& objectAllocator);
59 ~MemoryPoolRelayoutContainer() override;
62 * @brief Add relayout information to the container if it does'nt already exist
64 * @param actor The actor to relayout
65 * @param size The size to relayout
67 void Add(const Dali::Actor& actor, const Vector2& size) override;
70 * @brief Remove information from the container
75 * @brief Retrieve relayout information for the given index
77 * @param index The index of the information to retrieve
79 void Get(size_t index, Dali::Actor& actorOut, Vector2& sizeOut) const;
82 * @brief The count of information in the container
87 * @brief Set the capacity of the container
89 * @param capacity The new capacity for the container
91 void Reserve(size_t capacity);
94 * @brief Reset the container, freeing all memory
99 * @brief Returns if the container contains the actor or not
101 * @param actor The actor to search for
102 * @return Return if the actor was found or not
104 bool Contains(const Dali::Actor& actor);
107 using RelayoutInfoContainer = Vector<RelayoutInfo*>;
109 RelayoutInfoContainer mRelayoutInfos; ///< The list of relayout infos
111 MemoryPoolObjectAllocator<RelayoutInfo>& mAllocator; ///< The memory pool from which the infos are allocated
114 } // namespace Internal
118 #endif // DALI_INTERNAL_MEMORY_POOL_RELAYOUT_CONTAINER_H