32 #ifndef _UCOMMON_LINKED_H_
33 #define _UCOMMON_LINKED_H_
35 #ifndef _UCOMMON_CONFIG_H_
39 #ifndef _UCOMMON_OBJECT_H_
58 friend class LinkedRing;
60 friend class ObjectStack;
211 unsigned count(
void)
const;
227 virtual void lock_index(
void);
233 virtual void unlock_index(
void);
262 {
return LinkedObject::getIndexed((
LinkedObject*)head, index);};
290 {
copy(
object);
return *
this;}
435 virtual void clearId(
void);
444 void add(
NamedObject **hash,
char *name,
unsigned size = 1);
519 static unsigned keyindex(
const char *name,
unsigned size);
541 inline char *getId(
void)
const
551 virtual int compare(
const char *name)
const;
558 inline bool equal(
const char *name)
const
559 {
return (compare(name) == 0);};
566 inline bool operator==(
const char *name)
const
567 {
return compare(name) == 0;};
574 inline bool operator!=(
const char *name)
const
575 {
return compare(name) != 0;};
661 NamedTree *getChild(
const char *name)
const;
669 NamedTree *getLeaf(
const char *name)
const;
678 {
return static_cast<NamedTree *
>(Child.begin());};
693 {
return static_cast<NamedTree *
>(Child.getIndexed(index));};
706 inline operator bool()
const
707 {
return (Id != NULL);};
713 inline bool operator!()
const
714 {
return (Id == NULL);};
721 void setId(
char *name);
733 inline bool is_leaf(
void)
const
734 {
return (Child.begin() == NULL);};
740 inline bool is_root(
void)
const
741 {
return (Parent == NULL);};
760 {relistTail(trunk);};
825 inline bool is_head(
void)
const
832 inline bool is_tail(
void)
const
872 {insertTail(
object);};
879 {insertHead(
object);};
927 class __EXPORT ObjectStack
961 {
return ObjectStack::pull();};
1002 virtual bool equal(
unsigned path, caddr_t key,
size_t size)
const;
1020 void enlist(
unsigned path,
MultiMap **index, caddr_t key,
unsigned size,
size_t keysize = 0);
1026 void delist(
unsigned path);
1032 MultiMap *next(
unsigned path)
const;
1041 static unsigned keyindex(caddr_t key,
unsigned max,
size_t size = 0);
1052 static MultiMap *find(
unsigned path,
MultiMap **index, caddr_t key,
unsigned max,
size_t size = 0);
1062 template <
typename T,
class O=NamedObject>
1072 {LinkedObject::enlist(root); O::id = name;};
1078 inline void operator=(
const T& typed_value)
1079 {this->
set(typed_value);};
1088 {
return static_cast<named_value *
>(NamedObject::find(first, name));};
1099 template <
typename T,
class O=OrderedObject>
1113 {LinkedObject::enlist(root);};
1120 {O::enlist(index);};
1128 {LinkedObject::enlist(root); this->
set(typed_value);};
1136 {O::enlist(index); this->
set(typed_value);};
1142 inline void operator=(
const T& typed_value)
1143 {this->
set(typed_value);};
1169 inline void push(T *
object)
1170 {ObjectStack::push(
object);}
1176 inline void add(T *
object)
1177 {ObjectStack::push(
object);}
1183 inline T *pull(
void)
1184 {
return (T *)ObjectStack::pull();}
1191 {
return (T *)ObjectStack::pull();}
1213 inline void push(T *
object)
1220 inline void add(T *
object)
1227 inline T *pull(
void)
1228 {
return (T *)OrderedIndex::get();}
1235 {
return (T *)OrderedIndex::get();}
1256 inline void push(T *
object)
1263 inline void add(T *
object)
1270 inline T *pull(
void)
1271 {
return (T *)ObjectQueue::pull();}
1278 {
return (T *)ObjectQueue::pop();}
1306 {ptr = pointer.ptr;};
1313 {ptr =
static_cast<T*
>(pointer);};
1316 {ptr =
static_cast<T*
>(pointer);};
1323 {ptr =
static_cast<T*
>(index->
begin());};
1343 {ptr = pointer.ptr;};
1350 {ptr =
static_cast<T*
>(index->
begin());};
1357 {ptr =
static_cast<T*
>(pointer);};
1363 inline T* operator->()
const
1370 inline T* operator*()
const
1377 inline operator T*()
const
1383 inline void prev(
void)
1384 {ptr =
static_cast<T*
>(ptr->getPrev());};
1389 inline void next(
void)
1390 {ptr =
static_cast<T*
>(ptr->getNext());};
1396 inline T *getNext(
void)
const
1397 {
return static_cast<T*
>(ptr->getNext());};
1404 inline T *getPrev(
void)
const
1405 {
return static_cast<T*
>(ptr->getPrev());};
1410 inline void operator++()
1411 {ptr =
static_cast<T*
>(ptr->getNext());};
1416 inline void operator--()
1417 {ptr =
static_cast<T*
>(ptr->getPrev());};
1423 inline bool is_next(
void)
const
1424 {
return (ptr->getNext() != NULL);};
1430 inline bool is_prev(
void)
const
1431 {
return (ptr->getPrev() != NULL);};
1437 inline operator bool()
const
1438 {
return (ptr != NULL);};
1444 inline bool operator!()
const
1445 {
return (ptr == NULL);};
1462 template <
typename T,
unsigned P>
1483 inline T &
get(void)
const
1492 {
return static_cast<multimap*
>(MultiMap::next(path));};
1498 inline T& operator*()
const
1512 inline void set(
const T &reference)
1513 {value = reference;};
1519 inline void operator=(
const T& data)
1531 inline static multimap *find(
unsigned path,
MultiMap **index, caddr_t key,
unsigned size,
unsigned keysize = 0)
1532 {
return static_cast<multimap*
>(MultiMap::find(path, index, key, size, keysize));};
1552 template <
typename T>
1571 {value = source.value;};
1587 NamedTree(parent, name) {value = reference;};
1593 inline const T&
get(void)
const
1600 inline const T& operator*()
const
1609 {
return (node == NULL) ? NULL : node->value;};
1615 inline bool is_attribute(
void)
const
1616 {
return (!Child.begin() && value != NULL);};
1622 inline const T getPointer(
void)
const
1629 inline const T& getData(
void)
const
1643 inline void set(
const T& reference)
1644 {value = reference;};
1650 inline void operator=(
const T& data)
1659 {
return static_cast<treemap*
>(Child.getIndexed(index));};
1666 {
return static_cast<treemap*
>(Parent);};
1675 {
return static_cast<treemap*
>(NamedTree::getChild(name));};
1684 {
return static_cast<treemap*
>(NamedTree::getLeaf(name));};
1693 inline T getValue(
const char *name)
const
1694 {
return getPointer(getLeaf(name));};
1703 {
return static_cast<treemap*
>(NamedTree::find(name));};
1712 {
return static_cast<treemap*
>(NamedTree::path(path));};
1721 {
return static_cast<treemap*
>(NamedTree::leaf(name));};
1728 {
return static_cast<treemap*
>(NamedTree::getFirst());};
1738 template <
class T,
unsigned M = 177>
1749 {NamedObject::purge(idx, M);};
1770 inline T *
get(
const char *name)
const
1771 {
return static_cast<T*
>(NamedObject::map(idx, name, M));};
1778 inline T& operator[](
const char *name)
const
1779 {
return static_cast<T*
>(NamedObject::map(idx, name, M));};
1786 inline void add(
const char *name, T&
object)
1787 {
object.NamedObject::add(idx, name, M);};
1794 inline void add(
const char *name, T *
object)
1795 {
object->NamedObject::add(idx, name, M);};
1802 inline T *
remove(
const char *name)
1803 {
return static_cast<T*
>(NamedObject::remove(idx, name, M));};
1809 inline T *begin(
void)
const
1810 {
return static_cast<T*
>(NamedObject::skip(idx, NULL, M));};
1817 inline T *next(T *current)
const
1818 {
return static_cast<T*
>(NamedObject::skip(idx, current, M));};
1824 inline unsigned count(
void)
const
1825 {
return NamedObject::count(idx, M);};
1833 inline T **index(
void)
const
1834 {
return NamedObject::index(idx, M);};
1842 inline T **sort(
void)
const
1843 {
return NamedObject::sort(NamedObject::index(idx, M));};
1873 inline T *begin(
void)
1874 {
return static_cast<T*
>(head);};
1882 {
return static_cast<T*
>(tail);};
1890 inline T *create(
const char *name)
1891 {
return new T(
this, name);};
1899 {
return static_cast<T*
>(current->
getNext());};
1906 inline T *find(
const char *name)
1907 {
return static_cast<T*
>(NamedObject::find(begin(), name));};
1909 inline T *offset(
unsigned offset)
1910 {
return static_cast<T*
>(OrderedIndex::find(offset));};
1917 inline T& operator[](
unsigned offset)
1918 {
return static_cast<T&
>(OrderedIndex::find(offset));};
1920 inline T& operator[](
const char *name)
1921 {
return static_cast<T&
>(NamedObject::find(begin(), name));};
1929 inline T **index(
void)
1930 {
return static_cast<T**
>(OrderedIndex::index());};
1938 inline T **sort(
void)
1939 {
return static_cast<T**
>(NamedObject::sort(index()));};