Mobile API Reference  MicroStrategy 2019
TemplateUnitInfo.h
Go to the documentation of this file.
1 //==============================================================================================
2 // FILENAME : Dataset.h
3 // AUTHOR : Dong Shi & Fangyao Ma
4 // CREATION : 2008-05-15
5 // Copyright (C) MicroStrategy Incorporated 2008
6 // All Rights Reserved
7 //==============================================================================================
8 
9 // Updated by Li en, 2016/3/10
10 // formatmanager refactor, splite dataset out
11 // move used template units include MetricUnitInfo and CustomGroupUnitInfo into this new file
12 
13 #ifndef MsiFormat_MetricUnitInfo_h
14 #define MsiFormat_MetricUnitInfo_h
15 
16 #include "Base/Base/BaseString.h"
18 #include "Synch/Defines/SmartPtr.h"
19 
20 class DSSTemplateMetric;
21 class DSSTemplate;
22 class DSSRWGridIterator;
24 
25 namespace MsiFormat
26 {
28 
29  //Unit Info Structure//
30 
32  struct UnitInfo
33  {
35  {
36  mName = L"";
37  mIndexInAxis = 0;
39  mIsValid = false;
40  }
41 
42  UnitInfo(MBase::String& iName, GUID& iID, Int32 iIndex, Int32 iType) : mID(iID), mIndexInAxis(iIndex), mType(iType), mName(iName)
43  {
44  mIsValid = true;
45  }
46  public:
47  MBase::GUID GetID() {return mID;}
49  Int32 GetType() {return mType;}
52  bool mIsValid;
53  protected:
57  };
58 
59  typedef std::pair<MBase::GUID, MBase::String> ElementInfo;
60 
61  class DimTree;
62  struct MetricUnitInfo: public UnitInfo
63  {
65 
66  MetricUnitInfo(MBase::String& iName, MBase::GUID& iID, Int32 iIndex, Int32 iType) : UnitInfo(iName, iID, iIndex, iType)
67  {
68  mIsInRowAxis = false;
69  mMetricNumber = 0;
70  }
71 
73  {
74  mIsInRowAxis = false;
75  mMetricNumber = 0;
76  mIsValid = hPopulateMetricInfo(ipTemplate);
77  }
78  void AddOneElement(const MBase::GUID& iID, const MBase::String& iName) {mElements.push_back(std::make_pair(iID, iName));}
79  void GetOneElement(MBase::GUID& orID, MBase::String& orName, Int32 iIndex)
80  {
81  _ASSERTE( iIndex >= 0 && iIndex < mElements.size());
82  orID = mElements[iIndex].first;
83  orName = mElements[iIndex].second;
84  }
86  {
87  _ASSERTE(iIndex >= 0 && iIndex < mElements.size());
88  return mElements[iIndex].first;
89  }
92  {
93  return mElements[iIndex].second;
94  }
95 
96  void GetElementNames(std::vector<MBase::String>& orElements)
97  {
98  orElements.clear();
99  size_t lSize = mElements.size();
100  for (size_t i = 0; i < lSize; i++)
101  orElements.push_back(mElements[i].second);
102  }
106  {
107  Int32 lSize = sizeof(*this);
108 
109  Int32 lCount = (Int32)mOccupyPairSet.size();
110  Int32 kSize = sizeof(std::pair<Int32, Int32>);
111  lSize += lCount * kSize;
112 
113  lCount = (Int32)mIDToTemplateMetric.size();
114  kSize = sizeof(MBase::GUID) + sizeof(DSSTemplateMetric*);
115  lSize += lCount * kSize;
116 
117  lCount = (Int32)mElements.size();
118  kSize = sizeof(ElementInfo);
119  lSize += lCount * kSize;
120 
121  return lSize;
122  }
123 
127  protected:
128  std::vector<ElementInfo> mElements;
129  std::vector<std::pair<Int32, Int32> > mOccupyPairSet; //<width, index>
130  std::map<MBase::GUID, DSSTemplateMetric*> mIDToTemplateMetric;
131  private:
132  bool hPopulateMetricInfo(DSSTemplate* ipTemplate);
133 
134  };
135 
136  //CustomGroupUnitInfo
137  typedef enum
138  {//to identify custom group levels ()
144  //CustomGroupUnitInfo impl
146  {
148 
149  Int32 mCustomGroupNum[2];//0 for rows, 1 for columns
150 
151  CustomGroupUnitInfo(MBase::String& iName, MBase::GUID& iID, Int32 iIndex, Int32 iType) : UnitInfo(iName, iID, iIndex, iType)
152  {
153  mCustomGroupNum[0] = mCustomGroupNum[1] = 0;
154  }
156  {
157  mCustomGroupNum[0] = mCustomGroupNum[1] = 0;
158  mIsValid = hPopulateCustomGroupUnitInfo(ipIterator);
159  }
160  //iAxis = 0(Row) or 1(Column)
161  DSSTemplateCustomGroup* getCustomGroupInAxis(int iAxis, int iDepth, CUSTOM_GROUP_LEVEL& iLevel);//not fully implemented
162  std::vector<std::pair<Int32, Int32> > getCustomGroupPositions(bool iIsRow);
163  bool hasCustomGroupInRow(){return (mCustomGroupNum[0]>0);}
165  protected:
166  std::vector<std::pair<Int32, Int32> > mOccupyPairSet[2]; //<beginIndex endIndex> -- [bgin, end)
167  std::map<Int32, MBase::GUID> mCustomGroupIndexToID[2]; //<CGIndex, ID>
168  std::map<MBase::GUID, DSSTemplateCustomGroup*> mIDToTemplateCustomGroup;
169  //format info pool
170  std::map<Int32, std::pair<GUID, Int32> > mCustomGroupIndexToElement[2];
171  private:
172  bool hPopulateCustomGroupUnitInfo(DSSRWGridIterator* mpIterator);
173  };
174  //CustomGroupUnitInfo~
175 };
176 
177 #endif
178 
bool hasCustomGroupInColumn()
Definition: TemplateUnitInfo.h:164
std::map< Int32, MBase::GUID > mCustomGroupIndexToID[2]
Definition: TemplateUnitInfo.h:167
MSynch::SmartPtr< MetricUnitInfo > Ptr
Definition: TemplateUnitInfo.h:64
std::map< MBase::GUID, DSSTemplateMetric * > mIDToTemplateMetric
Definition: TemplateUnitInfo.h:130
std::pair< MBase::GUID, MBase::String > ElementInfo
Definition: TemplateUnitInfo.h:59
bool mIsInRowAxis
Definition: TemplateUnitInfo.h:124
Int32 GetIndex()
Definition: TemplateUnitInfo.h:48
Int32 mMetricNumber
Definition: TemplateUnitInfo.h:126
Definition: Base/Base/GUID.h:365
void GetElementNames(std::vector< MBase::String > &orElements)
Definition: TemplateUnitInfo.h:96
std::vector< ElementInfo > mElements
Definition: TemplateUnitInfo.h:128
Definition: TemplateUnitInfo.h:145
#define _ASSERTE(x)
Definition: Asserte.h:40
MBase::GUID GetID()
Definition: TemplateUnitInfo.h:47
bool mHasMetrics
Definition: TemplateUnitInfo.h:125
DSSTemplateCustomGroup * getCustomGroupInAxis(int iAxis, int iDepth, CUSTOM_GROUP_LEVEL &iLevel)
Definition: DSSRWGridIterator.h:68
Definition: TemplateUnitInfo.h:62
Int32 GetElementNumber()
Definition: TemplateUnitInfo.h:103
Definition: DSSTemplate.h:29
Definition: DSSTemplateCustomGroup.h:17
Int32 MetricIDToTemaplateMetricIndex(GUID &irID)
std::vector< std::pair< Int32, Int32 > > mOccupyPairSet[2]
Definition: TemplateUnitInfo.h:166
std::map< Int32, std::pair< GUID, Int32 > > mCustomGroupIndexToElement[2]
Definition: TemplateUnitInfo.h:170
Definition: TemplateUnitInfo.h:140
MetricUnitInfo(DSSTemplate *ipTemplate)
Definition: TemplateUnitInfo.h:72
Definition: TemplateUnitInfo.h:139
Int32 GetType()
Definition: TemplateUnitInfo.h:49
std::map< MBase::GUID, DSSTemplateCustomGroup * > mIDToTemplateCustomGroup
Definition: TemplateUnitInfo.h:168
bool hasCustomGroupInRow()
Definition: TemplateUnitInfo.h:163
#define Int32
Definition: BasicTypes.h:20
UnitInfo(MBase::String &iName, GUID &iID, Int32 iIndex, Int32 iType)
Definition: TemplateUnitInfo.h:42
struct _GUID GUID
Definition: TemplateUnitInfo.h:142
std::vector< std::pair< Int32, Int32 > > mOccupyPairSet
Definition: TemplateUnitInfo.h:129
Definition: TemplateUnitInfo.h:141
CUSTOM_GROUP_LEVEL
Definition: TemplateUnitInfo.h:137
UnitInfo()
Definition: TemplateUnitInfo.h:34
std::vector< std::pair< Int32, Int32 > > getCustomGroupPositions(bool iIsRow)
void GetOneElement(MBase::GUID &orID, MBase::String &orName, Int32 iIndex)
Definition: TemplateUnitInfo.h:79
Definition: DSSIPhoneEnums.h:14
std::basic_string< WCHAR, std::char_traits< WCHAR >, Allocator< WCHAR > > String
Definition: BaseString.h:26
DSSTemplateMetric * GetTemplateMetric(MBase::GUID &irID)
Int32 GetMemoryUsageEstimation()
Definition: TemplateUnitInfo.h:105
MBase::String GetName()
Definition: TemplateUnitInfo.h:50
void AddOneElement(const MBase::GUID &iID, const MBase::String &iName)
Definition: TemplateUnitInfo.h:78
GUID GetMetricID(Int32 iIndex)
Definition: TemplateUnitInfo.h:85
Definition: DSSTemplateMetric.h:20
MSynch::SmartPtr< CustomGroupUnitInfo > Ptr
Definition: TemplateUnitInfo.h:147
MBase::String mName
Definition: TemplateUnitInfo.h:56
MBase::String GetMetricName(Int32 iIndex)
Definition: TemplateUnitInfo.h:91
MetricUnitInfo(MBase::String &iName, MBase::GUID &iID, Int32 iIndex, Int32 iType)
Definition: TemplateUnitInfo.h:66
CustomGroupUnitInfo(MBase::String &iName, MBase::GUID &iID, Int32 iIndex, Int32 iType)
Definition: TemplateUnitInfo.h:151
Definition: TemplateUnitInfo.h:32
bool mIsValid
Definition: TemplateUnitInfo.h:52
CustomGroupUnitInfo(DSSRWGridIterator *ipIterator)
Definition: TemplateUnitInfo.h:155
Int32 mCustomGroupNum[2]
Definition: TemplateUnitInfo.h:149
Int32 mIndexInAxis
Definition: TemplateUnitInfo.h:51
MBase::GUID mID
Definition: TemplateUnitInfo.h:54
Int32 mType
Definition: TemplateUnitInfo.h:55
Definition: Base/Base/GUID.h:32
Definition: BaseFormatManager.h:25