| 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 | /** @file | ||
| 30 | * @brief Abstract interface for directory providers | ||
| 31 | * @ingroup gatecore | ||
| 32 | */ | ||
| 33 | |||
| 34 | #ifndef GATE_DIRECTORIES_H_INCLUDED | ||
| 35 | #define GATE_DIRECTORIES_H_INCLUDED | ||
| 36 | |||
| 37 | #include "gate/gate_core_api.h" | ||
| 38 | #include "gate/objects.h" | ||
| 39 | #include "gate/values.h" | ||
| 40 | #include "gate/delegates.h" | ||
| 41 | #include "gate/streams.h" | ||
| 42 | #include "gate/maps.h" | ||
| 43 | |||
| 44 | #if defined(__cplusplus) | ||
| 45 | extern "C" { | ||
| 46 | #endif | ||
| 47 | |||
| 48 | #define GATE_INTERFACE_NAME_DIRECTORYCLASS GATE_INTERFACE_NAME_OBJECT GATE_INTERFACE_NAME_SEPARATOR "directory_class" | ||
| 49 | |||
| 50 | #define GATE_DIRECTORY_PROPERTY_FLAG_OPTIONAL 0x0001 | ||
| 51 | |||
| 52 | typedef struct gate_directory_propertydef_class | ||
| 53 | { | ||
| 54 | gate_type_id_t data_type; | ||
| 55 | gate_string_t name; | ||
| 56 | gate_uint32_t flags; | ||
| 57 | } gate_directory_propertydef_t; | ||
| 58 | |||
| 59 | GATE_CORE_API gate_directory_propertydef_t* gate_directory_propertydef_create(gate_directory_propertydef_t* propdef, | ||
| 60 | gate_type_id_t type, | ||
| 61 | gate_string_t const* name, | ||
| 62 | gate_uint32_t flags); | ||
| 63 | |||
| 64 | GATE_CORE_API void gate_directory_propertydef_release(gate_directory_propertydef_t* propdef); | ||
| 65 | |||
| 66 | |||
| 67 | /** @brief directory class instances can contain child directory entries */ | ||
| 68 | #define GATE_DIRECTORY_CLASS_FLAG_CONTAINER 0x0001 | ||
| 69 | |||
| 70 | /** @brief directory class instances can contain streams */ | ||
| 71 | #define GATE_DIRECTORY_CLASS_FLAG_STREAMS 0x0002 | ||
| 72 | |||
| 73 | /** @brief directory class instances can be dynamically created */ | ||
| 74 | #define GATE_DIRECTORY_CLASS_FLAG_CREATABLE 0x0004 | ||
| 75 | |||
| 76 | GATE_INTERFACE(gate_directory_class) | ||
| 77 | { | ||
| 78 | GATE_METHOD0(char const*, get_interface_name); | ||
| 79 | GATE_METHOD0(void, release); | ||
| 80 | GATE_METHOD0(int, retain); | ||
| 81 | |||
| 82 | GATE_METHOD1(gate_result_t, uid, gate_string_t * return_uid); | ||
| 83 | GATE_METHOD1(gate_result_t, name, gate_string_t * return_name); | ||
| 84 | GATE_METHOD1(gate_result_t, flags, gate_uint32_t * return_flags); | ||
| 85 | |||
| 86 | GATE_METHOD1(gate_result_t, get_properties_count, gate_size_t * return_count); | ||
| 87 | GATE_METHOD2(gate_result_t, get_property, gate_size_t index, gate_directory_propertydef_t * return_prop_def); | ||
| 88 | GATE_METHOD2(gate_result_t, find_property, gate_string_t const* name, gate_directory_propertydef_t * return_prop_def); | ||
| 89 | |||
| 90 | GATE_METHOD1(gate_result_t, get_superior_classes_count, gate_size_t * return_count); | ||
| 91 | GATE_METHOD2(gate_result_t, get_superior_class_uid, gate_size_t index, gate_string_t * return_class_uid); | ||
| 92 | |||
| 93 | GATE_METHOD1(gate_result_t, get_containment_classes_count, gate_size_t * return_count); | ||
| 94 | GATE_METHOD2(gate_result_t, get_containment_class_uid, gate_size_t index, gate_string_t * return_class_uid); | ||
| 95 | }; | ||
| 96 | |||
| 97 | #define gate_directory_class_uid(obj, return_uid) (obj)->vtbl->uid((obj), return_uid) | ||
| 98 | #define gate_directory_class_name(obj, return_name) (obj)->vtbl->name((obj), return_name) | ||
| 99 | #define gate_directory_class_flags(obj, return_flags) (obj)->vtbl->flags((obj), return_flags) | ||
| 100 | |||
| 101 | #define gate_directory_class_get_properties_count(obj, return_count) (obj)->vtbl->get_properties_count((obj), return_count) | ||
| 102 | #define gate_directory_class_get_property(obj, index, return_prop_def) (obj)->vtbl->get_property((obj), index, return_prop_def) | ||
| 103 | #define gate_directory_class_find_property(obj, name, return_prop_def) (obj)->vtbl->find_property((obj), name, return_prop_def) | ||
| 104 | |||
| 105 | #define gate_directory_class_get_superior_classes_count(obj, return_count) (obj)->vtbl->get_superior_classes_count((obj), return_count) | ||
| 106 | #define gate_directory_class_get_superior_class_uid(obj, index, return_class_uid) (obj)->vtbl->get_superior_class_uid((obj), index, return_class_uid) | ||
| 107 | |||
| 108 | #define gate_directory_class_get_containment_classes_count(obj, return_count) (obj)->vtbl->get_containment_classes_count((obj), return_count) | ||
| 109 | #define gate_directory_class_get_containment_class_uid(obj, index, return_class_uid) (obj)->vtbl->get_containment_class_uid((obj), index, return_class_uid) | ||
| 110 | |||
| 111 | |||
| 112 | |||
| 113 | |||
| 114 | #define GATE_INTERFACE_NAME_DIRECTORYENTRY GATE_INTERFACE_NAME_OBJECT GATE_INTERFACE_NAME_SEPARATOR "directory_entry" | ||
| 115 | |||
| 116 | GATE_INTERFACE(gate_directory_entry) | ||
| 117 | { | ||
| 118 | GATE_METHOD0(char const*, get_interface_name); | ||
| 119 | GATE_METHOD0(void, release); | ||
| 120 | GATE_METHOD0(int, retain); | ||
| 121 | |||
| 122 | GATE_METHOD1(gate_result_t, entry_uid, gate_string_t * return_entry_uid); | ||
| 123 | GATE_METHOD1(gate_result_t, class_uid, gate_string_t * return_class_uid); | ||
| 124 | |||
| 125 | GATE_METHOD1(gate_result_t, path, gate_string_t * return_path); | ||
| 126 | GATE_METHOD1(gate_result_t, name, gate_string_t * return_name); | ||
| 127 | GATE_METHOD1(gate_result_t, parent_path, gate_string_t * return_parent); | ||
| 128 | |||
| 129 | GATE_METHOD2(gate_result_t, get_property, gate_string_t const* prop_name, gate_value_t * return_value); | ||
| 130 | GATE_METHOD2(gate_result_t, set_property, gate_string_t const* prop_name, gate_value_t const* value); | ||
| 131 | GATE_METHOD0(gate_result_t, refresh_properties); | ||
| 132 | }; | ||
| 133 | |||
| 134 | #define gate_directory_entry_entry_uid(obj, return_entry_uid) (obj)->vtbl->entry_uid((obj), return_entry_uid) | ||
| 135 | #define gate_directory_entry_class_uid(obj, return_class_uid) (obj)->vtbl->class_uid((obj), return_class_uid) | ||
| 136 | |||
| 137 | #define gate_directory_entry_path(obj, return_path) (obj)->vtbl->path((obj), return_path) | ||
| 138 | #define gate_directory_entry_name(obj, return_name) (obj)->vtbl->name((obj), return_name) | ||
| 139 | #define gate_directory_entry_parent_path(obj, return_parent) (obj)->vtbl->parent_path((obj), return_parent) | ||
| 140 | |||
| 141 | #define gate_directory_entry_get_property(obj, prop_name, return_value) (obj)->vtbl->get_property((obj), prop_name, return_value) | ||
| 142 | #define gate_directory_entry_set_property(obj, prop_name, value) (obj)->vtbl->set_property((obj), prop_name, value) | ||
| 143 | #define gate_directory_entry_refresh_properties(obj) (obj)->vtbl->refresh_properties((obj)) | ||
| 144 | |||
| 145 | |||
| 146 | #define GATE_INTERFACE_NAME_DIRECTORYPROVIDER GATE_INTERFACE_NAME_OBJECT GATE_INTERFACE_NAME_SEPARATOR "directory_provider" | ||
| 147 | |||
| 148 | |||
| 149 | ✗ | GATE_DELEGATE_DECLARE_3(gate_directory_search_cb, | |
| 150 | gate_directory_entry_t* /* found entry */, | ||
| 151 | gate_bool_t* /* cancel_search */, | ||
| 152 | void* /* cb_param */); | ||
| 153 | |||
| 154 | GATE_INTERFACE(gate_directory_provider) | ||
| 155 | { | ||
| 156 | GATE_METHOD0(char const*, get_interface_name); | ||
| 157 | GATE_METHOD0(void, release); | ||
| 158 | GATE_METHOD0(int, retain); | ||
| 159 | |||
| 160 | GATE_METHOD1(gate_result_t, provider_name, gate_string_t * return_name); | ||
| 161 | GATE_METHOD1(gate_result_t, get_classes_count, gate_size_t * return_count); | ||
| 162 | GATE_METHOD2(gate_result_t, get_class, gate_size_t index, gate_directory_class_t * *return_class_ptr); | ||
| 163 | GATE_METHOD2(gate_result_t, find_class, gate_string_t const* class_uid, gate_directory_class_t * *return_class_ptr); | ||
| 164 | |||
| 165 | GATE_METHOD2(gate_result_t, get_entry_by_path, gate_string_t const* path, gate_directory_entry_t * *return_entry_ptr); | ||
| 166 | GATE_METHOD2(gate_result_t, get_entry_by_uid, gate_string_t const* uid, gate_directory_entry_t * *return_entry_ptr); | ||
| 167 | |||
| 168 | GATE_METHOD5(gate_result_t, search_entries, gate_directory_entry_t * search_root, gate_string_t const* query, gate_uint32_t search_flags, | ||
| 169 | gate_delegate_t const* callback, void* callback_param); | ||
| 170 | |||
| 171 | GATE_METHOD4(gate_result_t, get_child_entry, gate_directory_entry_t * parent, | ||
| 172 | gate_string_t const* class_uid, gate_string_t const* child_name, | ||
| 173 | gate_directory_entry_t * *return_entry_ptr); | ||
| 174 | |||
| 175 | GATE_METHOD6(gate_result_t, create_entry, gate_directory_entry_t * parent, | ||
| 176 | gate_string_t const* class_uid, gate_string_t const* child_name, | ||
| 177 | gate_map_t const* propname_to_value_map, gate_stream_t * stream_to_copy, | ||
| 178 | gate_directory_entry_t * *return_entry_ptr); | ||
| 179 | |||
| 180 | GATE_METHOD1(gate_result_t, delete_entry, gate_directory_entry_t * entry); | ||
| 181 | |||
| 182 | GATE_METHOD5(gate_result_t, copy_entry, gate_directory_entry_t * source, gate_directory_entry_t * target_container, | ||
| 183 | gate_string_t const* new_name, gate_uint32_t copy_flags, | ||
| 184 | gate_directory_entry_t * *return_entry_ptr); | ||
| 185 | |||
| 186 | GATE_METHOD5(gate_result_t, move_entry, gate_directory_entry_t * source, gate_directory_entry_t * target_container, | ||
| 187 | gate_string_t const* new_name, gate_uint32_t move_flags, | ||
| 188 | gate_directory_entry_t * *return_entry_ptr); | ||
| 189 | |||
| 190 | GATE_METHOD4(gate_result_t, open_stream, gate_directory_entry_t * source, gate_string_t const* stream_name, gate_uint32_t open_flags, | ||
| 191 | gate_stream_t * *return_stream); | ||
| 192 | |||
| 193 | }; | ||
| 194 | |||
| 195 | |||
| 196 | #define gate_directory_provider_provider_name(obj, return_name) \ | ||
| 197 | (obj)->vtbl->provider_name((obj), return_name) | ||
| 198 | |||
| 199 | #define gate_directory_provider_get_classes_count(obj, return_count) \ | ||
| 200 | (obj)->vtbl->get_classes_count((obj), return_count) | ||
| 201 | |||
| 202 | #define gate_directory_provider_get_class(obj, index, return_class_ptr) \ | ||
| 203 | (obj)->vtbl->get_class((obj), index, return_class_ptr) | ||
| 204 | |||
| 205 | #define gate_directory_provider_find_class(obj, class_uid, return_class_ptr) \ | ||
| 206 | (obj)->vtbl->find_class((obj), class_uid, return_class_ptr) | ||
| 207 | |||
| 208 | #define gate_directory_provider_get_entry_by_path(obj, path, return_entry_ptr) \ | ||
| 209 | (obj)->vtbl->get_entry_by_path((obj), path, return_entry_ptr) | ||
| 210 | |||
| 211 | #define gate_directory_provider_get_entry_by_uid(obj, uid, return_entry_ptr) \ | ||
| 212 | (obj)->vtbl->get_entry_by_uid((obj), uid, return_entry_ptr) | ||
| 213 | |||
| 214 | #define gate_directory_provider_search_entries(obj, search_root, query, search_flags, callback, callback_param) \ | ||
| 215 | (obj)->vtbl->search_entries((obj), search_root, query, search_flags, callback, callback_param) | ||
| 216 | |||
| 217 | #define gate_directory_provider_get_child_entry(obj, parent, class_uid, child_name, return_entry_ptr) \ | ||
| 218 | (obj)->vtbl->get_child_entry((obj), parent, class_uid, child_name, return_entry_ptr) | ||
| 219 | |||
| 220 | #define gate_directory_provider_create_entry(obj, parent, class_uid, child_name, propname_to_value_map, stream_to_copy, return_entry_ptr) \ | ||
| 221 | (obj)->vtbl->create_entry((obj), parent, class_uid, child_name, propname_to_value_map, stream_to_copy, return_entry_ptr) | ||
| 222 | |||
| 223 | #define gate_directory_provider_delete_entry(obj, entry) \ | ||
| 224 | (obj)->vtbl->delete_entry((obj), entry) | ||
| 225 | |||
| 226 | #define gate_directory_provider_copy_entry(obj, source, target_container, new_name, copy_flags, return_entry_ptr) \ | ||
| 227 | (obj)->vtbl->copy_entry((obj), source, target_container, new_name, copy_flags, return_entry_ptr) | ||
| 228 | |||
| 229 | #define gate_directory_provider_move_entry(obj, source, target_container, new_name, move_flags, return_entry_ptr) \ | ||
| 230 | (obj)->vtbl->move_entry((obj), source, target_container, new_name, move_flags, return_entry_ptr) | ||
| 231 | |||
| 232 | #define gate_directory_provider_open_stream(obj, source, stream_name, open_flags, return_stream) \ | ||
| 233 | (obj)->vtbl->open_stream((obj), source, stream_name, open_flags, return_stream) | ||
| 234 | |||
| 235 | |||
| 236 | |||
| 237 | #if defined(__cplusplus) | ||
| 238 | } | ||
| 239 | #endif | ||
| 240 | |||
| 241 | #endif | ||
| 242 | |||
| 243 |