Nebula
Toggle main menu visibility
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
//------------------------------------------------------------------------------
24
namespace
Core
25
{
26
class
RefCounted
;
27
class
Rtti
;
28
29
//------------------------------------------------------------------------------
30
class
Factory
31
{
32
public
:
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
59
private
:
61
Factory
();
63
~Factory
();
64
65
static
Factory
*
Singleton
;
66
Util::HashTable<Util::String, const Rtti*, 1024>
nameTable
;
// for fast lookup by class name
67
Util::Dictionary<Util::FourCC, const Rtti*>
fourccTable
;
// for fast lookup by fourcc code
68
};
69
70
}
// namespace Foundation
71
//------------------------------------------------------------------------------
array.h
Core::Factory::fourccTable
Util::Dictionary< Util::FourCC, const Rtti * > fourccTable
Definition
factory.h:67
Core::Factory::Singleton
static Factory * Singleton
Definition
factory.h:65
Core::Factory::~Factory
~Factory()
destructor is private
Definition
factory.cc:63
Core::Factory::Instance
static Factory * Instance()
get pointer to singleton instance (cannot use singleton.h!)
Definition
factory.cc:22
Core::Factory::CreateArray
void * CreateArray(const Util::String &className, SizeT num) const
create an array of objects by class name
Definition
factory.cc:242
Core::Factory::Register
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
Core::Factory::ClassExists
bool ClassExists(const Util::String &className) const
check if a class exists by class name
Definition
factory.cc:147
Core::Factory::Factory
Factory()
constructor is private
Definition
factory.cc:53
Core::Factory::nameTable
Util::HashTable< Util::String, const Rtti *, 1024 > nameTable
Definition
factory.h:66
Core::Factory::Create
void * Create(const Util::String &className) const
create an object by class name
Definition
factory.cc:192
Core::Factory::GetClassRtti
const Rtti * GetClassRtti(const Util::String &className) const
get class rtti object by name
Definition
factory.cc:169
Core::Factory::Destroy
static void Destroy()
static instance destruction method
Definition
factory.cc:39
Core::RefCounted
The common base class of Nebula.
Definition
refcounted.h:38
Core::Rtti
Nebula's runtime type information for one class.
Definition
rtti.h:27
Util::Dictionary
A collection of key/value pairs with quick value retrieval by key at roughly O(log n).
Definition
dictionary.h:35
Util::FourCC
A four-character-code is a quasi-human-readable 32-bit-id.
Definition
fourcc.h:19
Util::HashTable
Organizes key/value pairs by a hash code.
Definition
hashtable.h:42
dictionary.h
fourcc.h
hashtable.h
Core
Definition
coreserver.cc:11
ptr.h
string.h
Util.String
Nebula's universal string class.
Definition
String.cs:8
SizeT
int SizeT
Definition
types.h:42
code
foundation
core
factory.h
Generated on
for Nebula. Dark theme by
Tilen Majerle
. All rights reserved.