KSquare Utilities
Attribute.cpp
Go to the documentation of this file.
1 #include "FirstIncludes.h"
2 #include <stdio.h>
3 #include <ctype.h>
4 #include <time.h>
5 #include <iostream>
6 #include <fstream>
7 #include <map>
8 #include <string>
9 #include <vector>
10 #include "MemoryDebug.h"
11 using namespace std;
12 
13 
14 #include "DateTime.h"
15 #include "GlobalGoalKeeper.h"
16 #include "KKBaseTypes.h"
17 #include "KKException.h"
18 #include "KKQueue.h"
19 #include "KKStr.h"
20 #include "KKStrParser.h"
21 #include "OSservices.h"
22 #include "RunLog.h"
23 #include "XmlStream.h"
24 using namespace KKB;
25 
26 #include "Attribute.h"
27 #include "KKMLLTypes.h"
28 #include "FeatureNumList.h"
29 #include "MLClass.h"
30 using namespace KKMLL;
31 
32 
34  fieldNum (-1),
35  name (),
36  nameUpper (),
37  nominalValuesUpper (NULL),
39 
40 {
41 }
42 
43 
44 Attribute::Attribute (const KKStr& _name,
45  AttributeType _type,
46  kkint32 _fieldNum
47  ):
48  fieldNum (_fieldNum),
49  name (_name),
50  nameUpper (_name),
51  nominalValuesUpper (NULL),
52  type (_type)
53 
54 {
55  nameUpper.Upper ();
56  if ((type == AttributeType::Nominal) ||
57  (type == AttributeType::Symbolic)
58  )
59  {
60  nominalValuesUpper = new KKStrListIndexed (true, // true == nominalValuesUpper will own its contents.
61  false // false = Not Case Sensitive.
62  );
63  }
64 }
65 
66 
68  fieldNum (a.fieldNum),
69  name (a.name),
70  nameUpper (a.nameUpper),
71  nominalValuesUpper (NULL),
72  type (a.type)
73 
74 {
75  if ((type == AttributeType::Nominal) ||
76  (type == AttributeType::Symbolic)
77  )
78  {
79  nominalValuesUpper = new KKStrListIndexed (*(a.nominalValuesUpper));
80  }
81 }
82 
83 
84 
85 
87 {
88  delete nominalValuesUpper;
89 }
90 
91 
93 {
94  kkint32 memoryConsumedEstimated = sizeof (Attribute) +
97 
98  if (nominalValuesUpper)
99  memoryConsumedEstimated += nominalValuesUpper->MemoryConsumedEstimated ();
100 
101  return memoryConsumedEstimated;
102 }
103 
104 
105 
106 void Attribute::ValidateNominalType (const KKStr& funcName) const
107 {
108  if ((type != AttributeType::Nominal) &&
109  (type != AttributeType::Symbolic)
110  )
111  {
112  KKStr msg (80);
113  msg << "Attribute::ValidateNominalType Attribute[" << funcName << "] must be a Nominal or Symbolic Type to perform this operation.";
114  cerr << std::endl << msg << std::endl << std::endl;
115  throw KKException (msg);
116  }
117 
118  return;
119 } /* ValidateNuminalType */
120 
121 
122 
123 void Attribute::AddANominalValue (const KKStr& nominalValue,
124  bool& alreadyExists
125  )
126 {
127  ValidateNominalType ("AddANominalValue");
128  kkint32 code = GetNominalCode (nominalValue);
129  if (code >= 0)
130  {
131  alreadyExists = true;
132  return;
133  }
134 
135  alreadyExists = false;
136  nominalValuesUpper->Add (new KKStr (nominalValue));
137 } /* AddANominalValue */
138 
139 
140 
141 
142 const
144 {
145  ValidateNominalType ("GetNominalValue");
146 
147  static KKStr missingDataValue = "?";
148 
149  if (code == -1)
150  {
151  // Missing Value Flag.
152  return missingDataValue;
153  }
154 
155  if (!nominalValuesUpper)
156  return KKStr::EmptyStr ();
157 
158  KKStrConstPtr result = nominalValuesUpper->LookUp (code);
159  if (result == NULL)
160  {
161  cerr << endl << endl
162  << "Attribute::GetNominalValue ***ERROR*** Code[" << code << "] Does not exist." << endl
163  << " Attribute::Name[" << name << "]" << endl
164  << endl;
165  return KKStr::EmptyStr ();
166  }
167 
168  return *result;
169 } /* GetNominalValue */
170 
171 
172 
174 {
175  if ((type == AttributeType::Nominal) ||
176  (type == AttributeType::Symbolic)
177  )
178  return nominalValuesUpper->size ();
179  else
180  return 999999999;
181 } /* Cardinality */
182 
183 
184 
185 kkint32 Attribute::GetNominalCode (const KKStr& nominalValue) const
186 {
187  ValidateNominalType ("GetNominalCode");
188  kkint32 code = nominalValuesUpper->LookUp (nominalValue);
189  return code;
190 } /* GetNominalCode */
191 
192 
193 
194 bool Attribute::operator== (const Attribute& rightSide) const
195 {
196  if ((nameUpper != rightSide.nameUpper) || (Type () != rightSide.Type ()))
197  return false;
198 
199  if ((type == AttributeType::Nominal) ||
200  (type == AttributeType::Symbolic)
201  )
202  {
203  // Lets make sure that the nominal values are equal. Not Case sensitive.
204  if ((*nominalValuesUpper) != (*rightSide.nominalValuesUpper))
205  return false;
206  }
207 
208  return true;
209 } /* operator== */
210 
211 
212 
213 bool Attribute::operator!= (const Attribute& rightSide) const
214 {
215  return !(*this == rightSide);
216 } /* operator== */
217 
218 
219 
220 
221 
223 {
224  fieldNum = right.fieldNum;
225  name = right.name;
226  nameUpper = right.nameUpper;
227 
228  delete nominalValuesUpper;
229  if (nominalValuesUpper)
230  nominalValuesUpper = new KKStrListIndexed (*right.nominalValuesUpper);
231  else
232  nominalValuesUpper = NULL;
233 
234  type = right.type;
235  return *this;
236 } /* operator= */
237 
238 
239 
240 
242 {
243  return AttributeTypeToStr (type);
244 } /* TypeStr */
245 
246 
247 
248 
249 void Attribute::WriteXML (const KKStr& varName,
250  ostream& o
251  ) const
252 {
254  if ((type == KKMLL::AttributeType::Nominal) ||
256  )
257  startTagType = XmlTag::TagTypes::tagStart;
258 
259  XmlTag startTag ("Attribute", startTagType);
260  if (!varName.Empty ())
261  startTag.AddAtribute ("VarName", varName);
262  startTag.AddAtribute ("Name", name);
263  startTag.AddAtribute ("Type", TypeStr ());
264  startTag.AddAtribute ("FieldNum", fieldNum);
265  startTag.WriteXML (o);
266  o << endl;
267 
268  if (startTagType == XmlTag::TagTypes::tagStart)
269  {
270  VectorKKStr nominalValues;
271  for (kkint32 nominalIdx = 0; nominalIdx < Cardinality (); ++nominalIdx)
272  nominalValues.push_back (GetNominalValue (nominalIdx));
273  nominalValues.WriteXML ("NominalValues", o);
274  XmlTag endTag ("Attribute", XmlTag::TagTypes::tagEnd);
275  endTag.WriteXML (o);
276  o << endl;
277  }
278 } /* WriteXML */
279 
280 
281 
282 
284  XmlTagConstPtr tag,
285  VolConstBool& cancelFlag,
286  RunLog& log
287  )
288 {
289  delete nominalValuesUpper;
290  nominalValuesUpper = NULL;
292  fieldNum = tag->AttributeValueInt32 ("FieldNum");
293  name = tag->AttributeValueKKStr ("Name");
294  nameUpper = name.ToUpper ();
295 
296  XmlTokenPtr t = s.GetNextToken (cancelFlag, log);
297  while (t && (!cancelFlag))
298  {
299  if ((t->SectionName ().EqualIgnoreCase ("NominalValues")) && (typeid(*t) == typeid(XmlElementVectorKKStr)))
300  {
301  delete nominalValuesUpper;
302  nominalValuesUpper = new KKStrListIndexed (true, // true == nominalValuesUpper will own its contents.
303  false // false = Not Case Sensitive.
304  );
305  XmlElementVectorKKStrPtr v = dynamic_cast<XmlElementVectorKKStrPtr>(t);
306  if ((v != NULL) && (v->Value () != NULL))
307  {
308  VectorKKStr::const_iterator idx;
309  bool alreadyEixists = false;
310  for (idx = v->Value ()->begin (); idx != v->Value ()->end (); ++idx)
311  AddANominalValue (*idx, alreadyEixists);
312  }
313  }
314  delete t;
315  t = s.GetNextToken (cancelFlag, log);
316  }
317  delete t;
318  t = NULL;
319 }
320 
321 
322 
323 
324 
326  KKQueue<Attribute> (true)
327 {
328 }
329 
330 
331 
332 
333 
336 {
337 }
338 
339 
340 
342 {
343 }
344 
345 
347 {
348  kkint32 memoryConsumedEstimated = sizeof (AttributeList) + nameIndex.size ();
349 
350  {
351  std::map<KKStr, AttributePtr>::const_iterator idx;
352  for (idx = nameIndex.begin (); idx != nameIndex.end (); ++idx)
353  memoryConsumedEstimated += (sizeof (AttributePtr) + idx->first.MemoryConsumedEstimated ());
354  }
355 
356  {
357  AttributeList::const_iterator idx;
358  for (idx = begin (); idx != end (); ++idx)
359  {
360  memoryConsumedEstimated += (*idx)->MemoryConsumedEstimated ();
361  }
362  }
363 
364  return memoryConsumedEstimated;
365 } /* MemoryConsumedEstimated */
366 
367 
368 
369 const
371 {
372  KKStr nameUpper (name);
373  nameUpper.Upper ();
374 
375  map<KKStr, AttributePtr>::const_iterator p;
376  p = nameIndex.find (nameUpper);
377  if (p == nameIndex.end ())
378  return NULL;
379  return p->second;
380 } /* LookUpByName */
381 
382 
383 
385 {
386  AddToNameIndex (attribute);
387  KKQueue<Attribute>::PushOnBack (attribute);
388 }
389 
390 
392 {
393  AddToNameIndex (attribute);
394  KKQueue<Attribute>::PushOnFront (attribute);
395 }
396 
397 
398 
399 void AttributeList::AddToNameIndex (AttributePtr attribute)
400 {
401  nameIndex.insert (pair<KKStr, AttributePtr> (attribute->Name ().ToUpper (), attribute));
402 } /* AddToNameIndex */
403 
404 
405 
407 {
409 
410  const_iterator idx;
411  for (idx = begin (); idx != end (); idx++)
412  {
413  v->push_back ((*idx)->Type ());
414  }
415 
416  return v;
417 } /* CreateAttributeTypeVector */
418 
419 
420 
421 
423 {
424  static vector<KKStr> AttributeTypeStrings =
425  {
426  "Null",
427  "Ignore",
428  "Numeric",
429  "Nominal",
430  "Ordinal"
431  };
432 
433  if ((type < (AttributeType)0) || ((kkuint32)type >= AttributeTypeStrings.size ()))
434  return KKStr::EmptyStr ();
435 
436  return AttributeTypeStrings[(int)type];
437 } /* TypeStr */
438 
439 
440 
441 
443 {
444  if (s.EqualIgnoreCase ("Ignore"))
445  return AttributeType::Ignore;
446 
447  else if (s.EqualIgnoreCase ("Numeric"))
448  return AttributeType::Numeric;
449 
450  else if (s.EqualIgnoreCase ("Nominal"))
451  return AttributeType::Nominal;
452 
453  else if (s.EqualIgnoreCase ("Ordinal"))
454  return AttributeType::Ordinal;
455 
456  else if (s.EqualIgnoreCase ("Symbolic"))
458 
459  else
461 }
462 
463 
464 
465 
466 bool AttributeList::operator== (const AttributeList& right) const
467 {
468  if (size () != right.size ())
469  return false;
470 
471  AttributeList::const_iterator idxL;
472  AttributeList::const_iterator idxR;
473 
474  idxL = begin ();
475  idxR = right.begin ();
476 
477  while (idxL != end ())
478  {
479  AttributePtr leftAttribute = *idxL;
480  AttributePtr rightAttribute = *idxR;
481 
482  if ((*leftAttribute) != (*rightAttribute))
483  return false;
484 
485  ++idxL;
486  ++idxR;
487  }
488 
489  return true;
490 } /* operator== */
491 
492 
493 
494 bool AttributeList::operator!= (const AttributeList& right) const
495 {
496  return !(*this == right);
497 } /* operator!= */
498 
499 
500 
501 void AttributeList::WriteXML (const KKStr& varName,
502  ostream& o
503  ) const
504 {
505  XmlTag startTag ("AttributeList", XmlTag::TagTypes::tagStart);
506  if (!varName.Empty ())
507  startTag.AddAtribute ("VarName", varName);
508  startTag.WriteXML (o);
509  o << endl;
510 
511  AttributeList::const_iterator idx;
512  for (idx = begin (); idx != end (); ++idx)
513  {
514  AttributePtr attribute = *idx;
515  attribute->WriteXML ("", o);
516  }
517  XmlTag endTag ("AttributeList", XmlTag::TagTypes::tagEnd);
518  endTag.WriteXML (o);
519  o << endl;
520 } /* WriteXML */
521 
522 
523 
524 
525 
526 
528  XmlTagConstPtr tag,
529  VolConstBool& cancelFlag,
530  RunLog& log
531  )
532 {
533  DeleteContents ();
534  Owner (true);
535  XmlTokenPtr t = s.GetNextToken (cancelFlag, log);
536  while (t && (!cancelFlag))
537  {
538  if (typeid (*t) == typeid(XmlElementAttribute))
539  {
540  XmlElementAttributePtr attrToken = dynamic_cast<XmlElementAttributePtr> (t);
541  if (attrToken->Value ())
542  PushOnBack (attrToken->TakeOwnership ());
543  }
544  delete t;
545  t = s.GetNextToken (cancelFlag, log);
546  }
547  delete t;
548  t = NULL;
549 }
550 
551 
554 {
555 }
556 
557 
559  AttributeType initialValue
560  ):
562 {
563 }
564 
565 
567 {
568  return (AttributeType)((int)zed + 1);
569 } /* operator++ */
570 
571 
572 void AttributeTypeVector::WriteXML (const KKStr& varName,
573  ostream& o
574  ) const
575 {
576  XmlTag tagStart ("AttributeTypeVector", XmlTag::TagTypes::tagStart);
577  if (!varName.Empty ())
578  tagStart.AddAtribute ("VarName", varName);
579  tagStart.AddAtribute ("Size", (kkint32)size ());
580  tagStart.WriteXML (o);
581  o << endl;
582 
583  o << "CodeTable";
584  for (AttributeType zed = AttributeType::NULLAttribute; zed <= AttributeType::Symbolic; ++zed)
585  o << "\t" << AttributeTypeToStr (zed);
586  o << endl;
587 
588  o << "CodedAttributeValues";
589  for (auto idx: *this)
590  o << "\t" << (int)idx;
591  o << endl;
592 
593  XmlTag tagEnd ("AttributeTypeVector", XmlTag::TagTypes::tagEnd);
594  tagEnd.WriteXML (o);
595  o << endl;
596 }
597 
598 
600  XmlTagConstPtr tag,
601  VolConstBool& cancelFlag,
602  RunLog& log
603  )
604 {
605  clear ();
606 
607  kkuint32 expectedLen = (kkuint32)tag->AttributeValueInt32 ("Size");
608  AttributeTypeVector decodeTable;
609 
610  XmlTokenPtr t = s.GetNextToken (cancelFlag, log);
611  while (t && (!cancelFlag))
612  {
613  if (typeid (*t) == typeid (XmlContent))
614  {
615  KKStrParser p (*(dynamic_cast<XmlContentPtr> (t)->Content ()));
616  p.TrimWhiteSpace (" ");
617  KKStr lineName =p.GetNextToken ();
618  if (lineName.EqualIgnoreCase ("CodeTable"))
619  {
620  KKStr fieldName = p.GetNextToken ();
621  while (p.MoreTokens ())
622  {
623  if (!fieldName.Empty ())
624  decodeTable.push_back (AttributeTypeFromStr (fieldName));
625  fieldName = p.GetNextToken ();
626  }
627  }
628 
629  else if (lineName.EqualIgnoreCase ("CodedAttributeValues"))
630  {
632  if ((x < 0) || (x >= (kkint32)decodeTable.size ()))
633  {
634  log.Level (-1) << endl << "AttributeTypeVector::ReadXML ***ERROR*** Invalid Code Value[" << x << "]" << endl << endl;
635  push_back (AttributeType::NULLAttribute);
636  }
637  else
638  {
639  push_back ((AttributeType)x);
640  }
641 
642  }
643  }
644  t = s.GetNextToken (cancelFlag, log);
645  }
646  delete t;
647  t = NULL;
648 }
649 
650 
651 
652 
653 XmlFactoryMacro(Attribute)
654 XmlFactoryMacro(AttributeList)
655 XmlFactoryMacro(AttributeTypeVector)
kkint32 Add(KKStrPtr s)
Definition: KKStr.cpp:5506
KKStr(kkint32 size)
Creates a KKStr object that pre-allocates space for &#39;size&#39; characters.
Definition: KKStr.cpp:655
XmlTag(const KKStr &_name, TagTypes _tagType)
Definition: XmlStream.cpp:586
void PushOnFront(AttributePtr attribute)
Definition: Attribute.cpp:391
Attribute(const Attribute &a)
Definition: Attribute.cpp:67
void AddANominalValue(const KKStr &nominalValue, bool &alreadyExists)
Adds a allowable Nominal value to the Nominal or Symbolic field that this attribute represents...
Definition: Attribute.cpp:123
const AttributePtr LookUpByName(const KKStr &attributeName) const
Definition: Attribute.cpp:370
void PushOnBack(AttributePtr attribute)
Definition: Attribute.cpp:384
bool EqualIgnoreCase(const char *s2) const
Definition: KKStr.cpp:1257
kkint32 MemoryConsumedEstimated() const
Definition: KKStr.cpp:766
__int32 kkint32
Definition: KKBaseTypes.h:88
const KKStr & GetNominalValue(kkint32 code) const
Returns the nominal value for the given ordinal value.
Definition: Attribute.cpp:143
void TrimWhiteSpace(const char *_whiteSpace=" ")
After this call all leading and trailing whitespace will be trimmed from tokens.
Definition: KKStrParser.cpp:95
bool operator!=(const AttributeList &right) const
Determines if two different attribute lists are different; compares each respective attribute...
Definition: Attribute.cpp:494
KKStr GetNextToken(const char *delStr="\n\t\r ")
Extract next Token from string, tokens will be separated by delimiter characters. ...
KKStrConstPtr LookUp(kkuint32 x) const
Definition: KKStr.cpp:5584
const KKStr & AttributeValueKKStr(const KKStr &name) const
Definition: XmlStream.cpp:688
kkint32 GetNominalCode(const KKStr &nominalValue) const
Definition: Attribute.cpp:185
XmlContent * XmlContentPtr
Definition: XmlStream.h:24
KKStr ToUpper() const
Definition: KKStr.cpp:2517
bool operator!=(const Attribute &rightSide) const
Definition: Attribute.cpp:213
void ReadXML(XmlStream &s, XmlTagConstPtr tag, VolConstBool &cancelFlag, RunLog &log)
Definition: Attribute.cpp:599
XmlToken * XmlTokenPtr
Definition: XmlStream.h:18
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
AttributeType operator++(AttributeType zed)
Definition: Attribute.cpp:566
kkint32 MemoryConsumedEstimated() const
Definition: KKStr.cpp:5454
describes a single Feature, Type and possible values.
Definition: Attribute.h:74
bool MoreTokens() const
Definition: KKStrParser.h:74
Attribute(const KKStr &_name, AttributeType _type, kkint32 _fieldNum)
Definition: Attribute.cpp:44
KKStr & operator=(KKStr &&src)
Definition: KKStr.cpp:1369
Attribute * AttributePtr
Definition: Attribute.h:156
void AddAtribute(const KKStr &attributeName, kkint32 attributeValue)
Definition: XmlStream.cpp:620
KKTHread * KKTHreadPtr
KKStrListIndexed(bool _owner, bool _caseSensitive)
Definition: KKStr.cpp:5381
KKStrParser(const KKStr &_str)
Definition: KKStrParser.cpp:42
kkint32 AttributeValueInt32(const KKStr &attributeName) const
Definition: XmlStream.cpp:676
void WriteXML(const KKStr &varName, std::ostream &o) const
Definition: Attribute.cpp:572
KKStr(const KKStr &str)
Copy Constructor.
Definition: KKStr.cpp:561
void AddAtribute(const KKStr &attributeName, const KKStr &attributeValue)
Definition: XmlStream.cpp:602
AttributeTypeVector * AttributeTypeVectorPtr
Definition: Attribute.h:72
bool Empty() const
Definition: KKStr.h:241
XmlTag const * XmlTagConstPtr
Definition: KKStr.h:45
Manages the reading and writing of objects in a simple XML format. For a class to be supported by Xml...
Definition: XmlStream.h:46
void ReadXML(XmlStream &s, XmlTagConstPtr tag, VolConstBool &cancelFlag, RunLog &log)
Definition: Attribute.cpp:527
AttributeType AttributeTypeFromStr(const KKStr &s)
Definition: Attribute.cpp:442
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of &#39;std::string&#39; strings.
Definition: KKStr.cpp:1082
AttributeTypeVector(kkuint32 initialSize, AttributeType initialValue)
Definition: Attribute.cpp:558
bool operator==(const AttributeList &right) const
Determines if two different attribute lists are the same; compares each respective attribute...
Definition: Attribute.cpp:466
void Upper()
Converts all characters in string to their Upper case equivalents via &#39;toupper&#39;.
Definition: KKStr.cpp:2461
kkint32 MemoryConsumedEstimated() const
Definition: Attribute.cpp:346
static const KKStr & EmptyStr()
Static method that returns an Empty String.
Definition: KKStr.cpp:3453
AttributeType
Definition: Attribute.h:36
kkint32 MemoryConsumedEstimated() const
Definition: Attribute.cpp:92
bool operator!=(const KKStr &right) const
Definition: KKStr.cpp:1558
bool operator==(const Attribute &rightSide) const
Definition: Attribute.cpp:194
void WriteXML(const KKStr &varName, std::ostream &o) const
Definition: KKStr.cpp:5319
AttributeTypeVectorPtr CreateAttributeTypeVector() const
Definition: Attribute.cpp:406
kkint32 GetNextTokenInt(const char *delStr="\n\t\r ")
AttributeType Type() const
Definition: Attribute.h:133
AttributeList(bool owner)
Definition: Attribute.cpp:334
void WriteXML(std::ostream &o)
Definition: XmlStream.cpp:723
KKStr & operator=(const KKStr &src)
Definition: KKStr.cpp:1390
KKStrPtr const Content() const
Definition: XmlStream.h:338
void ReadXML(XmlStream &s, XmlTagConstPtr tag, VolConstBool &cancelFlag, RunLog &log)
Definition: Attribute.cpp:283
Used for logging messages.
Definition: RunLog.h:49
void EncodeProblem(const struct svm_paramater &param, struct svm_problem &prob_in, struct svm_problem &prob_out)
kkint32 LookUp(const KKStr &s) const
Definition: KKStr.cpp:5558
KKStrListIndexed(const KKStrListIndexed &list)
Definition: KKStr.cpp:5397
Class that manages the extraction of tokens from a String without being destructive to the original s...
Definition: KKStrParser.h:18
void WriteXML(const KKStr &varName, std::ostream &o) const
Definition: Attribute.cpp:501
virtual XmlTokenPtr GetNextToken(VolConstBool &cancelFlag, RunLog &log)
Definition: XmlStream.cpp:116
bool operator!=(const KKStrListIndexed &right)
Definition: KKStr.cpp:5499
KKStr TypeStr() const
Definition: Attribute.cpp:241
KKException(const KKStr &_exceptionStr)
Definition: KKException.cpp:45
void WriteXML(const KKStr &varName, std::ostream &o) const
Definition: Attribute.cpp:249
kkint32 Cardinality() const
Returns back the cardinality of the attribute; the number of possible values it can take...
Definition: Attribute.cpp:173
kkuint32 size() const
Definition: KKStr.cpp:5447
const KKStr & AttributeTypeToStr(AttributeType type)
Definition: Attribute.cpp:422
#define XmlFactoryMacro(NameOfClass)
Definition: XmlStream.h:688
Attribute & operator=(const Attribute &right)
Definition: Attribute.cpp:222
volatile const bool VolConstBool
Definition: KKBaseTypes.h:163