1 #ifndef DALI_TOOLKIT_PARTICLE_SYSTEM_PARTICLE_H
2 #define DALI_TOOLKIT_PARTICLE_SYSTEM_PARTICLE_H
4 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 #include <dali-toolkit/public-api/particle-system/particle-types.h>
24 #include <dali/public-api/object/base-handle.h>
26 namespace Dali::Toolkit::ParticleSystem
36 * Particle represents a single instance of a particle in the particle system.
38 * Particle provides a simple interface that allows R/W access to selected data stream and
39 * allows ignoring a placement of the particle data within the stream (Particle serves as a
40 * view on particular data within a stream).
42 class DALI_TOOLKIT_API Particle : public BaseHandle
51 * @brief Downcasts a handle to Particle handle.
53 * If handle points to an Particle object, the downcast produces valid handle.
54 * If not, the returned handle is left uninitialized.
56 * @param[in] handle to An object
57 * @return handle to a Particle object or an uninitialized handle
59 static Particle DownCast(BaseHandle handle);
62 * @brief Returns writeable reference to the data for specified stream
64 * The ParticleStreamTypeFlagBit allows accessing only pre-defined streams
65 * defined by the ParticleSystem. For custom streams GetByIndex() should be used.
67 * @tparam T type of data
68 * @param[in] streamBit Stream to access data from
69 * @return Reference to the data value
72 T& Get(ParticleStreamTypeFlagBit streamBit)
74 return *reinterpret_cast<T*>(Get(streamBit));
78 * @brief Returns writeable reference to the data for a stream specified by stream index.
80 * This function allows accessing builtin streams as well as custom ones. The index of a custom
81 * stream should be stored upon creation.
83 * @tparam T type of data
84 * @param[in] streamIndex Index of stream in the emitter
85 * @return Reference to the data value
88 T& GetByIndex(uint32_t streamIndex)
90 return *reinterpret_cast<T*>(GetByIndex(streamIndex));
94 * @brief Returns an index of particle within emitter data streams.
96 * @return Index of particle
98 [[nodiscard]] uint32_t GetIndex() const;
103 * @brief This constructor is used by Particle::New() methods.
105 * @param [in] impl A pointer to a newly allocated implementation
107 Particle(Dali::Toolkit::ParticleSystem::Internal::Particle* impl);
113 * @brief Returns pointer to the value
116 * The ParticleStreamTypeFlagBit allows accessing only pre-defined streams
117 * defined by the ParticleSystem. For custom streams GetByIndex() should be used.
119 * @param[in] streamBit Stream to access data from
121 * @return void* to the memory within stream that stores the data
123 void* Get(ParticleStreamTypeFlagBit streamBit);
128 * @brief Returns writeable reference to the data for a stream specified by stream index.
130 * This function allows accessing builtin streams as well as custom ones. The index of a custom
131 * stream should be stored upon creation.
133 * @param[in] streamIndex Index of stream in the emitter
135 * @return void* to the memory within stream that stores the data
137 void* GetByIndex(uint32_t streamIndex);
140 } // namespace Dali::Toolkit::ParticleSystem
142 #endif // DALI_TOOLKIT_PARTICLE_SYSTEM_PARTICLE_H