[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / public-api / loader / buffer-definition.h
1 #ifndef DALI_SCENE3D_LOADER_BUFFER_DEFINITION_H
2 #define DALI_SCENE3D_LOADER_BUFFER_DEFINITION_H
3 /*
4  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
5  *
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  */
19
20 // EXTERNAL INCLUDES
21 #include <dali/public-api/common/dali-vector.h>
22 #include <dali/public-api/common/vector-wrapper.h>
23 #include <fstream>
24 #include <memory>
25
26 // INTERNAL INCLUDES
27 #include <dali-scene3d/public-api/api.h>
28
29 namespace Dali::Scene3D::Loader
30 {
31 /**
32  * @brief Defines a buffer that is loaded from input uri.
33  *
34  * The buffer can contain 3D resource data such as mesh, animation, and texture.
35  * @SINCE_2_2.12
36  */
37 struct DALI_SCENE3D_API BufferDefinition
38 {
39   using Vector = std::vector<BufferDefinition>;
40
41   BufferDefinition();
42   BufferDefinition(std::vector<uint8_t>& buffer);
43
44   ~BufferDefinition();
45
46   BufferDefinition(const BufferDefinition& other) = default;
47   BufferDefinition& operator=(const BufferDefinition& other) = default;
48
49   BufferDefinition(BufferDefinition&& other);
50   BufferDefinition& operator=(BufferDefinition&&) = default;
51
52   /**
53    * @brief Retrieves data stream of this buffer.
54    * @SINCE_2_2.12
55    * @return iostream of this buffer
56    */
57   std::iostream& GetBufferStream();
58
59   /**
60    * @brief Retrieves uri of this buffer
61    * @SINCE_2_2.12
62    * @return uri of the buffer
63    */
64   std::string GetUri();
65
66   /**
67    * @brief Checks whether the buffer is available or not.
68    *
69    * It is available, if the buffer is successfully loaded from file or base64 stream.
70    * @SINCE_2_2.12
71    * @return True if it is available.
72    */
73   bool IsAvailable();
74
75 private:
76   /// @cond internal
77   /**
78    * @brief Loads buffer from file or encoded stream.
79    */
80   void LoadBuffer();
81   /// @endcond
82
83 public: // DATA
84   std::string mResourcePath;
85   std::string mUri;
86   uint32_t    mByteLength{0};
87   std::string mName;
88
89 private:
90   struct Impl;
91   std::unique_ptr<Impl> mImpl;
92
93   bool mIsEmbedded{false};
94 };
95
96 } // namespace Dali::Scene3D::Loader
97
98 #endif // DALI_SCENE3D_LOADER_BUFFER_DEFINITION_H