00001
00002
00003
00004 #ifndef ASTATTRIBUTEMECHANISM_H
00005 #define ASTATTRIBUTEMECHANISM_H
00006
00007 #include "AttributeMechanism.h"
00008
00009 class SgNode;
00010
00011 class AstAttribute
00012 {
00013
00014
00015
00016 public:
00017
00018
00019 class AttributeEdgeInfo
00020 {
00021 public:
00022 SgNode* fromNode;
00023 SgNode* toNode;
00024 std::string label;
00025 std::string options;
00026
00027 AttributeEdgeInfo (SgNode* fromNode, SgNode* toNode, std::string label, std::string options )
00028 : fromNode(fromNode), toNode(toNode), label(label), options(options)
00029 {
00030 }
00031
00032 ~AttributeEdgeInfo () { fromNode = NULL; toNode = NULL; };
00033 };
00034
00035
00036 class AttributeNodeInfo
00037 {
00038 public:
00039 SgNode* nodePtr;
00040 std::string label;
00041 std::string options;
00042
00043 AttributeNodeInfo (SgNode* nodePtr, std::string label, std::string options )
00044 : nodePtr(nodePtr), label(label), options(options)
00045 {
00046 }
00047
00048 ~AttributeNodeInfo () {};
00049 };
00050 #if 1
00051 AstAttribute();
00052 virtual ~AstAttribute();
00057 virtual std::string toString();
00058
00059
00060 AstAttribute* constructor();
00061 std::string attribute_class_name();
00062
00063
00064 virtual int packed_size();
00065 virtual char* packed_data();
00066 virtual void unpacked_data( int size, char* data );
00067
00068
00069 virtual std::string additionalNodeOptions();
00070
00071
00072
00073 virtual std::vector<AttributeEdgeInfo> additionalEdgeInfo();
00074 virtual std::vector<AttributeNodeInfo> additionalNodeInfo();
00075
00076
00077
00078
00079 virtual AstAttribute* copy();
00080
00081
00082
00083 virtual bool commentOutNodeInGraph();
00084 #else
00085 AstAttribute() {}
00086 virtual ~AstAttribute() {}
00091 virtual std::string toString() { return ""; }
00092
00093
00094 AstAttribute* constructor() { return new AstAttribute(); }
00095 std::string attribute_class_name() { return "AstAttribute"; }
00096
00097
00098 virtual int packed_size() { return 0; }
00099 virtual char* packed_data() { return NULL; }
00100 virtual void unpacked_data( int size, char* data ) {}
00101
00102
00103 virtual std::string additionalNodeOptions() { return ""; }
00104
00105
00106
00107 virtual std::vector<AttributeEdgeInfo> additionalEdgeInfo() { std::vector<AttributeEdgeInfo> v; return v; }
00108 virtual std::vector<AttributeNodeInfo> additionalNodeInfo() { std::vector<AttributeNodeInfo> v; return v; }
00109
00110
00111
00112
00113 virtual AstAttribute* copy() { return new AstAttribute(*this); }
00114
00115
00116
00117 virtual bool commentOutNodeInGraph() { return false; }
00118 #endif
00119
00120 };
00121
00122
00134 class MetricAttribute : public AstAttribute
00135 {
00136 public:
00137 MetricAttribute();
00138 MetricAttribute(double value, bool is_derived=false);
00139
00140 MetricAttribute& operator+= (const MetricAttribute & other);
00141 MetricAttribute& operator-= (const MetricAttribute & other);
00142 MetricAttribute& operator*= (const MetricAttribute & other);
00143 MetricAttribute& operator/= (const MetricAttribute & other);
00144
00145 virtual AstAttribute* constructor();
00146 virtual AstAttribute* copy();
00147
00148 virtual std::string attribute_class_name();
00149
00150 virtual int packed_size();
00151 virtual char* packed_data();
00152 virtual void unpacked_data( int size, char* data );
00153
00154 virtual bool isDerived() const;
00155 virtual double getValue() const;
00156 virtual void setValue(double newVal);
00157 virtual std::string toString();
00158
00159 protected:
00160 bool is_derived_;
00161 double value_;
00162 };
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172 class AstAttributeMechanism : public AttributeMechanism<std::string,AstAttribute*>
00173 {
00174 public:
00175
00176
00177 AstAttributeMechanism ( const AstAttributeMechanism & X );
00178
00179
00180
00181 AstAttributeMechanism ();
00182 };
00183
00184
00185
00192 class AstRegExAttribute : public AstAttribute
00193 {
00194 public:
00195 std::string expression;
00196
00197 AstRegExAttribute();
00198 AstRegExAttribute(const std::string & s);
00199 };
00200
00201 #endif