C++ main module for gpm Package  1.0
GPM_Edge.h
Go to the documentation of this file.
1 #ifndef GPM_Edge_H
2 #define GPM_Edge_H
3 
4 #include "GPM_GraphElement.h"
5 
6 
14 
15 class GPM_Edge : public GPM_GraphElement {
16  SP_OBJECT(GPM_Edge);
17  // ATTRIBUTES
18 
19 private:
20 
21 
22  WP::GPM_Vertex mSource;
23  WP::GPM_Vertex mTarget;
24 
25 
26 protected:
27  // METHODS
28 
29  // CONSTRUCTORS
30 
32  GPM_Edge(SP::GPM_Vertex source,SP::GPM_Vertex target);
33 
34 
35 
36  // DESTRUCTORS
37 
38 
41  virtual ~GPM_Edge(void);
42 
43 
44 public:
45 
46  // NEW methods
47 
50  static inline SP::GPM_Edge New(SP::GPM_Vertex source,
51  SP::GPM_Vertex target) {
52  SP::GPM_Edge p(new GPM_Edge(source,target),GPM_Edge::Delete());
53 
54  p->setThis(p);
55  return p;
56  }
59  static inline SP::GPM_Edge New(const int& id) {
60  SP::GPM_Vertex edge,target;
61  SP::GPM_Edge p=New(edge,target);
62  p->setId(id);
63  return p;
64  }
67  static inline SP::GPM_Edge New() {
68  SP::GPM_Vertex edge,target;
69  return New(edge,target);
70  }
71 
72 
73 
76  virtual SP::GPM_GraphElement NewInstance() const {
77  return New();
78  }
79 
82  virtual SP::GPM_Edge NewCopyInstance() const {
83  SP::GPM_Edge p=New();
84  p->copy(*this);
85  return p;
86  }
87 
88  // SET & GET methods
91  virtual tString getGroupTypeName() const {
92  return "EDGE";
93  }
96  inline void setSource(SP::GPM_Vertex v) {
97  mSource=v;
98  }
99 
102  inline void setTarget(SP::GPM_Vertex v) {
103  mTarget=v;
104  }
105 
106 
107 
110  inline SP::GPM_Vertex getSource() const {
111  SP::GPM_Vertex v=mSource.lock();
112  return v;
113  }
114 
117  inline SP::GPM_Vertex getTarget() const {
118  SP::GPM_Vertex v=mTarget.lock();
119  return v;
120  }
121 
122 
123 
124 
125 
126 
127  // IO methods
128 
132  virtual void saveToStream(ofstream& f) const;
136 
139  virtual tString toString() const;
140 };
141 
142 #endif
virtual tString getGroupTypeName() const
get the default group type name
Definition: GPM_Edge.h:91
DEFINE_SPTR(GPM_Edge)
GPM_Edge(SP::GPM_Vertex source, SP::GPM_Vertex target)
create an object
Definition: GPM_Edge.cpp:7
static SP::GPM_Edge New(const int &id)
create an edge
Definition: GPM_Edge.h:59
static SP::GPM_Edge New(SP::GPM_Vertex source, SP::GPM_Vertex target)
create an edge
Definition: GPM_Edge.h:50
SP::GPM_Vertex getSource() const
get the source vertex
Definition: GPM_Edge.h:110
SP::GPM_Vertex getTarget() const
get the target vertex
Definition: GPM_Edge.h:117
#define tBoolean
Definition: types.h:35
virtual ~GPM_Edge(void)
destroy an object.
Definition: GPM_Edge.cpp:16
virtual tString toString() const
turn the class into string
Definition: GPM_Edge.cpp:33
This class describes a edge.
Definition: GPM_Edge.h:15
virtual SP::GPM_Edge NewCopyInstance() const
create a new instance
Definition: GPM_Edge.h:82
void setTarget(SP::GPM_Vertex v)
set the target vertex
Definition: GPM_Edge.h:102
tBoolean loadFromStream(tString &f)
Definition: GPM_Edge.cpp:26
static SP::GPM_Edge New()
create an edge
Definition: GPM_Edge.h:67
#define tString
Definition: types.h:36
DEFINE_SVPTR(GPM_Edge)
virtual SP::GPM_GraphElement NewInstance() const
create a new instance
Definition: GPM_Edge.h:76
void setSource(SP::GPM_Vertex v)
set the source vertex
Definition: GPM_Edge.h:96
virtual void saveToStream(ofstream &f) const
Definition: GPM_Edge.cpp:20
This class describes an element of a graph.
Definition: GPM_GraphElement.h:17
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106