Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

serverVI.h

Go to the documentation of this file.
00001 #ifndef serverVI_h
00002 #define serverVI_h
00003 
00004 #include <vector>
00005 #include <string>
00006 //-------------------------
00008         
00029 //------------------------
00030 // JA Hernando, Santa Cruz, CA, 05/15/00
00031 //------------------------
00032 //########################
00033 template<class T> class serverVI 
00034 //########################
00035 {
00036 public:
00037 
00038         
00040         serverVI() {m_names.clear();m_List.clear();}
00042         ~serverVI() {}
00043 
00045         void add(std::string n, T* t) 
00046         {
00047                 if (!search(n)) {
00048                         m_names.push_back(n);
00049                         m_List.push_back(t);
00050                 } 
00051         }
00052 
00054         int size() const {return num();}
00056         int num() const {return (m_List.size() == m_names.size()? m_List.size(): 0);}
00058 
00060         void clear() {m_names.clear();m_List.clear();}
00061 
00063         bool search(std::string name) const {
00064                 for (int i = 0; i < m_List.size(); i++) {
00065                         if (m_names[i] == name) return true;
00066                 }
00067                 return false;
00068         }
00069 
00071         std::string getName(T* t) const {
00072                 for (int i = 0; i < m_List.size(); i++) {
00073                         if (m_List[i] == t) return m_names[i];
00074                 }
00075                 return "EMPTY";
00076         }       
00077 
00079         std::string getName(int i) const {return ((i >=0 && i < num())? m_names[i]: "EMPTY");}
00080 
00082         T* get(std::string name) const {
00083                 for (int i = 0; i < m_List.size(); i++) {
00084                         if (m_names[i] == name) return m_List[i];
00085                 }
00086                 return 0;
00087         }
00088 
00090         T* get(int i) const { return ((i >=0 && i < num())? m_List[i]: 0);}
00091 
00093         std::string nameList() const {
00094                 std::string list = " " ;
00095                 for (int i = 0; i < m_List.size(); i++) list = list+" in server : "+m_names[i]+ " \n ";
00096                 return list;
00097         }       
00098         
00100         void command(std::string com) const {
00101                 for (int i = 0; i < m_List.size(); i++) m_List[i]->command(com);
00102         }
00103 
00104 private:
00105 
00106         std::vector<std::string> m_names;
00107         std::vector<T*> m_List;
00108 
00109 };
00110 #endif

Generated at Fri Aug 18 12:57:38 2000 for centella framework by doxygen 1.1.3 written by Dimitri van Heesch, © 1997-2000