Kigs Framework  Doc version 0.8
Open source multi purpose Rapid Application Development framework
maBool.h
1 #pragma once
2 
4 #include "AttributeModifier.h"
5 
6 // ****************************************
7 // * maBoolHeritage class
8 // * --------------------------------------
14 // ****************************************
15 template<int notificationLevel>
16 class maBoolHeritage : public CoreModifiableAttributeData<bool>
17 {
18  DECLARE_ATTRIBUTE_HERITAGE(maBoolHeritage, maBoolHeritage, bool, CoreModifiable::ATTRIBUTE_TYPE::BOOL);
19 
20 public:
21 
22  // getValue overloads
23 #define IMPLEMENT_GET_VALUE_BOOL(type)\
24  virtual bool getValue(type value) const override \
25  {\
26  bool tmpValue = mValue;\
27  CALL_GETMODIFIER(notificationLevel, tmpValue);\
28  value = (type)tmpValue;\
29  return true;\
30  }
31  EXPAND_MACRO_FOR_BASE_TYPES(NOQUALIFIER, &, IMPLEMENT_GET_VALUE_BOOL);
32 
33  virtual bool getValue(kstl::string& value) const override
34  {
35  bool tmpValue = mValue;
36  CALL_GETMODIFIER(notificationLevel, tmpValue);
37  value = tmpValue ? "true" : "false";
38  return true;
39  }
41 
42  // setValue overloads
43 #define IMPLEMENT_SET_VALUE_BOOL(type)\
44  virtual bool setValue(type value) override\
45  {\
46  if (isReadOnly()) { return false; }\
47  bool tmpValue = (value != (type)0);\
48  CALL_SETMODIFIER(notificationLevel, tmpValue); \
49  mValue = tmpValue; \
50  DO_NOTIFICATION(notificationLevel);\
51  return true;\
52  }
53 
54  EXPAND_MACRO_FOR_BASE_TYPES(NOQUALIFIER, NOQUALIFIER, IMPLEMENT_SET_VALUE_BOOL);
55 
56 
57  virtual bool setValue(const kstl::string& value) override
58  {
59  if (this->isReadOnly()) { return false; }
60  bool tmpValue = (value == "true" || value == "TRUE");
61  CALL_SETMODIFIER(notificationLevel, tmpValue);
62  mValue = tmpValue;
63  DO_NOTIFICATION(notificationLevel);
64  return true;
65  }
66  virtual bool setValue(const char* value) override { if (this->isReadOnly()) { return false; } if (value) { kstl::string localstr(value); return setValue(localstr); } return setValue(false);}
68 
69 };
70 
72 
73 
74 
75 
76 
77 #undef IMPLEMENT_SET_VALUE_BOOL
78 #undef IMPLEMENT_GET_VALUE_BOOL
79 
CoreModifiableAttribute::isReadOnly
virtual bool isReadOnly()
Read only attributes cannot be modified with setValue.
Definition: CoreModifiableAttribute.h:276
maBoolHeritage
CoreModifiableAttributeData for bool with different level of notification.
Definition: maBool.h:16
CoreModifiableAttribute.h
Base template class for CoreModifiable attributes managing data.