00001
00002
00003
00004
00005
00006
00007 #ifndef INCLUDE__TERMINAL_H__FILE
00008 #define INCLUDE__TERMINAL_H__FILE
00009
00010 #include "defs.h"
00011 #include "EGException.h"
00012
00018 template<class TN>
00019 class EGTTerminal {
00020 public:
00021 typedef TN Node;
00022 typedef EGTTerminal<TN> Self;
00023
00025 EGTTerminal()
00026 : m_tNode(0), m_uTermNum(0), m_tDest(0) { }
00028 virtual ~EGTTerminal() { }
00029
00031 void SetTerm(Self* ret) { m_tDest = ret; }
00033 virtual Self* GetTerm() const { return m_tDest; }
00034
00036 void SetNode(Node* ret) { m_tNode = ret; }
00038 Node* GetNode() const { return m_tNode; }
00039
00041 void SetTermNum(UInt ret) { m_uTermNum = ret; }
00043 UInt GetTermNum() const { return m_uTermNum; }
00044
00046 UInt GetDestTermNum() const {
00047 CheckDest(__FILE__, __LINE__);
00048 return m_tDest->GetTermNum();
00049 }
00051 Node* GetDestNode() const {
00052 CheckDest(__FILE__, __LINE__);
00053 return m_tDest->GetNode();
00054 }
00056 UInt GetDestNodeID() const {
00057 CheckDest(__FILE__, __LINE__);
00058 return m_tDest->GetNode()->GetNodeID();
00059 }
00061 void CheckNode(char* filename, UInt uLine) const {
00062 #ifdef DEBUG
00063 if (m_tNode == 0) {
00064 throw EGException("EGTTerminal, "
00065 "This Terminal does not belong to any Nodes.",
00066 filename, uLine);
00067 }
00068 #endif
00069 }
00071 void CheckDest(char* filename, UInt uLine) const {
00072 #ifdef DEBUG
00073 if (m_tDest == 0) {
00074 throw EGException("EGTTerminal, "
00075 "This Terminal is not connected to any Terminals.",
00076 filename, uLine);
00077 }
00078 #endif
00079 }
00080
00081 private:
00083 Node* m_tNode;
00085 UInt m_uTermNum;
00087 Self* m_tDest;
00088
00089 EGTTerminal(const Self&);
00090 Self& operator=(const Self&);
00091 };
00092
00093 #endif //INCLUDE__TERMINAL_H__FILE
00094