proj home

Files   Classes   Functions   Hierarchy  

element.h

Go to the documentation of this file.
00001 #ifndef ELEMENT_H
00002 #define ELEMENT_H
00003 
00004 #include <visitor.h>
00005 
00009 class Element
00010 {
00011 public:
00012 
00014   virtual void accept(const Visitor& v)=0;
00015 
00016   virtual ~Element() {};
00017 };
00018 
00019 
00023 class ElementA : public Element
00024 {
00025 public:
00026 
00028   void accept(const Visitor& v);
00029 
00031   template<typename T>
00032   void print(T t) const;
00033 
00034   template<typename T>
00035   void print2(T t) const;
00036 };
00037 
00041 class ElementB : public Element
00042 {
00043 public:
00044 
00046   void accept(const Visitor& v);
00047 
00049   template<typename T>
00050   void print(T t) const;
00051 
00052   template<typename T>
00053   void print2(T t) const;
00054 };
00055 
00056 
00057 // -------------------------------------------------- 
00058 //  Implementation
00059 
00060 template<typename T>
00061 void ElementA::print(T t) const
00062 {
00063    cout << "*A:t=" << t << endl;
00064 }
00065 
00066 template<typename T>
00067 void ElementB::print(T t) const
00068 {
00069    cout << "#B:t=" << t << endl;
00070 }
00071 
00072 void ElementA::accept(const Visitor& v)
00073 {
00074      v.visit(*this);
00075 }
00076 
00077 void ElementB::accept(const Visitor& v)
00078 {
00079      v.visit(*this);
00080 }
00081 
00082 template<typename T>
00083 void ElementA::print2(T t) const
00084 {
00085    cout << "<tagA>" << t << "</tagA>" << endl;
00086 }
00087 
00088 template<typename T>
00089 void ElementB::print2(T t) const
00090 {
00091    cout << "<tagB>" << t << "</tagB>" << endl;
00092 }
00093 
00094 
00095 #endif
00096 

Generated on Fri Mar 4 00:49:31 2011 for Chelton Evans Source by  doxygen 1.5.8