Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
DataManager Class Reference

#include <DataManager.h>

Classes

struct  LevelPreloadResult
 
struct  PreloadStats
 
struct  TilesetInfo
 

Public Member Functions

 DataManager ()
 
virtual ~DataManager ()
 
void Initialize ()
 
void Shutdown ()
 
bool PreloadTexture (const std::string &id, const std::string &path, ResourceCategory category=ResourceCategory::System)
 
bool PreloadSprite (const std::string &id, const std::string &path, ResourceCategory category=ResourceCategory::GameEntity)
 
SpriteGetTexture (const std::string &id) const
 
SpriteGetSprite (const std::string &id, const std::string &path, ResourceCategory category=ResourceCategory::GameEntity)
 
bool GetSprite_data (const std::string &id, const std::string &path, VisualSprite_data &outData)
 
bool GetSpriteEditor_data (const std::string &id, const std::string &path, VisualEditor_data &outData)
 
bool ReleaseResource (const std::string &id)
 
void UnloadAll ()
 
bool HasResource (const std::string &id) const
 
std::vector< std::string > ListResourcesByType (ResourceType type) const
 
std::vector< std::string > ListResourcesByCategory (ResourceCategory category) const
 
bool SaveJSONForObject (const std::string &videogameName, const std::string &objectName, const std::string &jsonContent) const
 
bool LoadJSONForObject (const std::string &videogameName, const std::string &objectName, std::string &outJson) const
 
bool SaveTextFile (const std::string &filepath, const std::string &content) const
 
bool LoadTextFile (const std::string &filepath, std::string &outContent) const
 
bool EnsureDirectoryExists (const std::string &dirpath) const
 
bool PreloadSystemResources (const std::string &configFilePath)
 
PreloadStats PreloadTextures (const std::vector< std::string > &paths, ResourceCategory category=ResourceCategory::Level, bool enableFallbackScan=true)
 
PreloadStats PreloadSprites (const std::vector< std::string > &paths, ResourceCategory category=ResourceCategory::GameEntity, bool enableFallbackScan=true)
 
PreloadStats PreloadAudioFiles (const std::vector< std::string > &paths, bool enableFallbackScan=true)
 
PreloadStats PreloadTilesets (const std::vector< TilesetInfo > &tilesets, bool enableFallbackScan=true)
 
std::string FindResourceRecursive (const std::string &filename, const std::string &rootDir="GameData") const
 

Static Public Member Functions

static DataManagerGetInstance ()
 
static DataManagerGet ()
 
static std::string BuildGameDataPath (const std::string &videogameName, const std::string &objectName)
 

Private Member Functions

std::string FindResourceRecursive_Unix (const std::string &filename, const std::string &rootDir) const
 

Private Attributes

std::string name
 
std::mutex m_mutex_
 
std::unordered_map< std::string, std::shared_ptr< Resource > > m_resources_
 
bool m_enableFallbackScan = true
 

Detailed Description

Definition at line 79 of file DataManager.h.

Constructor & Destructor Documentation

◆ DataManager()

DataManager::DataManager ( )

Definition at line 42 of file DataManager.cpp.

References name, and SYSTEM_LOG.

◆ ~DataManager()

DataManager::~DataManager ( )
virtual

Definition at line 48 of file DataManager.cpp.

References SYSTEM_LOG, and UnloadAll().

+ Here is the call graph for this function:

Member Function Documentation

◆ BuildGameDataPath()

std::string DataManager::BuildGameDataPath ( const std::string &  videogameName,
const std::string &  objectName 
)
static

Definition at line 300 of file DataManager.cpp.

References GetComponentTypeID_Static().

Referenced by LoadJSONForObject(), and SaveJSONForObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EnsureDirectoryExists()

bool DataManager::EnsureDirectoryExists ( const std::string &  dirpath) const

Definition at line 353 of file DataManager.cpp.

References GetComponentTypeID_Static(), and SYSTEM_LOG.

Referenced by SaveTextFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindResourceRecursive()

std::string DataManager::FindResourceRecursive ( const std::string &  filename,
const std::string &  rootDir = "GameData" 
) const

Definition at line 688 of file DataManager.cpp.

References FindResourceRecursive_Unix(), and GetComponentTypeID_Static().

Referenced by World::InstantiatePass1_VisualLayers(), TilesetManager::LoadTilesets(), PreloadSprites(), PreloadTextures(), and PreloadTilesets().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindResourceRecursive_Unix()

std::string DataManager::FindResourceRecursive_Unix ( const std::string &  filename,
const std::string &  rootDir 
) const
private

Definition at line 743 of file DataManager.cpp.

References FindResourceRecursive_Unix(), GetComponentTypeID_Static(), and name.

Referenced by FindResourceRecursive(), and FindResourceRecursive_Unix().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Get()

static DataManager & DataManager::Get ( )
inlinestatic

◆ GetInstance()

DataManager & DataManager::GetInstance ( )
static

Definition at line 55 of file DataManager.cpp.

References GetComponentTypeID_Static().

Referenced by Get(), and GameEngine::Initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSprite()

Sprite * DataManager::GetSprite ( const std::string &  id,
const std::string &  path,
ResourceCategory  category = ResourceCategory::GameEntity 
)

◆ GetSprite_data()

bool DataManager::GetSprite_data ( const std::string &  id,
const std::string &  path,
VisualSprite_data outData 
)

Definition at line 190 of file DataManager.cpp.

References GameEntity, GetComponentTypeID_Static(), GetSprite(), and SYSTEM_LOG.

+ Here is the call graph for this function:

◆ GetSpriteEditor_data()

bool DataManager::GetSpriteEditor_data ( const std::string &  id,
const std::string &  path,
VisualEditor_data outData 
)

Definition at line 206 of file DataManager.cpp.

References GameEntity, GetComponentTypeID_Static(), GetSprite(), and SYSTEM_LOG.

+ Here is the call graph for this function:

◆ GetTexture()

SDL_Texture * DataManager::GetTexture ( const std::string &  id) const

Definition at line 137 of file DataManager.cpp.

References GetComponentTypeID_Static(), m_mutex_, m_resources_, GameEngine::renderer, renderer, and SYSTEM_LOG.

Referenced by GetSprite(), and OlympeAnimation::AnimationBank::ParseJSON().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HasResource()

bool DataManager::HasResource ( const std::string &  id) const

Definition at line 267 of file DataManager.cpp.

References GetComponentTypeID_Static(), m_mutex_, and m_resources_.

+ Here is the call graph for this function:

◆ Initialize()

void DataManager::Initialize ( )

Definition at line 61 of file DataManager.cpp.

References SYSTEM_LOG.

Referenced by SDL_AppInit().

+ Here is the caller graph for this function:

◆ ListResourcesByCategory()

std::vector< std::string > DataManager::ListResourcesByCategory ( ResourceCategory  category) const

Definition at line 286 of file DataManager.cpp.

References GetComponentTypeID_Static(), m_mutex_, and m_resources_.

+ Here is the call graph for this function:

◆ ListResourcesByType()

std::vector< std::string > DataManager::ListResourcesByType ( ResourceType  type) const

Definition at line 273 of file DataManager.cpp.

References GetComponentTypeID_Static(), m_mutex_, and m_resources_.

+ Here is the call graph for this function:

◆ LoadJSONForObject()

bool DataManager::LoadJSONForObject ( const std::string &  videogameName,
const std::string &  objectName,
std::string &  outJson 
) const

Definition at line 347 of file DataManager.cpp.

References BuildGameDataPath(), GetComponentTypeID_Static(), and LoadTextFile().

+ Here is the call graph for this function:

◆ LoadTextFile()

bool DataManager::LoadTextFile ( const std::string &  filepath,
std::string &  outContent 
) const

Definition at line 329 of file DataManager.cpp.

References GetComponentTypeID_Static().

Referenced by LoadJSONForObject(), and PreloadSystemResources().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PreloadAudioFiles()

DataManager::PreloadStats DataManager::PreloadAudioFiles ( const std::vector< std::string > &  paths,
bool  enableFallbackScan = true 
)

◆ PreloadSprite()

bool DataManager::PreloadSprite ( const std::string &  id,
const std::string &  path,
ResourceCategory  category = ResourceCategory::GameEntity 
)

Definition at line 132 of file DataManager.cpp.

References PreloadTexture().

Referenced by GetSprite(), _Sprite::Preload(), PreloadSprites(), and PreloadSystemResources().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PreloadSprites()

DataManager::PreloadStats DataManager::PreloadSprites ( const std::vector< std::string > &  paths,
ResourceCategory  category = ResourceCategory::GameEntity,
bool  enableFallbackScan = true 
)

◆ PreloadSystemResources()

bool DataManager::PreloadSystemResources ( const std::string &  configFilePath)

Definition at line 404 of file DataManager.cpp.

References GameEntity, GetComponentTypeID_Static(), Level, LoadTextFile(), PreloadSprite(), PreloadTexture(), System, and SYSTEM_LOG.

Referenced by GameEngine::Initialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PreloadTexture()

bool DataManager::PreloadTexture ( const std::string &  id,
const std::string &  path,
ResourceCategory  category = ResourceCategory::System 
)

Definition at line 73 of file DataManager.cpp.

References GetComponentTypeID_Static(), m_mutex_, m_resources_, GameEngine::renderer, renderer, SYSTEM_LOG, and Texture.

Referenced by OlympeAnimation::AnimationBank::ParseJSON(), PreloadSprite(), PreloadSystemResources(), PreloadTextures(), and PreloadTilesets().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PreloadTextures()

DataManager::PreloadStats DataManager::PreloadTextures ( const std::vector< std::string > &  paths,
ResourceCategory  category = ResourceCategory::Level,
bool  enableFallbackScan = true 
)

◆ PreloadTilesets()

DataManager::PreloadStats DataManager::PreloadTilesets ( const std::vector< TilesetInfo > &  tilesets,
bool  enableFallbackScan = true 
)

◆ ReleaseResource()

bool DataManager::ReleaseResource ( const std::string &  id)

Definition at line 221 of file DataManager.cpp.

References GetComponentTypeID_Static(), m_mutex_, m_resources_, and SYSTEM_LOG.

+ Here is the call graph for this function:

◆ SaveJSONForObject()

bool DataManager::SaveJSONForObject ( const std::string &  videogameName,
const std::string &  objectName,
const std::string &  jsonContent 
) const

Definition at line 341 of file DataManager.cpp.

References BuildGameDataPath(), GetComponentTypeID_Static(), and SaveTextFile().

+ Here is the call graph for this function:

◆ SaveTextFile()

bool DataManager::SaveTextFile ( const std::string &  filepath,
const std::string &  content 
) const

Definition at line 308 of file DataManager.cpp.

References EnsureDirectoryExists(), GetComponentTypeID_Static(), and SYSTEM_LOG.

Referenced by SaveJSONForObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Shutdown()

void DataManager::Shutdown ( )

Definition at line 67 of file DataManager.cpp.

References SYSTEM_LOG, and UnloadAll().

Referenced by SDL_AppQuit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UnloadAll()

void DataManager::UnloadAll ( )

Definition at line 246 of file DataManager.cpp.

References GetComponentTypeID_Static(), m_mutex_, and m_resources_.

Referenced by Shutdown(), and ~DataManager().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_enableFallbackScan

bool DataManager::m_enableFallbackScan = true
private

Definition at line 218 of file DataManager.h.

Referenced by PreloadSprites(), PreloadTextures(), and PreloadTilesets().

◆ m_mutex_

std::mutex DataManager::m_mutex_
mutableprivate

◆ m_resources_

std::unordered_map<std::string, std::shared_ptr<Resource> > DataManager::m_resources_
private

◆ name

std::string DataManager::name
private

Definition at line 215 of file DataManager.h.

Referenced by DataManager(), and FindResourceRecursive_Unix().


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