Kigs Framework  Doc version 0.8
Open source multi purpose Rapid Application Development framework
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
KigsCore Class Reference

#include <Core.h>

Classes

struct  decorateMethodPair
 decorator map More...
 

Public Member Functions

InstanceFactoryGetInstanceFactory ()
 return instance factory More...
 
MiniInstanceFactory * GetUpgradorFactory () const
 
kigs::unordered_map< kstl::string, CoreItemOperatorCreateMethod > & GetDefaultCoreItemOperatorConstructMap ()
 return the map for CoreItemOperator creation in general purpose case More...
 
void CleanSingletonMap ()
 
MEMORYMANAGEMENT_START MemoryManager * GetMemoryManager ()
 retreive the memory manager More...
 
void GetSemaphore ()
 add a semaphore to the core
 
void ReleaseSemaphore ()
 release a semaphore from the core
 
template<>
CMSP GetInstanceOf (const kstl::string &instancename, const KigsID &classname)
 

Static Public Member Functions

static void Init ()
 Init create the unique instance and all members (memory manager, instance factory...) More...
 
static void ModuleInit (KigsCore *core, ModuleBase *module)
 register a module in the map More...
 
static void Close (bool closeMemoryManager=true)
 delete all unique instance members More...
 
static KigsCoreInstance ()
 return unique instance of KigsCore More...
 
static CoreBaseApplicationGetCoreApplication ()
 
static NotificationCenterGetNotificationCenter ()
 
static ModuleBase * GetModule (const KigsID &classname)
 get the registered module given its name
 
template<typename... Args>
static CMSP GetInstanceOf (const kstl::string &instancename, const KigsID &classname, Args &&... args)
 return an instance of the given class More...
 
static CMSP & GetSingleton (const KigsID &classname)
 return an unique instance of the given class (Design Pattern Singleton) More...
 
static void ReleaseSingleton (KigsID classname)
 destroy the unique instance of the given class More...
 
static CoreTreeNodeGetRootNode ()
 return inheritance tree root node
 
static void ModuleStaticInit (KigsCore *core)
 for the core unique instance to be unique even in windows dll More...
 
static bool IsInit ()
 check for init More...
 
static bool IsMultiThread ()
 check for multithread More...
 
template<class Module_Type >
static Module_Type * LoadKigsModule (const std::string &Module_Type_Name, const kstl::vector< CoreModifiableAttribute * > *params=0)
 Load and initialize the given module. More...
 
static const char * GetErrorBuffer ()
 get the error buffer More...
 
static void DumpMessageBuffer ()
 dump the message buffer More...
 
static void SetMessagePrintf (int(*)(const char *format...))
 print function
 
static void SetMessagePrintf (void *func)
 print function
 
static void AddError (const char *, long, const kstl::string &, int errorLevel=0)
 add an error in the error buffer More...
 
static void AddWarning (const char *, long, const kstl::string &, int warningLevel=0)
 add a warning in the error buffer More...
 
static void AddMessage (const kstl::string &)
 add a message in the error buffer More...
 
static GlobalProfilerManager * GetProfileManager ()
 Get the unique instance of GlobalProfilerManager. More...
 
static CoreModifiableGetThreadProfiler ()
 Get the unique instance of ThreadProfiler. More...
 
static kigs::unordered_map< CoreModifiable *, kstl::vector< CoreModifiableAttribute * > > & getReferenceMap ()
 Get the map of referenced CoreModifiable (maReference) More...
 
static bool ParseXml (const kstl::string &filename, CoreModifiable *delegateObject, const char *force_as_format=0)
 Parse the given xml file, using delegateObject as delegate. More...
 

Protected Member Functions

void ProtectedAddError (const kstl::string &Error)
 add a message in the error buffer More...
 
void ProtectedDumpMessageBuffer ()
 dump the message buffer
 
 KigsCore ()
 protected constructor
 
 ~KigsCore ()
 protected destructor
 
void ManagePostDestruction ()
 manage post destruction
 

Static Protected Member Functions

static void SetCoreApplication (CoreBaseApplication *_instance)
 
static void SetNotificationCenter (NotificationCenter *_instance)
 
static void SetMultiThread ()
 set the KigsCore multiTread
 
static void CloseMultiThread ()
 remove the multiThread management of the KigsCore
 

Protected Attributes

InstanceFactorymInstanceFactory
 pointer to instance factory singleton
 
kigs::unordered_map< KigsID, ModuleBase * > * mModuleBaseInstanceMap
 pointer to initialised modules
 
kigs::unordered_map< KigsID, CMSP > * mSingletonMap
 pointer to created singletons
 
std::mutex mPostDestructionListMutex
 manage post destruction
 
kigs::unordered_map< CoreModifiable *, kstl::vector< CoreModifiableAttribute * > > * mReferenceMap
 CoreModifiable referenced by maReference.
 
MEMORYMANAGEMENT_START MemoryManager * mMemoryInstance
 pointer the memory manager instance
 
MEMORYMANAGEMENT_END CoreTreeNodemRootNode
 pointer to the root of the class inheritance tree
 
CMSP mSemaphore
 list of semaphore
 
bool * mMultiThread
 TRUE if the KigsCore is multiThread.
 
kstl::vector< kstl::string > * mErrorList
 list of error
 
int(* KigsMsgPrintf )(const char *format...)
 output function for error and warning msb
 
GlobalProfilerManager * mProfilerManager
 Profilers management.
 

Static Protected Attributes

static KigsCoremCoreInstance =0
 static pointer to the KigsCore singleton More...
 

Friends

class CoreBaseApplication
 
class ModuleThread
 

Detailed Description


Singleton class used to manage all others.

Member Function Documentation

◆ AddError()

void KigsCore::AddError ( const char *  errfile,
long  errline,
const kstl::string &  errorstring,
int  errorLevel = 0 
)
static

add an error in the error buffer

Parameters
char*: file in which the error appears
long: line number of the error appears
string: error message
errorLevel: error level in [0,3]

◆ AddMessage()

void KigsCore::AddMessage ( const kstl::string &  errorstring)
static

add a message in the error buffer

Parameters
string: message

◆ AddWarning()

void KigsCore::AddWarning ( const char *  errfile,
long  errline,
const kstl::string &  errorstring,
int  warningLevel = 0 
)
static

add a warning in the error buffer

Parameters
char: file in which the warning appears
long: line number of the warning appears
string: warning message
warningLevel: warning level in [0,3]

◆ CleanSingletonMap()

void KigsCore::CleanSingletonMap ( )

do nothing if no instance of the class

◆ Close()

void KigsCore::Close ( bool  closeMemoryManager = true)
static

delete all unique instance members

Close KigsCore

Parameters
closeMemoryManager: set to true if the memory manager needs to be closed too ( in case Kigs framework is build with MemoryManager )

◆ DumpMessageBuffer()

void KigsCore::DumpMessageBuffer ( )
static

dump the message buffer

use KIGS_DUMP_MESSAGES

◆ GetCoreApplication()

CoreBaseApplication * KigsCore::GetCoreApplication ( )
static

Get the GetCoreApplication instance (Design Pattern Singleton)

Returns
the unique instance of the CoreBaseApplication or null if no application is defined

◆ GetDefaultCoreItemOperatorConstructMap()

kigs::unordered_map< kstl::string, CoreItemOperatorCreateMethod > & KigsCore::GetDefaultCoreItemOperatorConstructMap ( )

return the map for CoreItemOperator creation in general purpose case

Returns
kigs::unordered_map<kstl::string, CoreItemOperatorCreateMethod>&

◆ GetErrorBuffer()

static const char * KigsCore::GetErrorBuffer ( )
static

get the error buffer

Returns
the error buffer

use Macro KIGS_ERROR to add errors

◆ GetInstanceFactory()

InstanceFactory * KigsCore::GetInstanceFactory ( )

return instance factory

Get the instance factory instance (Design Pattern Singleton)

Returns
the unique instance factory

◆ GetInstanceOf() [1/2]

template<>
CMSP KigsCore::GetInstanceOf ( const kstl::string &  instancename,
const KigsID &  classname 
)
inline

if instance factory fail then create a DoNothingObject (and print debug messages)

◆ GetInstanceOf() [2/2]

template<typename... Args>
CMSP KigsCore::GetInstanceOf ( const kstl::string &  instancename,
const KigsID &  classname,
Args &&...  args 
)
inlinestatic

return an instance of the given class

Parameters
instancename: name of the instance
classname: name of the class
Returns
an CMSP (smartpointer on instance) of the asked class or a DoNothingObject if failed

get the instance of 'classname' named 'instancename' or call the instance factory if not exist
return a DoNothingObject if the factory failed

if instance factory fail then create a DoNothingObject (and print debug messages)

◆ GetMemoryManager()

MEMORYMANAGEMENT_START MemoryManager * KigsCore::GetMemoryManager ( )

retreive the memory manager

return memory manager

◆ GetNotificationCenter()

NotificationCenter * KigsCore::GetNotificationCenter ( )
static

Get the NotificationCenter instance (Design Pattern Singleton)

Returns
the unique instance of the NotificationCenter

◆ GetProfileManager()

GlobalProfilerManager * KigsCore::GetProfileManager ( )
static

Get the unique instance of GlobalProfilerManager.

Returns
the unique instance of the GlobalProfilerManager

◆ getReferenceMap()

static kigs::unordered_map< CoreModifiable *, kstl::vector< CoreModifiableAttribute * > > & KigsCore::getReferenceMap ( )
inlinestatic

Get the map of referenced CoreModifiable (maReference)

Returns

◆ GetSingleton()

CMSP & KigsCore::GetSingleton ( const KigsID &  classname)
static

return an unique instance of the given class (Design Pattern Singleton)

Parameters
classname: name of the class
Returns
the unique instance of the asked class or NULL if failed

get the instance of 'classname' or call the instance factory if not exist
return NULL if the factory failed

search for an already existing instance

and return it if found

else create a new instance

◆ GetThreadProfiler()

static CoreModifiable * KigsCore::GetThreadProfiler ( )
inlinestatic

Get the unique instance of ThreadProfiler.

Returns
the unique instance of the ThreadProfiler

◆ GetUpgradorFactory()

MiniInstanceFactory * KigsCore::GetUpgradorFactory ( ) const
inline

Get the MiniInstanceFactory used by Upgrador mechanism

Returns
the MiniInstanceFactory

◆ Init()

void KigsCore::Init ( )
static

Init create the unique instance and all members (memory manager, instance factory...)

Init KigsCore singleton and all its members

root node used by inheritance tree

memory manager

instance factory

map for all initialised modules

map for all singleton

init error management

map for references

declare DoNothingObject (created when unknown object is asked to InstanceFactory)

◆ Instance()

KigsCore * KigsCore::Instance ( )
static

return unique instance of KigsCore

Get the KigsCore instance (Design Pattern Singleton)

Returns
the unique instance of the KigsCore

◆ IsInit()

bool KigsCore::IsInit ( )
static

check for init

Returns
TRUE if the KigsCore has been initialized

◆ IsMultiThread()

bool KigsCore::IsMultiThread ( )
static

check for multithread

return true if thread module is init

Returns
TRUE if the KigsCore is multiThread

◆ LoadKigsModule()

template<class Module_Type >
template< class Module_Type > static Module_Type * KigsCore::LoadKigsModule ( const std::string &  Module_Type_Name,
const kstl::vector< CoreModifiableAttribute * > *  params = 0 
)
inlinestatic

Load and initialize the given module.

Returns
the loaded module

◆ ModuleInit()

void KigsCore::ModuleInit ( KigsCore core,
ModuleBase *  module 
)
static

register a module in the map

Called by modules to be registered in KigsCore

Parameters
core: link to the core, NOT NULL
module: module to register, CAN BE NULL

◆ ModuleStaticInit()

void KigsCore::ModuleStaticInit ( KigsCore core)
static

for the core unique instance to be unique even in windows dll

called by dll module to init correctly their unique instance (Windows dll => each dll has its own static members)

Parameters
core: instance of the KigsCore

◆ ParseXml()

bool KigsCore::ParseXml ( const kstl::string &  filename,
CoreModifiable delegateObject,
const char *  force_as_format = 0 
)
static

Parse the given xml file, using delegateObject as delegate.

Parameters
filename: the name of the file to parse
delegateObject: the CoreModifiable used as delegate
force_as_format: "xml" or "kxml". if nothing is specified, use real extension to define xml or kxml.
Returns
true if everything is fine

The delegateObject will receive the parse information using the following method if it declare/implement them :

DECLARE_METHOD(XMLElementStartDescription); DECLARE_METHOD(XMLElementEndDescription); DECLARE_METHOD(XMLDeclHandler); DECLARE_METHOD(XMLCharacterHandler); COREMODIFIABLE_METHODS(XMLElementStartDescription,XMLElementEndDescription,XMLDeclHandler,XMLCharacterHandler); If the format is force, the extension of the file can be anything (plist, dat, ...)

◆ ProtectedAddError()

void KigsCore::ProtectedAddError ( const kstl::string &  Error)
protected

add a message in the error buffer

Parameters
Error: message

◆ ReleaseSingleton()

void KigsCore::ReleaseSingleton ( KigsID  classname)
static

destroy the unique instance of the given class

Parameters
classname: name of the class

destroy the instance of 'classname' and remove reference as singleton (allow to create another one)

search for an already existing instance

do nothing if no instance of the class

◆ SetCoreApplication()

void KigsCore::SetCoreApplication ( CoreBaseApplication _instance)
staticprotected

Set current CoreBaseApplication

Parameters
_instanceCoreBaseApplication instance

◆ SetNotificationCenter()

void KigsCore::SetNotificationCenter ( NotificationCenter _instance)
staticprotected

Set the NotificationCenter member

Parameters
_instanceNotificationCenter instance

Member Data Documentation

◆ mCoreInstance

KIGS_PREFIX_ERROR KIGS_PREFIX_WARNING KIGS_PREFIX_MESSAGE KigsCore * KigsCore::mCoreInstance =0
staticprotected

static pointer to the KigsCore singleton

core unique instance, used also in all dll


The documentation for this class was generated from the following files: