mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-27 16:07:22 +00:00
d2aeebcd46
* Move CDClientManager to be a namespace Tested that worlds still load data as expected. Had no use being a singleton anyways. * Move cdclient data storage to tu local containers Allows some data from these containers to be saved on object by reference instead of always needing to copy. iteration 2 - move all unnamed namespace containers to a singular spot - use macro for template specialization and variable declaration - use templates to allow for as little copy paste of types and functions as possible * remember to use typename! compiler believes T::StorageType is accessing a member, not a type. * Update CDClientManager.cpp * move to cpp?
45 lines
1.0 KiB
C++
45 lines
1.0 KiB
C++
#ifndef __CDCLIENTMANAGER__H__
|
|
#define __CDCLIENTMANAGER__H__
|
|
|
|
#define UNUSED_TABLE(v)
|
|
|
|
/**
|
|
* Initialize the CDClient tables so they are all loaded into memory.
|
|
*/
|
|
namespace CDClientManager {
|
|
void LoadValuesFromDatabase();
|
|
void LoadValuesFromDefaults();
|
|
|
|
/**
|
|
* Fetch a table from CDClient
|
|
*
|
|
* @tparam Table type to fetch
|
|
* @return A pointer to the requested table.
|
|
*/
|
|
template<typename T>
|
|
T* GetTable();
|
|
|
|
/**
|
|
* Fetch a table from CDClient
|
|
* Note: Calling this function without a template specialization in CDClientManager.cpp will cause a linker error.
|
|
*
|
|
* @tparam Table type to fetch
|
|
* @return A pointer to the requested table.
|
|
*/
|
|
template<typename T>
|
|
typename T::StorageType& GetEntriesMutable();
|
|
};
|
|
|
|
|
|
// These are included after the CDClientManager namespace declaration as CDTable as of Jan 29 2024 relies on CDClientManager in Templated code.
|
|
#include "CDTable.h"
|
|
|
|
#include "Singleton.h"
|
|
|
|
template<typename T>
|
|
T* CDClientManager::GetTable() {
|
|
return &T::Instance();
|
|
};
|
|
|
|
#endif //!__CDCLIENTMANAGER__H__
|