Dawn Framework 1.0
Universal data acquisition framework for embedded systems
handler.cxx
1// dawn/src/system/handler.cxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#include "dawn/system/handler.hxx"
7
8#include "dawn/debug.hxx"
9
10using namespace dawn;
11
12void CSystemHandler::objallocPriv(CHandler &obj, CDescObject &desc)
13{
15 {
16 CSystemHandler &t = static_cast<CSystemHandler &>(obj);
17 CSystemCommon *tmp = t.create(desc);
18
19 if (tmp == nullptr)
20 {
21 DAWNERR("Failed to create SYSTEM object 0x%" PRIx32 "\n", desc.getObjectIdV());
22 t.allocError = -ENOMEM;
23 return;
24 }
25
26 DAWNINFO("created SYSTEM: 0x%" PRIx32 " %p\n", desc.getObjectIdV(), tmp);
27 t.registerObject(tmp);
28 }
29}
30
31CSystemCommon *CSystemHandler::create(CDescObject &desc)
32{
33 if (userFactory != nullptr)
34 {
35 CSystemCommon *ret = userFactory->create(desc);
36 if (ret != nullptr)
37 {
38 return ret;
39 }
40 }
41
42 return factory.create(desc);
43}
44
45int CSystemHandler::objalloc(CDescriptor &desc)
46{
47 return CGenericHandler<CSystemCommon>::objalloc(desc, objallocPriv);
48}
49
50int CSystemHandler::init(CDescriptor &desc, ISystemFactory *f)
51{
52 userFactory = f;
53 return objalloc(desc);
54}
Descriptor wrapper for individual object configuration.
SObjectId::ObjectId getObjectIdV() const
Get object identifier as raw 32-bit value.
SObjectId::UObjectId & getObjectId() const
Get object identifier as union structure.
Binary device descriptor manager.
int registerObject(T *obj)
Register object.
int objalloc(CDescriptor &desc, CDescriptor::allocobj_func_t func)
Allocate objects from descriptor.
Base implementation of IHandler interface.
Definition handler.hxx:110
Base class for OBJTYPE_ANY configuration objects.
Definition common.hxx:25
Handler for SYSTEM objects (OBJTYPE_ANY, cls != 0).
Definition handler.hxx:17
Interface for user-provided dev object factories.
Definition factory.hxx:16
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
static bool objectIsSystem(const UObjectId &objid)
Check if object is a System object (raw 32-bit version).
Definition objectid.hxx:402