00001 00016 #ifndef InterUseful_H 00017 #define InterUseful_H 00018 00019 #include <OpenAnalysis/Activity/UsefulStandard.hpp> 00020 #include <OpenAnalysis/OABase/Annotation.hpp> 00021 #include <map> 00022 00023 namespace OA { 00024 namespace Activity { 00025 00026 class InterUseful : public virtual Annotation { 00027 public: 00028 InterUseful() { mNumIter = 0; } 00029 virtual ~InterUseful() {} 00030 00032 OA_ptr<Activity::UsefulStandard> getUsefulResults(ProcHandle proc) 00033 { if (mProcToUsefulMap[proc].ptrEqual(0)) { 00034 OA_ptr<UsefulStandard> empty; 00035 empty = new UsefulStandard(proc); 00036 mProcToUsefulMap[proc] = empty; 00037 } 00038 return mProcToUsefulMap[proc]; 00039 } 00040 00042 int getNumIter() { return mNumIter; } 00043 00044 //***************************************************************** 00045 // Output 00046 //***************************************************************** 00048 void dump(std::ostream& os, OA_ptr<IRHandlesIRInterface> ir) 00049 { 00050 os << "====================== InterUseful" << std::endl; 00051 std::map<ProcHandle,OA_ptr<UsefulStandard> >::iterator mapIter; 00052 for (mapIter=mProcToUsefulMap.begin(); 00053 mapIter!=mProcToUsefulMap.end(); 00054 mapIter++) 00055 { 00056 OA_ptr<UsefulStandard> results = mapIter->second; 00057 results->dump(os,ir); 00058 os << "-------------------------------" << std::endl; 00059 } 00060 os << "\nInterUseful Number of Iterations = " << mNumIter 00061 << "\n\n====================== End InterUseful\n\n"; 00062 } 00063 00064 00065 00066 //***************************************************************** 00067 // Annotation Interface 00068 //***************************************************************** 00069 void output(IRHandlesIRInterface &ir) { 00070 00071 sOutBuild->objStart("InterUseful"); { 00072 sOutBuild->mapStart("mProcToUsefulMap","ProcHandle","UsefulStandard"); 00073 std::map<ProcHandle,OA_ptr<UsefulStandard> >::iterator mapIter; 00074 for (mapIter=mProcToUsefulMap.begin(); 00075 mapIter!=mProcToUsefulMap.end(); 00076 mapIter++) 00077 { 00078 ProcHandle proc = mapIter->first; 00079 OA_ptr<UsefulStandard> results = mapIter->second; 00080 00081 sOutBuild->mapEntryStart(); { 00082 sOutBuild->mapKeyStart(); { 00083 sOutBuild->outputIRHandle(proc,ir); 00084 } sOutBuild->mapKeyEnd(); 00085 sOutBuild->mapValueStart(); { 00086 results->output(ir); 00087 } sOutBuild->mapValueEnd(); 00088 } sOutBuild->mapEntryEnd(); 00089 } 00090 sOutBuild->mapEnd("mProcToUsefulMap"); 00091 } sOutBuild->objEnd("InterUseful"); 00092 00093 } 00094 00095 //***************************************************************** 00096 // Construction methods 00097 //***************************************************************** 00098 00100 void mapProcToUseful(ProcHandle proc, OA_ptr<UsefulStandard> useful) 00101 { mProcToUsefulMap[proc] = useful; } 00102 00104 void setNumIter(int n) { mNumIter = n; } 00105 00106 private: 00107 std::map<ProcHandle,OA_ptr<UsefulStandard> > mProcToUsefulMap; 00108 int mNumIter; 00109 00110 00111 }; 00112 00113 } // end of Activity namespace 00114 } // end of OA namespace 00115 00116 #endif 00117
1.7.1