00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "stdafx.h"
00012 #include "ippdme/misc/ippPropDefinition.h"
00013
00014
00015
00016 ippPropDefinition::ippPropDefinition(
00017 ippOtherKeyType keyword,
00018 propType type
00019 )
00020 : _keyword(keyword)
00021 , _properties(0)
00022 , _n_properties(0)
00023 , _type(type)
00024 {
00025 }
00026
00027 ippPropDefinition::ippPropDefinition(
00028 ippOtherKeyType keyword,
00029 const ippPropDefinition* prop,
00030 int n
00031 )
00032 : _keyword(keyword)
00033 , _properties(prop)
00034 , _n_properties(n)
00035 , _type(object)
00036 {
00037 }
00038
00039 const ippPropDefinition* ippPropDefinition::find(
00040 const ippProp& prop,
00041 bool bLeafOnly
00042 )const
00043 {
00044 const ippPropDefinition* retval = 0;
00045 if (_keyword!= prop.getKey1()) {
00046 return retval;
00047 }
00048 if (prop.getKey2() == EmptyKey && !bLeafOnly) {
00049 return this;
00050 }
00051 ippProp p(prop.getKey2(),prop.getKey3(),prop.getKey4());
00052 if (_n_properties) {
00053 for (int i=0;i<_n_properties;i++) {
00054 retval = _properties[i].find(p,bLeafOnly);
00055 if (retval) {
00056 return retval;
00057 }
00058 }
00059 return 0;
00060 }
00061 return this;
00062 }
00063 #define _count(a) sizeof(a)/sizeof(a[0])
00064
00065 const ippPropDefinition paramDefinition[] = {
00066 ippPropDefinition(EmptyKey,read_write),
00067 ippPropDefinition(Actual,read_write),
00068 ippPropDefinition(Default,read_only),
00069 ippPropDefinition(Max,read_only),
00070 ippPropDefinition(Min,read_only)
00071 };
00072
00073 const ippPropDefinition paramSpeed (Speed ,paramDefinition,_count(paramDefinition));
00074 const ippPropDefinition paramAccel (Accel ,paramDefinition,_count(paramDefinition));
00075 const ippPropDefinition paramApproach(Approach,paramDefinition,_count(paramDefinition));
00076 const ippPropDefinition paramRetract (Retract ,paramDefinition,_count(paramDefinition));
00077 const ippPropDefinition paramSearch (Search ,paramDefinition,_count(paramDefinition));
00078
00079 const ippPropDefinition GotoParProp_[]= {paramSpeed, paramAccel};
00080
00081 const ippPropDefinition paramGotoPar(GoToPar, GotoParProp_,_count(GotoParProp_));
00082
00083 const ippPropDefinition paramPtMeasPar_[] = { paramSpeed, paramAccel , paramApproach, paramRetract , paramSearch};
00084 const ippPropDefinition paramPtMeasPar(PtMeasPar,paramPtMeasPar_,_count(paramPtMeasPar_));
00085
00086 const ippPropDefinition paramScanPar_[] = { paramSpeed, paramAccel , paramRetract };
00087 const ippPropDefinition paramScanPar(ScanPar,paramScanPar_,_count(paramScanPar_));
00088
00089 const ippPropDefinition paramTool_[] = {
00090 ippPropDefinition(Alignment,complex_type),
00091 ippPropDefinition(AlignmentVolume,complex_type),
00092 ippPropDefinition(AvrRadius,read_only),
00093 ippPropDefinition(Name,complex_type),
00094 ippPropDefinition(CollisionVolume,complex_type),
00095 ippPropDefinition(Id,complex_type),
00096 ippPropDefinition(Collection,complex_type) ,
00097 paramGotoPar, paramPtMeasPar , paramScanPar };
00098
00099 const ippPropDefinition paramTool(Tool, paramTool_, _count(paramTool_));
00100 const ippPropDefinition paramFoundTool(FoundTool, paramTool_, _count(paramTool_));
00101
00102 const ippPropDefinition paramPart_[] = {
00103 ippPropDefinition(Temperature,read_write),
00104 ippPropDefinition(XPanCoefficient,read_write),
00105
00106 paramApproach,
00107
00108 paramSearch
00109
00110 };
00111 const ippPropDefinition paramPart(Part,paramPart_,_count(paramPart_));
00112
00113 const ippPropDefinition paramGetProp_[] = { paramPart,paramTool,paramFoundTool };
00114
00115
00116 bool IsObjectOrProperty(const ippProp& prop)
00117 {
00118 for (int i=0;i<_count(paramGetProp_) ; i++) {
00119 const ippPropDefinition& def = paramGetProp_[i];
00120
00121 ippProp prop1(prop.getKey1(),prop.getKey2(),prop.getKey3());
00122
00123 if (def._keyword == prop.getKey1()) {
00124
00125 const ippPropDefinition* found_prop = def.find(prop,false);
00126
00127 if (found_prop ) {
00128 return true;
00129 }
00130 }
00131 }
00132 return false;
00133 }
00134 bool IsMainObject(const ippOtherKeyType keyword1,const ippOtherKeyType keyword2)
00135 {
00136 return IsObjectOrProperty(ippProp(keyword1,keyword2));
00137 }
00138 bool PropertyIsDouble(const ippProp& prop)
00139 {
00140 for (int i=0;i<_count(paramGetProp_) ; i++) {
00141 const ippPropDefinition& def = paramGetProp_[i];
00142 const ippPropDefinition* found_prop = def.find(prop);
00143 if (found_prop && ( found_prop->_type == read_only || found_prop->_type == read_write)) {
00144 return true;
00145 }
00146 }
00147 return false;
00148 }
00149 bool PropertyIsAllowed(const ippProp& prop)
00150 {
00151 for (int i=0;i<_count(paramGetProp_) ; i++) {
00152 const ippPropDefinition& def = paramGetProp_[i];
00153 const ippPropDefinition* found_prop = def.find(prop);
00154 if (found_prop) {
00155 return true;
00156 }
00157 }
00158 return false;
00159 }
00160 bool PropertyIsAllowedAndWritable(const ippProp& prop) {
00161 for (int i=0;i<_count(paramGetProp_) ; i++) {
00162 const ippPropDefinition& def = paramGetProp_[i];
00163 const ippPropDefinition* found_prop = def.find(prop);
00164 if (found_prop && found_prop->_type == read_write) {
00165 return true;
00166 }
00167 }
00168 return false;
00169 }
00170
00171 const ippPropDefinition* findPropertyDefinition(const ippProp& prop)
00172 {
00173 for (int i=0;i<_count(paramGetProp_) ; i++) {
00174 const ippPropDefinition& def = paramGetProp_[i];
00175
00176 const ippPropDefinition* p = def.find(prop,false);
00177 if (p) {
00178 return p;
00179 }
00180 }
00181 return 0;
00182 }