{
protected:
T ** _array;
int _numOfElements;
int _index;
int _myOwnArray; // this need futher work.
void operator++(){
_element=_index<_numOfElements?_array[++_index]:0;
}
void operator--(){
_element=_index?_array[--_index]:0;
}
void ResetToTop(){_element=_array[_index=0];}
void ResetToEnd(){_element=_array[_index=_numOfElements-1];}
ArrayListMgr(const ArrayListMgr*);
public:
ListMgr *CopyOfSelf(int =0) const {return new ArrayListMgr(this);}
ArrayListMgr(){_array=0; _numOfElements=_index=0; _myOwnArray=0;}
ArrayListMgr(int i);
~ArrayListMgr(){if (_myOwnArray) delete [] _array;}
void AddElement(T*)=0;
T* FindElement(char*)=0;
void DeleteElement(T*)=0;
};
template class LinearListMgr : public ListMgr{
friend class MultiLinearListMgr;
protected:
int i;
T *_head;
T *_tail;
void operator++(){
if (_element && ((_element!=_tail) || (_element=0)))
_element=(T*)_element->Next();
}
void operator--(){
if (_element && ((_element!=_head) || (_element=0)))
_element=(T*)_element->Previous();
}
void ResetToTop(){_element=_head;}
void ResetToEnd();
public:
#if NEED_OBJECTSTORE
static os_typespec *get_os_typespec();
#endif
ListMgr *CopyOfSelf(int =0) const { return new LinearListMgr(this);}
LinearListMgr(){_head=_tail=0;}
LinearListMgr(T * a1, T * a2 =0){
_head=a1;_tail=a2;
}
LinearListMgr(const LinearListMgr * l);
void SetHead(const T& t){_head=(T*)&t;}
void SetTail(const T& t){_tail=(T*)&t;}
T* MyHead(){return _head;}
T* MyTail(){return _tail;}
};
template class NonLinearListMgr :public ListMgr{
protected:
DoubleLinkListElement *_head, *_current;
int _myOwnList; // set to 1 if the double link list should
// be destroyed by the current manager.
void operator++(){
if (_current){
_current=(DoubleLinkListElement*)_current->Next();
if (_current) _element=_current->_element;
else _element=0;
}
}
void operator--(){
if (_current && _current!=_head){
_current=_current->_previous;
_element=_current->_element;
}
}
void ResetToTop(){
if (_head) {
_current=_head;
_element=_current->_element;
}
}
void ResetToEnd();
public:
#if NEED_OBJECTSTORE
static os_typespec *get_os_typespec();
#endif
ListMgr *CopyOfSelf(int =0) const { return new NonLinearListMgr(this);}
NonLinearListMgr(){_head=_current=0; _myOwnList=1; }
NonLinearListMgr(const NonLinearListMgr *lp);
~NonLinearListMgr();
void AddElement(T* t);
T* FindElement(char* name);
void DeleteElement(T* t);
LinkListElement * MyList(){return _head;}
};
template class DLlistElementOfLinearListMgr {
// Element of double link list of LinearListMgr.
public:
LinearListMgr *_elements;
DLlistElementOfLinearListMgr *revious;
DLlistElementOfLinearListMgr *_next;
DLlistElementOfLinearListMgr(){revious=_next=0;}
#if NEED_OBJECTSTORE
static os_typespec *get_os_typespec();
#endif
};
template class MultiLinearListMgr : public ListMgr {
protected:
DLlistElementOfLinearListMgr *_lists, *_currentList;
void operator++(){
if (_currentList){
++(*(_currentList->_elements));
_element=&(*(_currentList->_elements))();
if ((!_element) && (_currentList=_currentList->_next)){
_currentList->_elements->ResetToTop();
_element=&(*(_currentList->_elements))();
}
}
else ResetToTop();
}
void operator--(){
if (_currentList){
--(*(_currentList->_elements));
_element=&(*(_currentList->_elements))();
if ((!_element) &&
(_currentList=_currentList->revious)){
_currentList->_elements->ResetToEnd();
_element=&(*(_currentList->_elements))();
}
}
else ResetToEnd();
}
void ResetToTop(){
if (_lists){
_currentList=_lists;
_currentList->_elements->ResetToTop();
_element=&(*(_currentList->_elements))();
}
}
void ResetToEnd();
public:
#if NEED_OBJECTSTORE
static os_typespec *get_os_typespec();
#endif
ListMgr * CopyOfSelf(int =0) const {return new MultiLinearListMgr(this);}
MultiLinearListMgr(){_lists=_currentList=0;}
MultiLinearListMgr(const MultiLinearListMgr *l);
~MultiLinearListMgr();
virtual void AddLinearListMgr(LinearListMgr* l);
void Merge(MultiLinearListMgr*);
void AddElement(T*){}
T* FindElement(char*){return 0;}
void DeleteElement(T*){}
};
#if NEED_OBJECTSTORE
class DbsMgr;
enum c_sz { COLL_SIZE=2100 };
template class CollectionListMgr : public ListMgr{
protected:
os_Collection *_coll;
os_Cursor *_cursor;
void operator++();
void operator--();
void ResetToTop();
void ResetToEnd();
CollectionListMgr(os_Collection *coll);
public:
static os_typespec *get_os_typespec();
ListMgr *CopyOfSelf(int order=0) const { return new CollectionListMgr(this,order);}
ListMgr *DeepCopyOfSelf();
CollectionListMgr(int behavior=0,int expected_size=COLL_SIZE);
CollectionListMgr(const CollectionListMgr *lp,int order=0);
~CollectionListMgr();
void AddElement(T* t);
T* FindElement(char* name);
int MyCardinality() const { if (_coll) return _coll->cardinality();
else return 0;
}
void AddIndex(char *ix_path, int opt=os_index_path::ordered);
CollectionListMgr *Query(char *query_str);
T *QueryPick(char *query_str);
T *QueryPick(const os_bound_query &bnd_qry);
CollectionListMgr *Query(const os_bound_query &bnd_qry);
void DeleteElement(T* t);
};
#endif
Back to The PDBLib