hololinked.core.meta.DescriptorRegistry
A registry for the descriptors of a Thing class or Thing instance.
Provides a dictionary interface to access the descriptors under the descriptors attribute.
Each of properties, actions and events subclasss from here to implement a registry of their available objects.
Source code in repo/hololinked/hololinked/core/meta.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
Attributes
owner
property
The owner of the registry - the instance of a Thing if a Thing has been instantiated or the class/subclass of Thing when accessed as a class attribute.
descriptor_object
property
The type of descriptor object that this registry holds, i.e. Property, Action or Event.
descriptors
property
A dictionary with all the descriptors as values and their names as keys.
values
property
The values contained within the descriptors after reading when accessed at instance level, otherwise, the descriptor objects as dictionary when accessed at class level.
Functions
__init__
Initialize the registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ThingMeta
|
The class/subclass of the |
required |
|
Thing | None
|
The instance of the |
None
|
Source code in repo/hololinked/hololinked/core/meta.py
clear
Deletes the descriptors dictionary (value of the descriptors property) so that it can be recreated.
Does not delete the descriptors themselves. Call this method once if new descriptors are added to the class/instance dynamically in runtime.
Source code in repo/hololinked/hololinked/core/meta.py
get_descriptors
A dictionary with all the descriptors as values and their names as keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
if |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
descriptors |
dict[str, Property | Action | Event]
|
the descriptors of this registry, keyed by their names |
Source code in repo/hololinked/hololinked/core/meta.py
get_values
The values contained within the descriptors after reading when accessed at instance level, otherwise, the descriptor objects as dictionary when accessed at class level.
For example, if a Thing instance's property contains a value of 5, this method will return
{ property_name : 5 } when accessed at instance level, and { property_name : property_object } when accessed
at class level.
This method is also the getter of the values property.
Returns:
| Name | Type | Description |
|---|---|---|
values |
dict[str, Any]
|
the value of each descriptor at instance level, or the descriptor objects at class level |
Source code in repo/hololinked/hololinked/core/meta.py
dunder
Apart from the above __getitem__, __contains__, __dir__, __iter__, __len__, __hash__, __str__ are supported