Safir SDK Core
Loading...
Searching...
No Matches
ObjectFactory.h
Go to the documentation of this file.
1/******************************************************************************
2*
3* Copyright Saab AB, 2023 (http://safirsdkcore.com)
4*
5* Created by: Lars Hagström / stlrha
6*
7*******************************************************************************
8*
9* This file is part of Safir SDK Core.
10*
11* Safir SDK Core is free software: you can redistribute it and/or modify
12* it under the terms of version 3 of the GNU General Public License as
13* published by the Free Software Foundation.
14*
15* Safir SDK Core is distributed in the hope that it will be useful,
16* but WITHOUT ANY WARRANTY; without even the implied warranty of
17* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18* GNU General Public License for more details.
19*
20* You should have received a copy of the GNU General Public License
21* along with Safir SDK Core. If not, see <http://www.gnu.org/licenses/>.
22*
23******************************************************************************/
24
25#pragma once
26
27#include <memory>
30#include <mutex>
31
32namespace Safir
33{
34namespace Dob
35{
36namespace Typesystem
37{
38 //forward declaration since we would rather not include dots_object.h (Object.cpp includes this file...)
39 class Object;
40
42 typedef std::shared_ptr<Object> ObjectPtr;
43
52 {
53 public:
60
71 ObjectPtr CreateObject(const TypeId typeId) const;
72
84 typedef ObjectPtr (*CreateObjectCallback)(Int64 handle);
85
93 bool RegisterClass(const TypeId typeId, const Int64 checksum, CreateObjectCallback createFunction);
94
117 ObjectPtr CreateObject(char const * const blob) const;
118
126 std::vector<std::pair<TypeId, Int64>> GetRegisteredTypes() const;
127
128 private:
131 ObjectFactory(const ObjectFactory&) = delete;
132 ObjectFactory& operator=(const ObjectFactory&) = delete;
133
134 class Impl;
135
136 Impl* m_impl;
137
144 struct SingletonHelper
145 {
146 private:
147 friend ObjectFactory& ObjectFactory::Instance();
148
149 static ObjectFactory& Instance();
150 static std::once_flag m_onceFlag;
151 };
152 };
153}
154}
155}
156
157
This namespace contains all the functionality and definitions of the SAFIR SDK.
Definition Backdoor.h:31
DotsC_Int64 Int64
64 bit integer type.
Definition Defs.h:69
std::shared_ptr< Object > ObjectPtr
A smart pointer to an Object.
Definition Object.h:44
DotsC_TypeId TypeId
A unique type identifier.
Definition Defs.h:218
This class is an object factory for all automatically generated DOB classes.
Definition ObjectFactory.h:52
std::vector< std::pair< TypeId, Int64 > > GetRegisteredTypes() const
GetRegisteredTypes - Get types wich have been registered in the ObjectFactory.
bool RegisterClass(const TypeId typeId, const Int64 checksum, CreateObjectCallback createFunction)
Register a class with the object factory.
ObjectPtr CreateObject(const TypeId typeId) const
Create a new "empty" object from a typeid.
static ObjectFactory & Instance()
Get the instance of the singleton.
ObjectPtr CreateObject(char const *const blob) const
Create a new object from a blob.
#define DOTS_CPP_API
Definition Defs.h:33