EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PlanetDataMgr Class Reference

#include "PlanetDataMgr.h"

Inheritance diagram for PlanetDataMgr:
Collaboration diagram for PlanetDataMgr:

Public Member Functions

 ~PlanetDataMgr ()
 
- Public Member Functions inherited from Singleton< PlanetDataMgr >
 Singleton ()
 Primary constructor. More...
 

Private Attributes

PlanetDB m_db
 
std::unordered_multimap
< uint32, uint32
m_planetData
 

PlanetDataMgr.cpp

Specific Class for managing planet and pi data : Allan

Date
: 30 November 2016
 PlanetDataMgr ()
 
int Initialize ()
 
void GetPlanetData (uint32 planetID, std::vector< uint16 > &typeIDs)
 
const char * GetCommandName (int8 commandID)
 
void _Populate ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Singleton< PlanetDataMgr >
static PlanetDataMgrget ()
 
- Static Protected Attributes inherited from Singleton< PlanetDataMgr >
static std::shared_ptr
< PlanetDataMgr
mInstance
 

Detailed Description

Definition at line 18 of file PlanetDataMgr.h.

Constructor & Destructor Documentation

PlanetDataMgr::PlanetDataMgr ( )

Definition at line 32 of file PlanetDataMgr.cpp.

33 {
34 }
PlanetDataMgr::~PlanetDataMgr ( )
inline

Definition at line 23 of file PlanetDataMgr.h.

23 { /* nothing do to yet */ }

Member Function Documentation

void PlanetDataMgr::_Populate ( )
protected

Definition at line 43 of file PlanetDataMgr.cpp.

References DBResultRow::GetInt(), PlanetDB::GetPlanetData(), DBQueryResult::GetRow(), GetTimeMSeconds(), m_db, m_planetData, SafeDelete(), and sLog.

Referenced by Initialize(), and PIDataMgr::Initialize().

44 {
45  double start = GetTimeMSeconds();
46  DBQueryResult* res = new DBQueryResult();
47  DBResultRow row;
48 
49  m_db.GetPlanetData(*res);
50  while (res->GetRow(row)) {
51  // SELECT planet.typeID, resource.typeID
52  m_planetData.insert(std::pair<uint32, uint32>(row.GetInt(0), row.GetInt(1)));
53  }
54 
55  //cleanup
56  SafeDelete(res);
57  sLog.Cyan(" PlanetDataMgr", "%u planet data groups in %u buckets loaded in %.3fms.",\
58  m_planetData.size(), m_planetData.bucket_count(), (GetTimeMSeconds() - start));
59 }
PlanetDB m_db
Definition: PlanetDataMgr.h:36
int32 GetInt(uint32 index) const
Definition: dbcore.cpp:635
std::unordered_multimap< uint32, uint32 > m_planetData
Definition: PlanetDataMgr.h:38
void SafeDelete(T *&p)
Deletes and nullifies a pointer.
Definition: SafeMem.h:83
bool GetRow(DBResultRow &into)
Definition: dbcore.cpp:552
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
double GetTimeMSeconds()
Definition: utils_time.cpp:104
void GetPlanetData(DBQueryResult &res)
Definition: PlanetDB.cpp:61

Here is the call graph for this function:

Here is the caller graph for this function:

const char * PlanetDataMgr::GetCommandName ( int8  commandID)

Definition at line 68 of file PlanetDataMgr.cpp.

References PI::Command::AddExtractorHead, PI::Command::CreateLink, PI::Command::CreatePin, PI::Command::CreateRoute, PI::Command::InstallProgram, Calendar::Flag::Invalid, PI::Command::KillExtractorHead, PI::Command::MoveExtractorHead, PI::Command::PrioritizeRoute, PI::Command::RemoveLink, PI::Command::RemovePin, PI::Command::RemoveRoute, PI::Command::SetLinkLevel, PI::Command::SetSchematic, and PI::Command::UpgradeCommandCenter.

69 {
70  using namespace PI::Command;
71  switch (commandID) {
72  case Invalid: return "Invalid";
73  case CreatePin: return "CreatePin";
74  case RemovePin: return "RemovePin";
75  case CreateLink: return "CreateLink";
76  case RemoveLink: return "RemoveLink";
77  case CreateRoute: return "CreateRoute";
78  case SetLinkLevel: return "SetLinkLevel";
79  case UpgradeCommandCenter: return "UpgradeCommandCenter";
80  case SetSchematic: return "SetSchematic";
81  case RemoveRoute: return "RemoveRoute";
82  case AddExtractorHead: return "AddExtractorHead";
83  case MoveExtractorHead: return "MoveExtractorHead";
84  case InstallProgram: return "InstallProgram";
85  case KillExtractorHead: return "KillExtractorHead";
86  case PrioritizeRoute: return "PrioritizeRoute";
87  default: return "UnknownCommandID";
88  }
89 }
void PlanetDataMgr::GetPlanetData ( uint32  planetID,
std::vector< uint16 > &  typeIDs 
)

Definition at line 61 of file PlanetDataMgr.cpp.

References m_planetData.

62 {
63  auto itr = m_planetData.equal_range(planetID);
64  for (auto it = itr.first; it != itr.second; ++it)
65  typeIDs.push_back(it->second);
66 }
std::unordered_multimap< uint32, uint32 > m_planetData
Definition: PlanetDataMgr.h:38
int PlanetDataMgr::Initialize ( )

Definition at line 36 of file PlanetDataMgr.cpp.

References _Populate(), and sLog.

37 {
38  _Populate();
39  sLog.Blue(" PlanetDataMgr", "Planet Data Manager Initialized.");
40  return 1;
41 }
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250

Here is the call graph for this function:

Member Data Documentation

PlanetDB PlanetDataMgr::m_db
private

Definition at line 36 of file PlanetDataMgr.h.

Referenced by _Populate(), and PIDataMgr::_Populate().

std::unordered_multimap<uint32, uint32> PlanetDataMgr::m_planetData
private

Definition at line 38 of file PlanetDataMgr.h.

Referenced by _Populate(), and GetPlanetData().


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