GCC Code Coverage Report


Directory: src/gate/
File: src/gate/cxx_directories.cpp
Date: 2025-09-14 13:10:38
Exec Total Coverage
Lines: 0 206 0.0%
Functions: 0 49 0.0%
Branches: 0 182 0.0%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright(c) 2018-2025, Stefan Meislinger <sm@opengate.at> |
4 | All rights reserved. |
5 | |
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met:|
8 | |
9 | 1. Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. |
11 | 2. Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. |
14 | |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"|
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | THE POSSIBILITY OF SUCH DAMAGE. |
26 +----------------------------------------------------------------------------+
27 */
28
29 #include "gate/directories.hpp"
30 #include "gate/exceptions.hpp"
31 #include "gate/utilities.hpp"
32
33 namespace gate
34 {
35
36 DirectoryPropertyDef::DirectoryPropertyDef()
37 {
38 gate_mem_clear(&this->impl, sizeof(this->impl));
39 }
40
41 DirectoryPropertyDef::DirectoryPropertyDef(gate_directory_propertydef_t const& src)
42 {
43 if (NULL == gate_directory_propertydef_create(&this->impl, src.data_type, &src.name, src.flags))
44 {
45 GATEXX_RAISE_ERROR(results::OutOfMemory);
46 }
47 }
48 DirectoryPropertyDef::DirectoryPropertyDef(DirectoryPropertyDef const& src)
49 {
50 if (NULL == gate_directory_propertydef_create(&this->impl, src.impl.data_type, &src.impl.name, src.impl.flags))
51 {
52 GATEXX_RAISE_ERROR(results::OutOfMemory);
53 }
54 }
55 DirectoryPropertyDef::DirectoryPropertyDef(gate_type_id_t dataType, String const& name, uint32_t flags)
56 {
57 if (NULL == gate_directory_propertydef_create(&this->impl, dataType, name.c_impl(), flags))
58 {
59 GATEXX_RAISE_ERROR(results::OutOfMemory);
60 }
61 }
62 DirectoryPropertyDef& DirectoryPropertyDef::operator=(DirectoryPropertyDef const& src)
63 {
64 if (this != &src)
65 {
66 String::assign(this->impl.name, src.impl.name);
67 this->impl.data_type = src.impl.data_type;
68 this->impl.flags = src.impl.flags;
69 }
70 return *this;
71 }
72 DirectoryPropertyDef::~DirectoryPropertyDef() noexcept
73 {
74 gate_directory_propertydef_release(&this->impl);
75 }
76
77 gate_type_id_t DirectoryPropertyDef::Type() const
78 {
79 return this->impl.data_type;
80 }
81 String DirectoryPropertyDef::Name() const
82 {
83 return String::duplicate(this->impl.name);
84 }
85 uint32_t DirectoryPropertyDef::Flags() const
86 {
87 return this->impl.flags;
88 }
89 gate_directory_propertydef_t* DirectoryPropertyDef::c_impl()
90 {
91 return &this->impl;
92 }
93 gate_directory_propertydef_t const* DirectoryPropertyDef::c_impl() const
94 {
95 return &this->impl;
96 }
97
98
99
100
101
102
103 uint32_t const DirectoryClass::Flag_Container = GATE_DIRECTORY_CLASS_FLAG_CONTAINER;
104 uint32_t const DirectoryClass::Flag_Streams = GATE_DIRECTORY_CLASS_FLAG_STREAMS;
105 uint32_t const DirectoryClass::Flag_Creatable = GATE_DIRECTORY_CLASS_FLAG_CREATABLE;
106
107
108 DirectoryClass::DirectoryClass(gate_directory_class_t* dir_class)
109 : object_impl_t(dir_class)
110 {
111 }
112 DirectoryClass::DirectoryClass(DirectoryClass const& src)
113 : object_impl_t(src)
114 {
115 }
116
117 String DirectoryClass::Uid() const
118 {
119 gate_string_t tmp = GATE_STRING_INIT_EMPTY;
120 result_t result = gate_directory_class_uid(this->c_impl(), &tmp);
121 GATEXX_CHECK_ERROR(result);
122 return String::createFrom(tmp);
123 }
124 String DirectoryClass::Name() const
125 {
126 gate_string_t tmp = GATE_STRING_INIT_EMPTY;
127 result_t result = gate_directory_class_name(this->c_impl(), &tmp);
128 GATEXX_CHECK_ERROR(result);
129 return String::createFrom(tmp);
130 }
131 uint32_t DirectoryClass::Flags() const
132 {
133 uint32_t flags = 0;
134 result_t result = gate_directory_class_flags(this->c_impl(), &flags);
135 GATEXX_CHECK_ERROR(result);
136 return flags;
137 }
138
139 size_t DirectoryClass::getPropertiesCount() const
140 {
141 size_t count = 0;
142 result_t result = gate_directory_class_get_properties_count(this->c_impl(), &count);
143 GATEXX_CHECK_ERROR(result);
144 return count;
145 }
146 DirectoryPropertyDef DirectoryClass::getProperty(size_t index) const
147 {
148 DirectoryPropertyDef def;
149 result_t result = gate_directory_class_get_property(this->c_impl(), index, def.c_impl());
150 GATEXX_CHECK_ERROR(result);
151 return def;
152 }
153 DirectoryPropertyDef DirectoryClass::findProperty(String const& name) const
154 {
155 DirectoryPropertyDef def;
156 result_t result = gate_directory_class_find_property(this->c_impl(), name.c_impl(), def.c_impl());
157 GATEXX_CHECK_EXCEPTION(result);
158 return def;
159 }
160
161 size_t DirectoryClass::getSuperiorClassesCount() const
162 {
163 size_t count = 0;
164 result_t result = gate_directory_class_get_superior_classes_count(this->c_impl(), &count);
165 GATEXX_CHECK_ERROR(result);
166 return count;
167 }
168 String DirectoryClass::getSuperiorClassUid(size_t index) const
169 {
170 gate_string_t tmp = GATE_STRING_INIT_EMPTY;
171 result_t result = gate_directory_class_get_superior_class_uid(this->c_impl(), index, &tmp);
172 GATEXX_CHECK_ERROR(result);
173 return String::createFrom(tmp);
174 }
175
176 size_t DirectoryClass::getContainmentClassesCount() const
177 {
178 size_t count = 0;
179 result_t result = gate_directory_class_get_containment_classes_count(this->c_impl(), &count);
180 GATEXX_CHECK_ERROR(result);
181 return count;
182 }
183 String DirectoryClass::getContainmentClassUid(size_t index) const
184 {
185 gate_string_t tmp = GATE_STRING_INIT_EMPTY;
186 result_t result = gate_directory_class_get_containment_class_uid(this->c_impl(), index, &tmp);
187 GATEXX_CHECK_ERROR(result);
188 return String::createFrom(tmp);
189 }
190
191
192
193
194
195 DirectoryEntry::DirectoryEntry(gate_directory_entry_t* dir_entry)
196 : object_impl_t(dir_entry)
197 {
198 }
199 DirectoryEntry::DirectoryEntry(DirectoryEntry const& src)
200 : object_impl_t(src)
201 {
202 }
203
204 String DirectoryEntry::EntryUid() const
205 {
206 gate_string_t tmp = GATE_STRING_INIT_EMPTY;
207 result_t result = gate_directory_entry_entry_uid(this->c_impl(), &tmp);
208 GATEXX_CHECK_ERROR(result);
209 return String::createFrom(tmp);
210 }
211 String DirectoryEntry::ClassUid() const
212 {
213 gate_string_t tmp = GATE_STRING_INIT_EMPTY;
214 result_t result = gate_directory_entry_class_uid(this->c_impl(), &tmp);
215 GATEXX_CHECK_ERROR(result);
216 return String::createFrom(tmp);
217 }
218
219 String DirectoryEntry::Path() const
220 {
221 gate_string_t tmp = GATE_STRING_INIT_EMPTY;
222 result_t result = gate_directory_entry_path(this->c_impl(), &tmp);
223 GATEXX_CHECK_ERROR(result);
224 return String::createFrom(tmp);
225 }
226 String DirectoryEntry::Name() const
227 {
228 gate_string_t tmp = GATE_STRING_INIT_EMPTY;
229 result_t result = gate_directory_entry_name(this->c_impl(), &tmp);
230 GATEXX_CHECK_ERROR(result);
231 return String::createFrom(tmp);
232 }
233 String DirectoryEntry::ParentPath() const
234 {
235 gate_string_t tmp = GATE_STRING_INIT_EMPTY;
236 result_t result = gate_directory_entry_parent_path(this->c_impl(), &tmp);
237 GATEXX_CHECK_ERROR(result);
238 return String::createFrom(tmp);
239 }
240
241 Value DirectoryEntry::getProperty(String const& propName) const
242 {
243 Value value;
244 result_t result = gate_directory_entry_get_property(this->c_impl(), propName.c_impl(), value.c_impl());
245 GATEXX_CHECK_EXCEPTION(result);
246 return value;
247 }
248 void DirectoryEntry::setProperty(String const& propName, Value const& value)
249 {
250 result_t result = gate_directory_entry_set_property(this->c_impl(), propName.c_impl(), value.c_impl());
251 GATEXX_CHECK_EXCEPTION(result);
252 }
253 void DirectoryEntry::refreshProperties()
254 {
255 result_t result = gate_directory_entry_refresh_properties(this->c_impl());
256 GATEXX_CHECK_ERROR(result);
257 }
258
259
260
261
262
263
264
265 DirectoryProvider::DirectoryProvider(gate_directory_provider_t* dir_prov)
266 : object_impl_t(dir_prov)
267 {
268 }
269 DirectoryProvider::DirectoryProvider(DirectoryProvider const& src)
270 : object_impl_t(src)
271 {
272 }
273
274 String DirectoryProvider::ProviderName()
275 {
276 gate_string_t tmp = GATE_STRING_INIT_EMPTY;
277 result_t result = gate_directory_provider_provider_name(this->c_impl(), &tmp);
278 GATEXX_CHECK_ERROR(result);
279 return String::createFrom(tmp);
280 }
281
282 size_t DirectoryProvider::getClassesCount()
283 {
284 size_t ret = 0;
285 result_t result = gate_directory_provider_get_classes_count(this->c_impl(), &ret);
286 GATEXX_CHECK_ERROR(result);
287 return ret;
288 }
289 DirectoryClass DirectoryProvider::getClass(size_t index)
290 {
291 gate_directory_class_t* ptr_class = NULL;
292 result_t result = gate_directory_provider_get_class(this->c_impl(), index, &ptr_class);
293 GATEXX_CHECK_ERROR(result);
294 return DirectoryClass(ptr_class);
295 }
296 DirectoryClass DirectoryProvider::findClass(String const& classUid)
297 {
298 gate_directory_class_t* ptr_class = NULL;
299 result_t result = gate_directory_provider_find_class(this->c_impl(), classUid.c_impl(), &ptr_class);
300 GATEXX_CHECK_EXCEPTION(result);
301 return DirectoryClass(ptr_class);
302 }
303
304 DirectoryEntry DirectoryProvider::getEntry(String const& entryPath)
305 {
306 gate_directory_entry_t* ptr_entry = NULL;
307 result_t result = gate_directory_provider_get_entry_by_path(this->c_impl(), entryPath.c_impl(), &ptr_entry);
308 GATEXX_CHECK_EXCEPTION(result);
309 return DirectoryEntry(ptr_entry);
310 }
311 DirectoryEntry DirectoryProvider::getEntryByUid(String const& entryUid)
312 {
313 gate_directory_entry_t* ptr_entry = NULL;
314 result_t result = gate_directory_provider_get_entry_by_uid(this->c_impl(), entryUid.c_impl(), &ptr_entry);
315 GATEXX_CHECK_EXCEPTION(result);
316 return DirectoryEntry(ptr_entry);
317 }
318
319 void DirectoryProvider::searchEntries(DirectoryEntry root, String const& query, uint32_t searchFlags,
320 SearchDelegate const& callback, void* callbackParam)
321 {
322 result_t result = gate_directory_provider_search_entries(this->c_impl(), root.c_impl(), query.c_impl(), searchFlags, callback.c_impl(), callbackParam);
323 GATEXX_CHECK_EXCEPTION(result);
324 }
325
326 bool DirectoryProvider::hasChild(DirectoryEntry root, String const& classUid, String const& name, Optional<DirectoryEntry>* ptrEntry)
327 {
328 result_t result = gate_directory_provider_get_child_entry(this->c_impl(), root.c_impl(), classUid.c_impl(), name.c_impl(), NULL);
329 return GATE_SUCCEEDED(result);
330 }
331 DirectoryEntry DirectoryProvider::getChild(DirectoryEntry root, String const& classUid, String const& name)
332 {
333 gate_directory_entry_t* ptr_entry = NULL;
334 result_t result = gate_directory_provider_get_child_entry(this->c_impl(), root.c_impl(), classUid.c_impl(), name.c_impl(), &ptr_entry);
335 GATEXX_CHECK_EXCEPTION(result);
336 return DirectoryEntry(ptr_entry);
337 }
338
339 DirectoryEntry DirectoryProvider::createEntry(DirectoryEntry parent, String const& classUid, String const& childName,
340 Map<String, Value> const& properties, Stream* optionalStream)
341 {
342 gate_directory_entry_t* ptr_entry = NULL;
343 result_t result = gate_directory_provider_create_entry(this->c_impl(), parent.c_impl(), classUid.c_impl(),
344 childName.c_impl(), properties.c_impl(),
345 (optionalStream ? optionalStream->c_impl() : NULL),
346 &ptr_entry);
347 GATEXX_CHECK_EXCEPTION(result);
348 return DirectoryEntry(ptr_entry);
349 }
350 void DirectoryProvider::deleteEntry(DirectoryEntry entry)
351 {
352 result_t result = gate_directory_provider_delete_entry(this->c_impl(), entry.c_impl());
353 GATEXX_CHECK_EXCEPTION(result);
354 }
355 DirectoryEntry DirectoryProvider::copyEntry(DirectoryEntry source, DirectoryEntry targetContainer, String const& newName, uint32_t copyFlags)
356 {
357 gate_directory_entry_t* ptr_entry = NULL;
358 result_t result = gate_directory_provider_copy_entry(this->c_impl(), source.c_impl(), targetContainer.c_impl(),
359 newName.c_impl(), copyFlags, &ptr_entry);
360 GATEXX_CHECK_EXCEPTION(result);
361 return DirectoryEntry(ptr_entry);
362 }
363 DirectoryEntry DirectoryProvider::moveEntry(DirectoryEntry source, DirectoryEntry targetContainer, String const& newName, uint32_t moveFlags)
364 {
365 gate_directory_entry_t* ptr_entry = NULL;
366 result_t result = gate_directory_provider_move_entry(this->c_impl(), source.c_impl(), targetContainer.c_impl(),
367 newName.c_impl(), moveFlags, &ptr_entry);
368 GATEXX_CHECK_EXCEPTION(result);
369 return DirectoryEntry(ptr_entry);
370 }
371
372 Stream DirectoryProvider::openStream(DirectoryEntry source, String const& streamName, uint32_t openFlags)
373 {
374 gate_stream_t* ptr_stream = NULL;
375 result_t result = gate_directory_provider_open_stream(this->c_impl(), source.c_impl(), streamName.c_impl(),
376 openFlags, &ptr_stream);
377 GATEXX_CHECK_EXCEPTION(result);
378 return Stream(ptr_stream);
379 }
380
381
382
383 } // end of namespace gate
384