00001 #ifndef RELATION_H
00002 #define RELATION_H
00003
00004 #include "string"
00005 #include "BONImpl.h"
00006
00007
00008 class Relation
00009 {
00010 public:
00011
00012 static const std::string containment_str;
00013 static const std::string folder_containment_str;
00014 static const std::string set_membership_str;
00015 static const std::string refer_to_str;
00016 static const std::string has_aspect_str;
00017 static const std::string aspect_member_str;
00018 static const std::string has_constraint_str;
00019 static const std::string has_attribute_str;
00020
00021
00022 static const std::string connector_str;
00023 static const std::string connector_src;
00024 static const std::string connector_dst;
00025 static const std::string connector_descr;
00026
00027 static const std::string equivalence_str;
00028 static const std::string equivalence_right;
00029 static const std::string equivalence_left;
00030
00031 static const std::string inheritance_str;
00032 static const std::string inheritance_base;
00033 static const std::string inheritance_derived;
00034
00035 static const std::string int_inheritance_str;
00036 static const std::string int_inheritance_base;
00037 static const std::string int_inheritance_derived;
00038
00039 static const std::string imp_inheritance_str;
00040 static const std::string imp_inheritance_base;
00041 static const std::string imp_inheritance_derived;
00042
00043 static const std::string same_folder_str;
00044 static const std::string same_folder_right;
00045 static const std::string same_folder_left;
00046
00047 static const std::string same_aspect_str;
00048 static const std::string same_aspect_right;
00049 static const std::string same_aspect_left;
00050
00051
00052 typedef enum
00053 {
00054
00055 CONTAINMENT_OP,
00056 FOLDER_CONTAINMENT_OP,
00057 SET_MEMBER_OP,
00058 REFER_TO_OP,
00059 HAS_ASPECT_OP,
00060 ASPECT_MEMBER_OP,
00061 HAS_CONSTRAINT_OP,
00062 HAS_ATTRIBUTE_OP,
00063
00064 ASSOCIATION_OP,
00065 EQUIVALENCE_OP,
00066 INHERITANCE_OP,
00067 INT_INHERITANCE_OP,
00068 IMP_INHERITANCE_OP,
00069 SAME_FOLDER_OP,
00070 SAME_ASPECT_OP
00071 } OPER_TYPE;
00072
00073 inline std::string getOperationStr() const {
00074 const std::string strings[] = {
00075 "CONTAINMENT_OP",
00076 "FOLDER_CONTAINMENT_OP",
00077 "SET_MEMBER_OP",
00078 "REFER_TO_OP",
00079 "HAS_ASPECT_OP",
00080 "ASPECT_MEMBER_OP",
00081 "HAS_CONSTRAINT_OP",
00082 "HAS_ATTRIBUTE_OP",
00083 "ASSOCIATION_OP",
00084 "EQUIVALENCE_OP",
00085 "INHERITANCE_OP",
00086 "INT_INHERITANCE_OP",
00087 "IMP_INHERITANCE_OP",
00088 "SAME_FOLDER_OP",
00089 "SAME_ASPECT_OP"
00090 };
00091 return strings[m_operation];
00092 }
00093
00094 inline OPER_TYPE getOperation() const { return m_operation; }
00095 inline const BON::FCO getOp1() const { return m_operand1; }
00096 inline const BON::FCO getOp2() const { return m_operand2; }
00097 inline const BON::FCO getOp3() const { return m_operand3; }
00098 inline const BON::FCO getOp4() const { return m_operand4; }
00099 inline const BON::FCO getOp5() const { return m_operand5; }
00100
00101 inline void setOperation( OPER_TYPE oper_t) { m_operation = oper_t; }
00102 inline void setOp1(const BON::FCO op_1) { m_operand1 = op_1; }
00103 inline void setOp2(const BON::FCO op_2) { m_operand2 = op_2; }
00104 inline void setOp3(const BON::FCO op_3) { m_operand3 = op_3; }
00105 inline void setOp4(const BON::FCO op_4) { m_operand4 = op_4; }
00106 inline void setOp5(const BON::FCO op_5) { m_operand5 = op_5; }
00107
00108 explicit Relation(
00109 OPER_TYPE oper_t,
00110 const BON::FCO operd1 = BON::FCO(),
00111 const BON::FCO operd2 = BON::FCO(),
00112 const BON::FCO operd3 = BON::FCO(),
00113 const BON::FCO operd4 = BON::FCO(),
00114 const BON::FCO operd5 = BON::FCO())
00115 : m_operation( oper_t),
00116 m_operand1( operd1),
00117 m_operand2( operd2),
00118 m_operand3( operd3),
00119 m_operand4( operd4),
00120 m_operand5( operd5) { };
00121
00122 ~Relation() { }
00123
00124 Relation( const Relation & operand):
00125 m_operation( operand.m_operation),
00126 m_operand1( operand.m_operand1),
00127 m_operand2( operand.m_operand2),
00128 m_operand3( operand.m_operand3),
00129 m_operand4( operand.m_operand4),
00130 m_operand5( operand.m_operand5) { };
00131
00132 const Relation & operator=(const Relation & operand)
00133 {
00134 if ( this == &operand) return *this;
00135 m_operation = operand.m_operation;
00136 m_operand1 = operand.m_operand1;
00137 m_operand2 = operand.m_operand2;
00138 m_operand3 = operand.m_operand3;
00139 m_operand4 = operand.m_operand4;
00140 m_operand5 = operand.m_operand5;
00141 return *this;
00142 }
00143
00144 bool operator==( const Relation& peer)
00145 {
00146 return (m_operation==peer.m_operation) &&
00147 (m_operand1 == peer.m_operand1) &&
00148 (m_operand2 == peer.m_operand2) &&
00149 (m_operand3 == peer.m_operand3) &&
00150 (m_operand4 == peer.m_operand4) &&
00151 (m_operand5 == peer.m_operand5);
00152 }
00153
00154 bool operator<( const Relation& peer) const
00155 {
00156 if ( m_operation != peer.m_operation) return m_operation < peer.m_operation;
00157
00158 int k;
00159 k = m_operand1->getName().compare( peer.m_operand1->getName());
00160 if( k != 0) return k < 0;
00161 k = m_operand2->getName().compare( peer.m_operand2->getName());
00162 if( k != 0) return k < 0;
00163 k = m_operand3->getName().compare( peer.m_operand3->getName());
00164 return ( k < 0);
00165 }
00166
00167 private:
00168 OPER_TYPE m_operation;
00169 BON::FCO m_operand1;
00170 BON::FCO m_operand2;
00171 BON::FCO m_operand3;
00172 BON::FCO m_operand4;
00173 BON::FCO m_operand5;
00174 };
00175
00176
00177 #endif //RELATION_H
00178
00179