Debian Codegraph @

Source/Utilities/Container/ContainerSettings.h

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #ifndef KONCLUDE_UTILITIES_CONTAINER_CONTAINERSETTINGS
22 #define KONCLUDE_UTILITIES_CONTAINER_CONTAINERSETTINGS
23
24 // Library includes
25
26
27 // Namespace includes
28
29
30 // Other includes
31 #include "Utilities/UtilitiesSettings.h"
32
33 // Logger includes
34
35
36 namespace Konclude {
37
38 namespace Utilities {
39
40 namespace Container {
41
42
43 /*!
44 *
45 * \file ContainerSettings
46 * \author Andreas Steigmiller
47 * \version 0.1
48 * \brief TODO
49 *
50 */
51
52
53 // forward declarations
54
55 class CModelDataArray;
56 class CModelDataLevelArray;
57
58
59
60 // Konclude code configs
61
62 #define KONCLUDE_CONTAINER_VECTOR_USE_QT_VECTOR_FOR_DEFAULT
63 #define KONCLUDE_CONTAINER_LIST_USE_QT_LIST_FOR_DEFAULT
64 #define KONCLUDE_CONTAINER_HASH_USE_QT_HASH_FOR_DEFAULT
65 #define KONCLUDE_CONTAINER_SET_USE_QT_SET_FOR_DEFAULT
66
67
68 #ifdef KONCLUDE_CONTAINER_VECTOR_USE_QT_VECTOR_FOR_DEFAULT
69 #define KONCLUDE_EMPLOY_QT_VECTOR_CONTAINER
70 #endif // KONCLUDE_CONTAINER_VECTOR_USE_QT_VECTOR_FOR_DEFAULT
71
72 #ifdef KONCLUDE_CONTAINER_LIST_USE_QT_LIST_FOR_DEFAULT
73 #define KONCLUDE_EMPLOY_QT_LIST_CONTAINER
74 #endif // KONCLUDE_CONTAINER_LIST_USE_QT_LIST_FOR_DEFAULT
75
76 #ifdef KONCLUDE_CONTAINER_SET_USE_QT_SET_FOR_DEFAULT
77 #define KONCLUDE_EMPLOY_QT_SET_CONTAINER
78 #endif // KONCLUDE_CONTAINER_SET_USE_QT_SET_FOR_DEFAULT
79
80 #ifdef KONCLUDE_CONTAINER_HASH_USE_QT_HASH_FOR_DEFAULT
81 #define KONCLUDE_EMPLOY_QT_HASH_CONTAINER
82 #endif // KONCLUDE_CONTAINER_HASH_USE_QT_HASH_FOR_DEFAULT
83
84
85 #define KONCLUDE_EMPLOY_QT_MANAGED_RESTRICTED_MODIFICATION_HASH_CONTAINER
86 #define KONCLUDE_EMPLOY_QT_MANAGED_RESTRICTED_MODIFICATION_SET_CONTAINER
87 #define KONCLUDE_EMPLOY_QT_MANAGED_RESTRICTED_MODIFICATION_LIST_CONTAINER
88 #define KONCLUDE_EMPLOY_QT_MANAGED_RESTRICTED_MODIFICATION_MAP_CONTAINER
89
90 // foreach macro definition analog to the foreach macro of qt
91 class CForeachContainerIt {};
92
93 template<class T>
94 class CForeachContainerItTemplate : public CForeachContainerIt {
95 public:
96 CForeachContainerItTemplate(const T& container)
97 : it(container.begin()),itEnd(container.end()),breakCnt(0) {
98 }
99 mutable class T::const_iterator it, itEnd;
100 mutable int breakCnt;
101 inline bool condition() const {
102 return !breakCnt++ && it != itEnd;
103 }
104 };
105
106 template<class T>
107 inline CForeachContainerItTemplate<T> createContainerItTemplate(const T& container) {
108 return CForeachContainerItTemplate<T>(container);
109 }
110
111 template<class T>
112 inline const CForeachContainerItTemplate<T>* getContainerItTemplate(const CForeachContainerIt* conItTemplate, const T& convertT) {
113 return static_cast<const CForeachContainerItTemplate<T>*>(conItTemplate);
114 }
115
116 #define FOREACHIT(variable, container) foreach(variable, container)
117
118 /*
119 #define FOREACHIT(variable, container) \
120 for (const CForeachContainerIt& conItTemplate(createContainerItTemplate(container)); \
121 getContainerItTemplate(&conItTemplate,container)->condition(); \
122 ++(getContainerItTemplate(&conItTemplate,container)->it)) \
123 for (variable = *((getContainerItTemplate(&conItTemplate,container)->it)); \
124 getContainerItTemplate(&conItTemplate,container)->breakCnt; \
125 --getContainerItTemplate(&conItTemplate,container)->breakCnt)
126 */
127
128 #define FOREACHHASHIT(keyVariable, valueVariable, container) \
129 for (const CForeachContainerIt& conItTemplate(createContainerItTemplate(container)); \
130 getContainerItTemplate(&conItTemplate,container)->condition(); \
131 ++(getContainerItTemplate(&conItTemplate,container)->it)) \
132 for (keyVariable = ((getContainerItTemplate(&conItTemplate,container)->it)).key(); \
133 getContainerItTemplate(&conItTemplate,container)->breakCnt == 1; \
134 ++getContainerItTemplate(&conItTemplate,container)->breakCnt) \
135 for (valueVariable = ((getContainerItTemplate(&conItTemplate,container)->it)).value(); \
136 getContainerItTemplate(&conItTemplate,container)->breakCnt == 1; \
137 getContainerItTemplate(&conItTemplate,container)->breakCnt-=2)
138
139
140 #define cForeach FOREACHIT
141 #define cDeleteAll qDeleteAll
142
143 }; // end namespace Container
144
145 }; // end namespace Utilities
146
147 }; // end namespace Konclude
148
149
150 #endif // end KONCLUDE_UTILITIES_CONTAINER_CONTAINERSETTINGS