Nebula
Loading...
Searching...
No Matches
factory.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
16#include "util/array.h"
17#include "util/string.h"
18#include "util/fourcc.h"
19#include "util/dictionary.h"
20#include "util/hashtable.h"
21#include "core/ptr.h"
22
23//------------------------------------------------------------------------------
24namespace Core
25{
26class RefCounted;
27class Rtti;
28
29//------------------------------------------------------------------------------
31{
32public:
34 static Factory* Instance();
36 static void Destroy();
37
39 void Register(const Rtti* rtti, const Util::String& className, const Util::FourCC& classFourCC);
41 void Register(const Rtti* rtti, const Util::String& className);
43 bool ClassExists(const Util::String& className) const;
45 bool ClassExists(const Util::FourCC classFourCC) const;
47 const Rtti* GetClassRtti(const Util::String& className) const;
49 const Rtti* GetClassRtti(const Util::FourCC& classFourCC) const;
51 void* Create(const Util::String& className) const;
53 void* Create(const Util::FourCC classFourCC) const;
55 void* CreateArray(const Util::String& className, SizeT num) const;
57 void* CreateArray(const Util::FourCC classFourCC, SizeT num) const;
58
59private:
61 Factory();
63 ~Factory();
64
68};
69
70} // namespace Foundation
71//------------------------------------------------------------------------------
Provides the central object factory mechanism for Nebula.
Definition factory.h:31
Util::Dictionary< Util::FourCC, const Rtti * > fourccTable
Definition factory.h:67
static Factory * Singleton
Definition factory.h:65
~Factory()
destructor is private
Definition factory.cc:63
static Factory * Instance()
get pointer to singleton instance (cannot use singleton.h!)
Definition factory.cc:22
void * CreateArray(const Util::String &className, SizeT num) const
create an array of objects by class name
Definition factory.cc:242
void Register(const Rtti *rtti, const Util::String &className, const Util::FourCC &classFourCC)
register a RTTI object with the factory (with class name and class fourcc code)
Definition factory.cc:82
bool ClassExists(const Util::String &className) const
check if a class exists by class name
Definition factory.cc:147
Factory()
constructor is private
Definition factory.cc:53
Util::HashTable< Util::String, const Rtti *, 1024 > nameTable
Definition factory.h:66
void * Create(const Util::String &className) const
create an object by class name
Definition factory.cc:192
const Rtti * GetClassRtti(const Util::String &className) const
get class rtti object by name
Definition factory.cc:169
static void Destroy()
static instance destruction method
Definition factory.cc:39
Nebula's runtime type information for one class.
Definition rtti.h:27
A collection of key/value pairs with quick value retrieval by key at roughly O(log n).
Definition dictionary.h:34
A four-character-code is a quasi-human-readable 32-bit-id.
Definition fourcc.h:19
Organizes key/value pairs by a hash code.
Definition hashtable.h:42
Definition coreserver.cc:11
Nebula's universal string class.
Definition string.h:50
int SizeT
Definition types.h:49