00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __DAE_SIDRESOLVER_H__
00010 #define __DAE_SIDRESOLVER_H__
00011
00012 #include <string>
00013 #include <map>
00014 #include <dae/daeTypes.h>
00015 #include <dae/daeElement.h>
00016
00017
00018
00019
00020
00021
00022
00023 struct DLLSPEC daeSidRef {
00024
00025 struct DLLSPEC resolveData {
00026 resolveData();
00027 resolveData(daeElement* elt, daeDoubleArray* array, daeDouble* scalar);
00028
00029 daeElement* elt;
00030 daeDoubleArray* array;
00031 daeDouble* scalar;
00032 };
00033
00034 daeSidRef();
00035 daeSidRef(const std::string& sidRef, daeElement* referenceElt, const std::string& profile = "");
00036 bool operator<(const daeSidRef& other) const;
00037
00038 resolveData resolve();
00039
00040 std::string sidRef;
00041 daeElement* refElt;
00042 std::string profile;
00043 };
00044
00045
00058 class DLLSPEC daeSIDResolver
00059 {
00060 public:
00064 enum ResolveState{
00066 target_empty,
00068 target_loaded,
00070 sid_failed_not_found,
00072 sid_success_element,
00074 sid_success_array,
00076 sid_success_double
00077 };
00078
00085 daeSIDResolver( daeElement *container, daeString target, daeString platform = NULL );
00086
00091 daeString getTarget() const;
00096 void setTarget( daeString t );
00097
00102 daeString getProfile() const;
00107 void setProfile( daeString p );
00108
00113 daeElement* getContainer() const;
00118 void setContainer(daeElement* element);
00119
00124 daeElement* getElement();
00125
00131 daeDoubleArray *getDoubleArray();
00132
00140 daeDouble *getDouble();
00141
00142
00143 ResolveState getState() const;
00144
00145 private:
00146
00147 std::string target;
00148 std::string profile;
00149 daeElement* container;
00150 };
00151
00152
00153
00154 class DLLSPEC daeSidRefCache {
00155 public:
00156 daeSidRefCache();
00157
00158 daeSidRef::resolveData lookup(const daeSidRef& sidRef);
00159 void add(const daeSidRef& sidRef, const daeSidRef::resolveData& data);
00160 void clear();
00161
00162
00163 bool empty();
00164 int misses();
00165 int hits();
00166
00167 private:
00168 std::map<daeSidRef, daeSidRef::resolveData> lookupTable;
00169 int hitCount;
00170 int missCount;
00171 };
00172
00173 #endif
00174