Location.hpp

Go to the documentation of this file.
00001 
00015 #ifndef Location_H
00016 #define Location_H
00017 
00018 #include <iostream>
00019 #include <cassert>
00020 #include <list>
00021 #include <set>
00022 #include <algorithm>
00023 #include <OpenAnalysis/IRInterface/IRHandles.hpp>
00024 #include <OpenAnalysis/OABase/Annotation.hpp>
00025 #include <OpenAnalysis/Utils/OA_ptr.hpp>
00026 
00027 using namespace std;
00028 namespace OA {
00029 
00030 class Location;
00031 
00032 // forward-decl to avoid circular reference in header files
00033 class LocationVisitor;
00034 
00035 
00036 
00037 // Location set abstraction
00038 typedef std::set<OA_ptr<Location> > LocSet;
00039 
00040 void dumpLocSet(std::set<OA_ptr<Location> >& set, std::ostream& os, 
00041                 OA_ptr<IRHandlesIRInterface> pIR, bool succinct=false);
00042 
00044 OA_ptr<std::set<OA_ptr<Location> > > 
00045 intersectLocSets(std::set<OA_ptr<Location> >& set1,
00046                  std::set<OA_ptr<Location> >& set2);
00047                  
00049 OA_ptr<std::set<OA_ptr<Location> > > 
00050     unionLocSets(
00051         std::set<OA_ptr<Location> >& set1,
00052         std::set<OA_ptr<Location> >& set2);
00053 
00057 bool mayOverlapLocSets(std::set<OA_ptr<Location> >& set1,
00058                        std::set<OA_ptr<Location> >& set2);
00059 
00061 bool subSetOf(std::set<OA_ptr<Location> >& set1, 
00062               std::set<OA_ptr<Location> >& set2);
00063 
00064 
00068 class Location : public Annotation {
00069   public:
00070     Location();
00071     Location(Location &loc) {}
00072     virtual ~Location() {}
00073 
00074     virtual void acceptVisitor(LocationVisitor& pVisitor) = 0;
00075 
00076     //*****************************************************************
00077     // Subclass type methods 
00078     //*****************************************************************
00079     virtual bool isaNamed() { return false; }
00080     virtual bool isaUnnamed() { return false; }
00081     virtual bool isaUnknown() { return false; }
00082     virtual bool isaInvisible() { return false; }
00083     virtual bool isaSubSet() { return false; }
00084 
00085     //*****************************************************************
00086     // Info methods 
00087     //*****************************************************************
00088     
00091     virtual OA_ptr<Location> getBaseLoc() = 0;
00092     
00098     virtual bool isLocal() { return false; }
00099 
00106     virtual bool isUnique() { return false; }
00107     
00111     
00112     /* PLM 1/23/07 deprecated hasFullAccuracy
00113     virtual bool hasFullAccuracy() { return true; }
00114     */
00115 
00116     //*****************************************************************
00117     // Relationship methods 
00118     //*****************************************************************
00119 
00121     virtual bool operator<(Location & other) = 0;
00122 
00124     virtual bool operator==(Location & other) = 0;
00125 
00127     virtual bool operator!=(Location & other) { return ! operator==(other); }
00128 
00131     virtual bool mayOverlap(Location & other) { return true; }
00132 
00135     virtual bool mustOverlap(Location & other) { return false; }
00136 
00138     virtual bool subSetOf(Location & other) { return true; }
00139 
00140     //*****************************************************************
00141     // Debugging
00142     //*****************************************************************
00143     virtual void dump(ostream& os, OA_ptr<IRHandlesIRInterface> pIR) = 0;
00144     virtual void dump(ostream& os) = 0;
00145 
00146     virtual string toString(OA_ptr<IRHandlesIRInterface> pIR) = 0;
00147 
00148     virtual int getOrder() { return sOrder; }
00149 
00150   private:
00151     static const int sOrder = -100;
00152 };
00153 
00154 
00155 } // end of OA namespace
00156 #endif

Generated on Sat Oct 31 05:21:22 2009 for OpenAnalysis by  doxygen 1.6.1