Drag[en]gine Game Engine  1.0
deModuleSystem Class Reference

Module System. More...

#include <deModuleSystem.h>

Public Types

enum  eModuleTypes {
  emtUnknown, emtGraphic, emtAudio, emtInput,
  emtNetwork, emtPhysics, emtImage, emtVideo,
  emtScript, emtModel, emtRig, emtSkin,
  emtAnimation, emtFont, emtCrashRecovery, emtLanguagePack,
  emtAnimator, emtSound, emtAI, emtOcclusionMesh,
  emtSynthesizer, EMT_COUNT
}
 

Public Member Functions

Constructors and Destructors
 deModuleSystem (deEngine *engine)
 
 ~deModuleSystem ()
 
Management
deEngineGetEngine () const
 
void DetectModules ()
 
Module Management
int GetModuleCount () const
 Retrieves the count of modules. More...
 
int GetModuleCountFor (eModuleTypes type) const
 Retrieves the count of modules of a given type. More...
 
int GetLoadedModuleCountFor (eModuleTypes type) const
 Retrieves the count of loaded modules of a given type. More...
 
deLoadableModuleGetModuleAt (int index) const
 Retrieves the module at the given index. More...
 
deLoadableModuleGetModuleNamed (const char *name) const
 Retrieves the highest version module with the given name or NULL if not found. More...
 
deLoadableModuleGetModuleNamed (const char *name, const char *version) const
 Retrieves the module with the given name and version or NULL if not found. More...
 
deLoadableModuleGetFirstLoadedModuleFor (eModuleTypes type) const
 Retrieves the first loaded module for the given type or NULL if not found. More...
 
deLoadableModuleFindMatching (eModuleTypes type, const char *filename) const
 Retrieves the first module of the given type able to handle the given file. More...
 
deBaseModuleGetModuleAbleToLoad (eModuleTypes type, const char *filename) const
 Retrieves the first modules of the given type able to handle the given file. More...
 
void AddModule (deLoadableModule *module)
 

Helper Functions

bool MatchesPattern (const char *filename, const char *pattern) const
 
bool StrEqual (const char *str1, const char *str2, int length) const
 
static int CompareVersion (const char *version1, const char *version2)
 Compare two module versions. More...
 
static eModuleTypes GetTypeFromString (const char *typeString)
 
static const char * GetTypeDirectory (eModuleTypes type)
 
static bool IsSingleType (eModuleTypes type)
 

Detailed Description

Module System.

This is a special system and not to be confused with single type or multiple type engine systems. The module system keeps track of all modules existing in the engine no matter if loaded or not. All modules that can be parsed are stored in the module system. If a module can not be loaded it still stays here but is marked as not loaded. This is to allow the engine and frontends to provide a nice view to the user showing what is working and what not. Only loaded modules are used by the engine.

Author
Pl├╝ss Roland
Version
1.0
Date
2008

Member Enumeration Documentation

◆ eModuleTypes

Module Types.

Enumerator
emtUnknown 

Module type is not known or invalid.

emtGraphic 

Graphic system module.

emtAudio 

Audio system module.

emtInput 

Input system module.

emtNetwork 

Network system module.

emtPhysics 

Physics system module.

emtImage 

Image system module.

emtVideo 

Video system module.

emtScript 

Scripting system module.

emtModel 

Model system module.

emtRig 

Rig system module.

emtSkin 

Skin system module.

emtAnimation 

Animation system module.

emtFont 

Font system module.

emtCrashRecovery 

Crash Recovery system module.

emtLanguagePack 

Language pack system module.

emtAnimator 

Animator system module.

emtSound 

Sound system module.

emtAI 

AI system module.

emtOcclusionMesh 

Occlusion mesh module.

emtSynthesizer 

Synthesizer module.

EMT_COUNT 

Dummy entry defining the number of types.

Constructor & Destructor Documentation

◆ deModuleSystem()

deModuleSystem::deModuleSystem ( deEngine engine)

Creates a new module system linked to the given engine.

◆ ~deModuleSystem()

deModuleSystem::~deModuleSystem ( )

Cleans up the module system.

Member Function Documentation

◆ AddModule()

void deModuleSystem::AddModule ( deLoadableModule module)

Adds a module to the system. The module has not to exist already and has to be properly initialized to be accepted.

Referenced by GetModuleCount().

◆ CompareVersion()

static int deModuleSystem::CompareVersion ( const char *  version1,
const char *  version2 
)
static

Compare two module versions.

The version strings have to consist of dot separated entries. The result is 0 if both strings are the same, -1 if the first differing version string part of the first version is less than the second or 1 otherwise.

Referenced by GetModuleCount().

◆ DetectModules()

void deModuleSystem::DetectModules ( )

Scans the module directory for modules and loads them if possible.

Referenced by GetEngine().

◆ FindMatching()

deLoadableModule* deModuleSystem::FindMatching ( eModuleTypes  type,
const char *  filename 
) const

Retrieves the first module of the given type able to handle the given file.

Multiple type modules provide a list of file extensions they can handle. If the extension of the given filename matches one of the entris of a module it is considered able to handle the file. If multiple versions of the same module exist the module with the highest version is returned.

Referenced by GetModuleCount().

◆ GetEngine()

deEngine* deModuleSystem::GetEngine ( ) const
inline

Retrieves the linked game engine.

References DetectModules().

◆ GetFirstLoadedModuleFor()

deLoadableModule* deModuleSystem::GetFirstLoadedModuleFor ( eModuleTypes  type) const

Retrieves the first loaded module for the given type or NULL if not found.

Referenced by GetModuleCount().

◆ GetLoadedModuleCountFor()

int deModuleSystem::GetLoadedModuleCountFor ( eModuleTypes  type) const

Retrieves the count of loaded modules of a given type.

Referenced by GetModuleCount().

◆ GetModuleAbleToLoad()

deBaseModule* deModuleSystem::GetModuleAbleToLoad ( eModuleTypes  type,
const char *  filename 
) const

Retrieves the first modules of the given type able to handle the given file.

This is the same as the FindMatching function but with the difference that the returned object is the module itself and not the wrapper around the module. This also requires that the module is loaded. In the other function Not loaded modules are matching too whereas here this is not the case. If multiple versions of the same module exist the module with the highest version is returned.

Referenced by GetModuleCount().

◆ GetModuleAt()

deLoadableModule* deModuleSystem::GetModuleAt ( int  index) const

Retrieves the module at the given index.

Referenced by GetModuleCount().

◆ GetModuleCount()

◆ GetModuleCountFor()

int deModuleSystem::GetModuleCountFor ( eModuleTypes  type) const

Retrieves the count of modules of a given type.

Referenced by GetModuleCount().

◆ GetModuleNamed() [1/2]

deLoadableModule* deModuleSystem::GetModuleNamed ( const char *  name) const

Retrieves the highest version module with the given name or NULL if not found.

Referenced by GetModuleCount().

◆ GetModuleNamed() [2/2]

deLoadableModule* deModuleSystem::GetModuleNamed ( const char *  name,
const char *  version 
) const

Retrieves the module with the given name and version or NULL if not found.

◆ GetTypeDirectory()

static const char* deModuleSystem::GetTypeDirectory ( eModuleTypes  type)
static

Retrieves directory name for a given type

Referenced by GetModuleCount().

◆ GetTypeFromString()

static eModuleTypes deModuleSystem::GetTypeFromString ( const char *  typeString)
static

Retrieves the type from eModuleTypes matching the given type string. This is used to translate type strings from the XML module definitions into an engine usable type. The following table shows the matchings.

  • "Graphic" returns emtGraphic
  • "Audio" returns emtAudio
  • "Input" returns emtInput
  • "Network" returns emtNetwork
  • "Physics" returns emtPhysics
  • "Image" returns emtImage
  • "Video returns emtVideo - "Script" returns emtScript - "Model" returns emtModel - "Rig" returns emtRig - "Skin" returns emtSkin - "Animation" returns emtAnimation - "Font" returns emtFont - "CrashRecovery" returns emtCrashRecovery - "LanguagePack" returns emtLanguagePack - "Animator" returns emtAnimator - "Sound" returns emtSound - "AI" returns emtAI - "OcclusionMesh" returns emtOcclusionMesh - "Synthesizer" returns emtSynthesizer

In all other cases emtUnknown is returned. Case does not matter.

Referenced by GetModuleCount().

◆ IsSingleType()

static bool deModuleSystem::IsSingleType ( eModuleTypes  type)
static

Retrieves if the given type is a single type. The following are single types:

  • emtGraphic
  • emtAudio
  • emtInput
  • emtNetwork
  • emtPhysics
  • emtScript
  • emtAnimator
  • emtAI
  • emtCrashRecovery
  • emtSynthesizer

All others are multiple type.

Referenced by GetModuleCount().

◆ MatchesPattern()

bool deModuleSystem::MatchesPattern ( const char *  filename,
const char *  pattern 
) const

Determines if the filename matches the given pattern.

Referenced by GetModuleCount().

◆ StrEqual()

bool deModuleSystem::StrEqual ( const char *  str1,
const char *  str2,
int  length 
) const

Determines if two strings are equal in a non-case sensitive comparisson.

Referenced by GetModuleCount().


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