GCC Code Coverage Report


Directory: src/gate/
File: src/gate/cxx_directories.cpp
Date: 2026-10-19 17:06:30
Exec Total Coverage
Lines: 82 220 37.3%
Functions: 21 51 41.2%
Branches: 25 194 12.9%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright (c) 2018-2026, 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 enumint_t const DirectoryPropertyDef::Flag_Optional = GATE_DIRECTORY_PROPERTY_FLAG_OPTIONAL;
37
38 4 DirectoryPropertyDef::DirectoryPropertyDef()
39 {
40 4 gate_mem_clear(&this->impl, sizeof(this->impl));
41 4 }
42
43 ✗ DirectoryPropertyDef::DirectoryPropertyDef(gate_directory_propertydef_t const& src)
44 {
45 ✗ if (NULL == gate_directory_propertydef_create(&this->impl, src.data_type, &src.name, src.flags))
46 {
47 ✗ GATEXX_RAISE_ERROR(results::OutOfMemory);
48 }
49 ✗ }
50 ✗ DirectoryPropertyDef::DirectoryPropertyDef(DirectoryPropertyDef const& src)
51 {
52 ✗ if (NULL == gate_directory_propertydef_create(&this->impl, src.impl.data_type, &src.impl.name, src.impl.flags))
53 {
54 ✗ GATEXX_RAISE_ERROR(results::OutOfMemory);
55 }
56 ✗ }
57 1 DirectoryPropertyDef::DirectoryPropertyDef(gate_type_id_t dataType, String const& name, enumint_t flags)
58 {
59
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if (NULL == gate_directory_propertydef_create(&this->impl, dataType, name.c_impl(), flags))
60 {
61 ✗ GATEXX_RAISE_ERROR(results::OutOfMemory);
62 }
63 1 }
64 2 DirectoryPropertyDef& DirectoryPropertyDef::operator=(DirectoryPropertyDef const& src)
65 {
66
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (this != &src)
67 {
68 2 String::assign(this->impl.name, src.impl.name);
69 2 this->impl.data_type = src.impl.data_type;
70 2 this->impl.flags = src.impl.flags;
71 }
72 2 return *this;
73 }
74 10 DirectoryPropertyDef::~DirectoryPropertyDef() noexcept
75 {
76 5 gate_directory_propertydef_release(&this->impl);
77 5 }
78
79 1 gate_type_id_t DirectoryPropertyDef::Type() const
80 {
81 1 return this->impl.data_type;
82 }
83 1 String DirectoryPropertyDef::Name() const
84 {
85 1 return String::duplicate(this->impl.name);
86 }
87 1 enumint_t DirectoryPropertyDef::Flags() const
88 {
89 1 return this->impl.flags;
90 }
91 3 gate_directory_propertydef_t* DirectoryPropertyDef::c_impl()
92 {
93 3 return &this->impl;
94 }
95 1 gate_directory_propertydef_t const* DirectoryPropertyDef::c_impl() const
96 {
97 1 return &this->impl;
98 }
99
100
101
102
103
104
105 enumint_t const DirectoryClass::Flag_Container = GATE_DIRECTORY_CLASS_FLAG_CONTAINER;
106 enumint_t const DirectoryClass::Flag_Streams = GATE_DIRECTORY_CLASS_FLAG_STREAMS;
107 enumint_t const DirectoryClass::Flag_Creatable = GATE_DIRECTORY_CLASS_FLAG_CREATABLE;
108
109 1 DirectoryClass DirectoryClass::create(
110 String const& uid, String const& name, enumint_t flags,
111 DirectoryPropertyDef const* propDefs, size_t propDefsCount,
112 String const* superiorUids, size_t superiorUidsCount,
113 String const* containmentUids, size_t containmentUidsCount)
114 {
115 1 gate_directory_class_t* const ptr_class = gate_directory_class_create(
116 uid.c_impl(), name.c_impl(), flags,
117 propDefs->c_impl(), propDefsCount,
118 superiorUids->c_impl(), superiorUidsCount,
119 containmentUids->c_impl(), containmentUidsCount);
120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (NULL == ptr_class)
121 {
122 ✗ GATEXX_RAISE_ERROR(results::OutOfMemory);
123 }
124 1 return DirectoryClass(ptr_class);
125 }
126
127 1 DirectoryClass::DirectoryClass(gate_directory_class_t* dir_class)
128 1 : object_impl_t(dir_class)
129 {
130 1 }
131 ✗ DirectoryClass::DirectoryClass(DirectoryClass const& src)
132 ✗ : object_impl_t(src)
133 {
134 ✗ }
135
136 1 String DirectoryClass::Uid() const
137 {
138 1 gate_string_t tmp = GATE_STRING_INIT_EMPTY;
139
1/2
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
1 result_t result = gate_directory_class_uid(this->c_impl(), &tmp);
140
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 GATEXX_CHECK_ERROR(result);
141 2 return String::createFrom(tmp);
142 }
143 1 String DirectoryClass::Name() const
144 {
145 1 gate_string_t tmp = GATE_STRING_INIT_EMPTY;
146
1/2
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
1 result_t result = gate_directory_class_name(this->c_impl(), &tmp);
147
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 GATEXX_CHECK_ERROR(result);
148 2 return String::createFrom(tmp);
149 }
150 1 enumint_t DirectoryClass::Flags() const
151 {
152 1 enumint_t flags = 0;
153
1/2
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
1 result_t result = gate_directory_class_flags(this->c_impl(), &flags);
154
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 GATEXX_CHECK_ERROR(result);
155 1 return flags;
156 }
157
158 1 size_t DirectoryClass::getPropertiesCount() const
159 {
160 1 size_t count = 0;
161
1/2
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
1 result_t result = gate_directory_class_get_properties_count(this->c_impl(), &count);
162
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 GATEXX_CHECK_ERROR(result);
163 1 return count;
164 }
165 1 DirectoryPropertyDef DirectoryClass::getProperty(size_t index) const
166 {
167 1 DirectoryPropertyDef def;
168
1/2
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 result_t result = gate_directory_class_get_property(this->c_impl(), index, def.c_impl());
169
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 GATEXX_CHECK_ERROR(result);
170 1 return def;
171 }
172 2 DirectoryPropertyDef DirectoryClass::findProperty(String const& name) const
173 {
174 2 DirectoryPropertyDef def;
175
1/2
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
2 result_t result = gate_directory_class_find_property(this->c_impl(), name.c_impl(), def.c_impl());
176
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
2 GATEXX_CHECK_EXCEPTION(result);
177 1 return def;
178 }
179
180 1 size_t DirectoryClass::getSuperiorClassesCount() const
181 {
182 1 size_t count = 0;
183
1/2
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
1 result_t result = gate_directory_class_get_superior_classes_count(this->c_impl(), &count);
184
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 GATEXX_CHECK_ERROR(result);
185 1 return count;
186 }
187 1 String DirectoryClass::getSuperiorClassUid(size_t index) const
188 {
189 1 gate_string_t tmp = GATE_STRING_INIT_EMPTY;
190
1/2
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
1 result_t result = gate_directory_class_get_superior_class_uid(this->c_impl(), index, &tmp);
191
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 GATEXX_CHECK_ERROR(result);
192 2 return String::createFrom(tmp);
193 }
194
195 1 size_t DirectoryClass::getContainmentClassesCount() const
196 {
197 1 size_t count = 0;
198
1/2
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
1 result_t result = gate_directory_class_get_containment_classes_count(this->c_impl(), &count);
199
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 GATEXX_CHECK_ERROR(result);
200 1 return count;
201 }
202 1 String DirectoryClass::getContainmentClassUid(size_t index) const
203 {
204 1 gate_string_t tmp = GATE_STRING_INIT_EMPTY;
205
1/2
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
1 result_t result = gate_directory_class_get_containment_class_uid(this->c_impl(), index, &tmp);
206
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 GATEXX_CHECK_ERROR(result);
207 2 return String::createFrom(tmp);
208 }
209
210
211
212
213
214 ✗ DirectoryEntry::DirectoryEntry(gate_directory_entry_t* dir_entry)
215 ✗ : object_impl_t(dir_entry)
216 {
217 ✗ }
218 ✗ DirectoryEntry::DirectoryEntry(DirectoryEntry const& src)
219 ✗ : object_impl_t(src)
220 {
221 ✗ }
222
223 ✗ String DirectoryEntry::EntryUid() const
224 {
225 ✗ gate_string_t tmp = GATE_STRING_INIT_EMPTY;
226 ✗ result_t result = gate_directory_entry_entry_uid(this->c_impl(), &tmp);
227 ✗ GATEXX_CHECK_ERROR(result);
228 ✗ return String::createFrom(tmp);
229 }
230 ✗ String DirectoryEntry::ClassUid() const
231 {
232 ✗ gate_string_t tmp = GATE_STRING_INIT_EMPTY;
233 ✗ result_t result = gate_directory_entry_class_uid(this->c_impl(), &tmp);
234 ✗ GATEXX_CHECK_ERROR(result);
235 ✗ return String::createFrom(tmp);
236 }
237
238 ✗ String DirectoryEntry::Path() const
239 {
240 ✗ gate_string_t tmp = GATE_STRING_INIT_EMPTY;
241 ✗ result_t result = gate_directory_entry_path(this->c_impl(), &tmp);
242 ✗ GATEXX_CHECK_ERROR(result);
243 ✗ return String::createFrom(tmp);
244 }
245 ✗ String DirectoryEntry::Name() const
246 {
247 ✗ gate_string_t tmp = GATE_STRING_INIT_EMPTY;
248 ✗ result_t result = gate_directory_entry_name(this->c_impl(), &tmp);
249 ✗ GATEXX_CHECK_ERROR(result);
250 ✗ return String::createFrom(tmp);
251 }
252 ✗ String DirectoryEntry::ParentPath() const
253 {
254 ✗ gate_string_t tmp = GATE_STRING_INIT_EMPTY;
255 ✗ result_t result = gate_directory_entry_parent_path(this->c_impl(), &tmp);
256 ✗ GATEXX_CHECK_ERROR(result);
257 ✗ return String::createFrom(tmp);
258 }
259
260 ✗ Value DirectoryEntry::getProperty(String const& propName) const
261 {
262 ✗ Value value;
263 ✗ result_t result = gate_directory_entry_get_property(this->c_impl(), propName.c_impl(), value.c_impl());
264 ✗ GATEXX_CHECK_EXCEPTION(result);
265 ✗ return value;
266 }
267 ✗ void DirectoryEntry::setProperty(String const& propName, Value const& value)
268 {
269 ✗ result_t result = gate_directory_entry_set_property(this->c_impl(), propName.c_impl(), value.c_impl());
270 ✗ GATEXX_CHECK_EXCEPTION(result);
271 ✗ }
272 ✗ void DirectoryEntry::refreshProperties()
273 {
274 ✗ result_t result = gate_directory_entry_refresh_properties(this->c_impl());
275 ✗ GATEXX_CHECK_ERROR(result);
276 ✗ }
277
278
279
280
281
282
283
284 ✗ DirectoryProvider::DirectoryProvider(gate_directory_provider_t* dir_prov)
285 ✗ : object_impl_t(dir_prov)
286 {
287 ✗ }
288 ✗ DirectoryProvider::DirectoryProvider(DirectoryProvider const& src)
289 ✗ : object_impl_t(src)
290 {
291 ✗ }
292
293 ✗ String DirectoryProvider::ProviderName()
294 {
295 ✗ gate_string_t tmp = GATE_STRING_INIT_EMPTY;
296 ✗ result_t result = gate_directory_provider_provider_name(this->c_impl(), &tmp);
297 ✗ GATEXX_CHECK_ERROR(result);
298 ✗ return String::createFrom(tmp);
299 }
300
301 ✗ size_t DirectoryProvider::getClassesCount()
302 {
303 ✗ size_t ret = 0;
304 ✗ result_t result = gate_directory_provider_get_classes_count(this->c_impl(), &ret);
305 ✗ GATEXX_CHECK_ERROR(result);
306 ✗ return ret;
307 }
308 ✗ DirectoryClass DirectoryProvider::getClass(size_t index)
309 {
310 ✗ gate_directory_class_t* ptr_class = NULL;
311 ✗ result_t result = gate_directory_provider_get_class(this->c_impl(), index, &ptr_class);
312 ✗ GATEXX_CHECK_ERROR(result);
313 ✗ return DirectoryClass(ptr_class);
314 }
315 ✗ DirectoryClass DirectoryProvider::findClass(String const& classUid)
316 {
317 ✗ gate_directory_class_t* ptr_class = NULL;
318 ✗ result_t result = gate_directory_provider_find_class(this->c_impl(), classUid.c_impl(), &ptr_class);
319 ✗ GATEXX_CHECK_EXCEPTION(result);
320 ✗ return DirectoryClass(ptr_class);
321 }
322
323 ✗ DirectoryEntry DirectoryProvider::getEntry(String const& entryPath)
324 {
325 ✗ gate_directory_entry_t* ptr_entry = NULL;
326 ✗ result_t result = gate_directory_provider_get_entry_by_path(this->c_impl(), entryPath.c_impl(), &ptr_entry);
327 ✗ GATEXX_CHECK_EXCEPTION(result);
328 ✗ return DirectoryEntry(ptr_entry);
329 }
330 ✗ DirectoryEntry DirectoryProvider::getEntryByUid(String const& entryUid)
331 {
332 ✗ gate_directory_entry_t* ptr_entry = NULL;
333 ✗ result_t result = gate_directory_provider_get_entry_by_uid(this->c_impl(), entryUid.c_impl(), &ptr_entry);
334 ✗ GATEXX_CHECK_EXCEPTION(result);
335 ✗ return DirectoryEntry(ptr_entry);
336 }
337
338 struct GATE_API_LOCAL search_callback_dispatcher_param
339 {
340 DirectoryProvider::SearchDelegate const* ptrDelegate;
341 void* ptrParam;
342 };
343
344 ✗ static gate_bool_t GATE_CALL search_callback_dispatcher(gate_directory_entry_t* ptr_entry, void* param)
345 {
346 ✗ struct search_callback_dispatcher_param* dispParam = (struct search_callback_dispatcher_param*)param;
347 ✗ gate_bool_t ret = true;
348 ✗ DirectoryEntry entry(ptr_entry);
349 ✗ gate_object_retain(ptr_entry);
350 ✗ GATEXX_TRY_CATCHALL(
351 {
352 dispParam->ptrDelegate->invoke(entry, ret, dispParam->ptrParam);
353 },
354 {
355 ret = false;
356 }
357 );
358 ✗ return ret;
359 }
360
361
362 ✗ void DirectoryProvider::searchEntries(DirectoryEntry root, String const& query, enumint_t searchFlags,
363 SearchDelegate const& callback, void* callbackParam)
364 {
365 result_t result;
366 struct search_callback_dispatcher_param dispParam;
367 ✗ dispParam.ptrDelegate = &callback;
368 ✗ dispParam.ptrParam = callbackParam;
369
370 ✗ result = gate_directory_provider_search_entries(
371 this->c_impl(), root.c_impl(), query.c_impl(), searchFlags,
372 &search_callback_dispatcher, &dispParam);
373 ✗ GATEXX_CHECK_EXCEPTION(result);
374 ✗ }
375
376 ✗ bool DirectoryProvider::hasChild(DirectoryEntry root, String const& classUid, String const& name, Optional<DirectoryEntry>* ptrEntry)
377 {
378 ✗ result_t result = gate_directory_provider_get_child_entry(this->c_impl(), root.c_impl(), classUid.c_impl(), name.c_impl(), NULL);
379 ✗ return GATE_SUCCEEDED(result);
380 }
381 ✗ DirectoryEntry DirectoryProvider::getChild(DirectoryEntry root, String const& classUid, String const& name)
382 {
383 ✗ gate_directory_entry_t* ptr_entry = NULL;
384 ✗ result_t result = gate_directory_provider_get_child_entry(this->c_impl(), root.c_impl(), classUid.c_impl(), name.c_impl(), &ptr_entry);
385 ✗ GATEXX_CHECK_EXCEPTION(result);
386 ✗ return DirectoryEntry(ptr_entry);
387 }
388
389 ✗ DirectoryEntry DirectoryProvider::createEntry(DirectoryEntry parent, String const& classUid, String const& childName,
390 Map<String, Value> const& properties, Stream* optionalStream)
391 {
392 ✗ gate_directory_entry_t* ptr_entry = NULL;
393 ✗ result_t result = gate_directory_provider_create_entry(this->c_impl(), parent.c_impl(), classUid.c_impl(),
394 childName.c_impl(), properties.c_impl(),
395 (optionalStream ? optionalStream->c_impl() : NULL),
396 &ptr_entry);
397 ✗ GATEXX_CHECK_EXCEPTION(result);
398 ✗ return DirectoryEntry(ptr_entry);
399 }
400 ✗ void DirectoryProvider::deleteEntry(DirectoryEntry entry)
401 {
402 ✗ result_t result = gate_directory_provider_delete_entry(this->c_impl(), entry.c_impl());
403 ✗ GATEXX_CHECK_EXCEPTION(result);
404 ✗ }
405 ✗ DirectoryEntry DirectoryProvider::copyEntry(DirectoryEntry source, DirectoryEntry targetContainer, String const& newName, enumint_t copyFlags)
406 {
407 ✗ gate_directory_entry_t* ptr_entry = NULL;
408 ✗ result_t result = gate_directory_provider_copy_entry(this->c_impl(), source.c_impl(), targetContainer.c_impl(),
409 newName.c_impl(), copyFlags, &ptr_entry);
410 ✗ GATEXX_CHECK_EXCEPTION(result);
411 ✗ return DirectoryEntry(ptr_entry);
412 }
413 ✗ DirectoryEntry DirectoryProvider::moveEntry(DirectoryEntry source, DirectoryEntry targetContainer, String const& newName, enumint_t moveFlags)
414 {
415 ✗ gate_directory_entry_t* ptr_entry = NULL;
416 ✗ result_t result = gate_directory_provider_move_entry(this->c_impl(), source.c_impl(), targetContainer.c_impl(),
417 newName.c_impl(), moveFlags, &ptr_entry);
418 ✗ GATEXX_CHECK_EXCEPTION(result);
419 ✗ return DirectoryEntry(ptr_entry);
420 }
421
422 ✗ Stream DirectoryProvider::openStream(DirectoryEntry source, String const& streamName, enumint_t openFlags)
423 {
424 ✗ gate_stream_t* ptr_stream = NULL;
425 ✗ result_t result = gate_directory_provider_open_stream(this->c_impl(), source.c_impl(), streamName.c_impl(),
426 openFlags, &ptr_stream);
427 ✗ GATEXX_CHECK_EXCEPTION(result);
428 ✗ return Stream(ptr_stream);
429 }
430
431
432
433 } // end of namespace gate
434