00001 00002 00003 00004 00005 00006 00007 00008 #ifndef DEVICECOLLECTION_H 00009 #define DEVICECOLLECTION_H 00010 00011 #include <iostream> 00012 #include <vector> 00013 #include <string> 00014 #include <cstring> 00015 #include <helper.h> 00016 00017 class collectionMember { 00018 public: 00019 collectionMember():deviceName(""),devicePosition(0){}; 00020 virtual ~collectionMember(){}; 00021 std::string deviceName; 00022 float devicePosition; 00023 }; 00024 00025 class deviceCollection { 00026 friend class Connect; 00027 friend class CAFE; 00028 //if HAVE_LIBQTXML 00029 friend class loadCollectionXMLParser; 00030 //endif 00031 private: 00032 std::string name; 00033 std::string description; 00034 std::vector<collectionMember> cMembers; 00035 std::vector<std::string> attributes; 00036 00037 Helper helper; 00038 public: 00039 deviceCollection():description("collection of devices"){}; 00040 virtual ~deviceCollection(){}; 00041 00042 std::string getName() const {return name;}; 00043 std::string getDescription() const {return description;}; 00044 std::vector<collectionMember> getCMembers() const {return cMembers;}; 00045 00046 std::vector<std::string> getAttributes() const {return attributes;}; 00047 std::vector<float> getPositions() { 00048 std::vector<float> posV; posV.clear(); posV.reserve(cMembers.size()); 00049 for (size_t i=0; i<cMembers.size(); ++i) { 00050 posV.push_back(cMembers[i].devicePosition); 00051 }; 00052 return posV; 00053 }; 00054 float getPosition(const char * c) { 00055 char _c[PVNAME_SIZE]; 00056 helper.removeLeadingAndTrailingSpaces(c, _c); 00057 for (size_t i=0; i<cMembers.size(); ++i) { 00058 if(strcmp(cMembers[i].deviceName.c_str(),_c)==0) { 00059 return cMembers[i].devicePosition; 00060 } 00061 } 00062 std::cout << "INPUT: " << _c << " NOT FOUND IN COLLECTION: " << name << std::endl; 00063 std::cout << "HENCE RETURNING -1 FOR POSITION " << std::endl; 00064 return -1; 00065 } 00066 00067 std::vector<std::string> getMembers() { 00068 std::vector<std::string> memberV; memberV.clear(); memberV.reserve(cMembers.size()); 00069 for (size_t i=0; i<cMembers.size(); ++i) { 00070 memberV.push_back(cMembers[i].deviceName); 00071 }; 00072 return memberV; 00073 }; 00074 00075 unsigned int getNCollectionMembers() const {return cMembers.size();}; 00076 unsigned int getNAttribuites() const {return attributes.size();}; 00077 }; 00078 00079 00080 class collectionInGroup { 00081 //friend class loadGroupXMLParser; 00082 public: 00083 collectionInGroup(){}; 00084 virtual ~collectionInGroup(){}; 00085 std::string id; 00086 std::string attrib; 00087 }; 00088 00089 class deviceGroup { 00090 //if HAVE_LIBQTXML 00091 friend class loadGroupXMLParser; 00092 //endif 00093 private: 00094 std::string id; 00095 std::string description; 00096 00097 std::vector<collectionMember> members; 00098 std::vector<std::string> xmlMembers; 00099 std::vector<collectionInGroup> collections; 00100 public: 00101 deviceGroup(){}; 00102 virtual ~deviceGroup(){}; 00103 00104 std::string getName() const {return id;}; 00105 std::string getID() const {return id;}; 00106 00107 std::string getDescription() const {return description;}; 00108 std::vector<collectionMember> getCMembers() const {return members;}; 00109 std::vector<collectionInGroup> getCollections() const {return collections;}; 00110 std::vector<std::string>getXMLMembers() const {return xmlMembers;}; 00111 }; 00112 00113 00114 00115 #endif // DEVICECOLLECTION_H