00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef TORC_GENERIC_OM_LOGICELEMENT_HPP
00017 #define TORC_GENERIC_OM_LOGICELEMENT_HPP
00018
00019 #include "torc/generic/om/PointerTypes.hpp"
00020 #include "torc/generic/om/LogicValue.hpp"
00021 #include "torc/generic/util/Error.hpp"
00022 #include "torc/generic/om/FactoryType.hpp"
00023 #include "torc/generic/om/VisitorType.hpp"
00024
00025 #include <list>
00026 #include <vector>
00027
00028 namespace torc { namespace generic { class LogicValue; } }
00029 namespace torc { namespace generic { class BaseVisitor; } }
00030
00031 namespace torc {
00032
00033 namespace generic {
00034
00035
00036
00037
00038
00039
00040
00041
00042 class LogicElement
00043 : public LogicValue {
00044
00045 friend class FactoryType<LogicElement>;
00046
00047 public:
00048
00049
00050
00051
00052 enum Type
00053 {
00054 eTypeSingle = 0,
00055 eTypeList,
00056 eTypeOneOf,
00057 eTypeWaveForm,
00058 eTypeIgnored,
00059 eTypeTransition,
00060 eTypeBecomes
00061 };
00062
00063
00064
00065
00066
00067
00068 enum RelationType
00069 {
00070 eRelationTypeParent = 0,
00071 eRelationTypeChild
00072 };
00073
00074
00075
00076
00077 typedef VisitorType<LogicElement> Visitor;
00078
00079
00080
00081
00082 class Factory: public FactoryType<LogicElement>
00083 {
00084 public:
00085 using FactoryType<LogicElement>::create;
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 LogicElementSharedPtr
00097 virtual newLogicElementPtr( const LogicElement::Type & inType,
00098 const LogicValueSharedPtr & inLogicValue
00099 = LogicValueSharedPtr(),
00100 const LogicElementSharedPtr & inParentLogicElement
00101 = LogicElementSharedPtr() ) throw(Error);
00102 };
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 virtual void
00118 accept(BaseVisitor & visitor) throw(Error);
00119
00120
00121
00122
00123
00124
00125 inline const Type
00126 getType() const throw();
00127
00128
00129
00130
00131
00132
00133 void
00134 setType( const Type & inSource ) throw();
00135
00136
00137
00138
00139
00140
00141 inline void
00142 getChildren( std::vector< LogicElementSharedPtr >
00143 & outLogicElements ) const throw();
00144
00145
00146
00147
00148
00149
00150
00151
00152 void
00153 setChildren(const std::vector< LogicElementSharedPtr >
00154 & inSource) throw();
00155
00156
00157
00158
00159
00160
00161 bool
00162 addChildLogicElement(
00163 const LogicElementSharedPtr & inChildLogicElement) throw();
00164
00165
00166
00167
00168
00169 template<typename _Action>
00170 inline void applyOnAllChildren(const _Action & action) throw(Error);
00171
00172
00173
00174
00175
00176
00177 inline const RelationType
00178 getRelationType() const throw();
00179
00180
00181
00182
00183
00184
00185 void
00186 setRelationType(const RelationType & inSource) throw();
00187
00188
00189
00190
00191
00192 size_t
00193 getSize() const throw();
00194
00195 ~LogicElement() throw();
00196
00197 protected:
00198 LogicElement();
00199
00200 private:
00201 Type mType;
00202 RelationType mRelationType;
00203 std::vector< LogicElementSharedPtr > mChildren;
00204
00205 };
00206
00207
00208
00209
00210
00211
00212 inline const LogicElement::Type
00213 LogicElement::getType() const throw() {
00214 return mType;
00215 }
00216
00217
00218
00219
00220
00221
00222 inline void
00223 LogicElement::getChildren( std::vector< LogicElementSharedPtr >
00224 & outLogicElements ) const throw() {
00225 outLogicElements.insert( outLogicElements.end(),
00226 mChildren.begin(), mChildren.end() );
00227 }
00228
00229
00230
00231
00232
00233 template<typename _Action>
00234 inline void
00235 LogicElement::applyOnAllChildren(const _Action & action) throw(Error) {
00236 try
00237 {
00238 std::vector< LogicElementSharedPtr >::iterator it
00239 = mChildren.begin();
00240 for(; it != mChildren.end(); ++ it )
00241 {
00242 action( *it );
00243 }
00244 }
00245 catch(Error &e)
00246 {
00247 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00248 throw;
00249 }
00250 }
00251
00252
00253
00254
00255
00256
00257 inline const LogicElement::RelationType
00258 LogicElement::getRelationType() const throw() {
00259 return mRelationType;
00260 }
00261
00262 }
00263
00264 }
00265 #endif // TORC_GENERIC_OM_LOGICELEMENT_HPP