00001 // $Header: /local/reps/Gaudi/GaudiKernel/GaudiKernel/DataStoreItem.h,v 1.2 2000/12/13 12:57:12 mato Exp $ 00002 #ifndef GAUDIKERNEL_DATASTOREITEM_H 00003 #define GAUDIKERNEL_DATASTOREITEM_H 00004 00005 // STL include files 00006 #include <string> 00007 00018 class DataStoreItem { 00019 protected: 00021 std::string m_path; 00023 int m_depth; 00024 public: 00026 DataStoreItem (const std::string& path, int depth = 1) 00027 : m_path(path), m_depth(depth) { 00028 analyse(); 00029 } 00031 DataStoreItem (const DataStoreItem& item) 00032 : m_path(item.m_path), m_depth(item.m_depth) { 00033 analyse(); 00034 } 00036 virtual ~DataStoreItem() { 00037 } 00039 bool operator==(const DataStoreItem& cmp) const { 00040 return m_path == cmp.path() && m_depth == cmp.depth(); 00041 } 00043 bool operator!=(const DataStoreItem& cmp) const { 00044 return ! ( m_path == cmp.path() && m_depth == cmp.depth() ); 00045 } 00047 DataStoreItem& operator=(const DataStoreItem& cmp) { 00048 m_path = cmp.path(); 00049 m_depth = cmp.depth(); 00050 analyse(); 00051 return *this; 00052 } 00054 void analyse() { 00055 int len = m_path.length()-1; 00056 if ( m_path[len] == '*' ) { 00057 m_depth = 99999999; 00058 (m_path[len-1] == '/') ? m_path.erase(len-1, 2) : m_path.erase(len, 1); 00059 } 00060 else if ( m_path[len] == '+' ) { 00061 (m_path[len-1] == '/') ? m_path.erase(len-1, 2) : m_path.erase(len, 1); 00062 m_depth = 2; 00063 } 00064 } 00066 const std::string& path() const { 00067 return m_path; 00068 } 00070 int depth() const { 00071 return m_depth; 00072 } 00073 }; 00074 #endif // GAUDIKERNEL_DATASTOREITEM_H