184 lines
3.9 KiB
C++
184 lines
3.9 KiB
C++
#pragma once
|
|
|
|
//#include <string>
|
|
//#include <vector>
|
|
#include <toolkit/khash.h>
|
|
#include <toolkit/XFlag.h>
|
|
|
|
#include "MixCategoryBase.h"
|
|
|
|
//-------------------------------------------------------------------------------
|
|
//
|
|
// 강화 & 조합 공식 분류 DB.
|
|
//
|
|
//-------------------------------------------------------------------------------
|
|
|
|
class SMixCategoryDB
|
|
{
|
|
public:
|
|
|
|
// 합성분류.
|
|
enum SYNTHETIC_TYPE
|
|
{
|
|
SYNTHETIC_TYPE_UPGRAGE = 0, // 강화.
|
|
SYNTHETIC_TYPE_MIX, // 조합.
|
|
|
|
SYNTHETIC_TYPE_MAX,
|
|
};
|
|
|
|
|
|
// 합성분류당 대중소 분류 개수.
|
|
struct SCount
|
|
{
|
|
/// db의 데이타 순서가 바뀌면 제대로 동작을 안하기 때문에, 순서랑 상관없도록 수정함 - prodongi
|
|
/*
|
|
SCount() : highSize(0), middleSize(0), lowSize(0)
|
|
{}
|
|
~SCount()
|
|
{
|
|
arrMiddle.clear();
|
|
|
|
std::vector< std::vector< int > >::iterator it = arrLow.begin();
|
|
for (; it != arrLow.end(); ++it)
|
|
{
|
|
it->clear();
|
|
}
|
|
arrLow.clear();
|
|
}
|
|
|
|
int highSize;
|
|
int middleSize;
|
|
int lowSize;
|
|
|
|
std::vector< int > arrMiddle; // 대분류 당 중분류 개수.
|
|
std::vector< std::vector< int > > arrLow; // 중분류당 소분류 개수.
|
|
|
|
int GetMiddleSize( int high ){
|
|
return arrMiddle[ high ];
|
|
}
|
|
|
|
int GetLowSize( int high, int middle ){
|
|
return arrLow[ high ][ middle ];
|
|
}
|
|
*/
|
|
|
|
private:
|
|
struct sClass
|
|
{
|
|
~sClass() { m_subClass.clear(); }
|
|
int getSize() const { return (int)m_subClass.size(); }
|
|
|
|
std::vector<sClass> m_subClass;
|
|
};
|
|
|
|
public:
|
|
~SCount()
|
|
{
|
|
m_subClass.clear();
|
|
}
|
|
void classification(int depth, std::vector<int> const& id)
|
|
{
|
|
classification(m_subClass, depth, id);
|
|
}
|
|
int GetHighSize() const
|
|
{
|
|
return (int)m_subClass.size();
|
|
}
|
|
int GetMiddleSize(int h_id) const
|
|
{
|
|
return m_subClass[h_id].getSize();
|
|
}
|
|
int GetLowSize(int h_id, int m_id) const
|
|
{
|
|
return m_subClass[h_id].m_subClass[m_id].getSize();
|
|
}
|
|
|
|
private:
|
|
void classification(std::vector<sClass>& classList, int depth, std::vector<int> const& id)
|
|
{
|
|
int classId = id[depth];
|
|
|
|
while ((int)classList.size() < classId+1)
|
|
{
|
|
classList.push_back(sClass());
|
|
};
|
|
|
|
if (depth+1 < 3)
|
|
{
|
|
int nextClassId = id[depth+1];
|
|
if (nextClassId != -1)
|
|
{
|
|
classification(classList[classId].m_subClass, depth+1, id);
|
|
}
|
|
}
|
|
}
|
|
|
|
private:
|
|
std::vector<sClass> m_subClass; /// 대중소
|
|
};
|
|
|
|
|
|
protected:
|
|
KHash< struct MixCategoryBase*, hashPr_mod_int> m_hashData;
|
|
void Init();
|
|
void Destroy();
|
|
void Load();
|
|
|
|
// m_hashData 의 Key( id ) 를 찾기위한 Multi Key.
|
|
struct SKey
|
|
{
|
|
SKey(){}
|
|
|
|
SKey( int _id, short _high, short _middle, short _low ) :
|
|
id( _id ), high( _high ), middle( _middle ), low( _low )
|
|
{}
|
|
|
|
void Set( short _high, short _middle, short _low ){
|
|
high = _high; middle = _middle; low = _low;
|
|
}
|
|
|
|
bool Equal( SKey & key ){
|
|
return ( high == key.high && middle == key.middle && low == key.low );
|
|
}
|
|
|
|
bool Equal( short _high, short _middle, short _low ){
|
|
return ( high == _high && middle == _middle && low == _low );
|
|
}
|
|
|
|
int id;
|
|
short high; // 대.
|
|
short middle; // 중.
|
|
short low; // 소.
|
|
};
|
|
|
|
// 공식을 찾기위한 Key 배열.
|
|
std::vector< SKey > m_Category[ MixCategoryBase::SYNTHETIC_MAX ];
|
|
|
|
int m_nMaxCategorySize;
|
|
|
|
// 합성분류 - 강화,조합,수리,복원....
|
|
// 합성분류당 대중소 분류 개수 배열.
|
|
SCount m_arrCategorySize[ MixCategoryBase::SYNTHETIC_MAX ];
|
|
|
|
|
|
private:
|
|
bool LookUp( int nID, MixCategoryBase * pItem );
|
|
void classification(MixCategoryBase const* item);
|
|
|
|
|
|
public:
|
|
SMixCategoryDB();
|
|
~SMixCategoryDB();
|
|
|
|
// 합성구분, 국가코드, 대분류, 중분류, 소분류
|
|
MixCategoryBase * GetCategory( int synthetic_separation, int local_flag, short high, short midle = -1, short low = -1 );
|
|
|
|
// 합성분류당 대중소 분류 개수
|
|
SCount & GetCategorySize( int synthetic_separation ){
|
|
return m_arrCategorySize[ synthetic_separation ];
|
|
}
|
|
|
|
static SMixCategoryDB* m_pThis;
|
|
};
|
|
|
|
SMixCategoryDB & GetMixCategoryDB(); |