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;
206 unsigned count(
void)
const;
222 virtual void lock_index(
void);
228 virtual void unlock_index(
void);
257 {
return LinkedObject::getIndexed((
LinkedObject*)head, index);};
343 {
return static_cast<OrderedObject *
>(LinkedObject::getNext());};
423 virtual void clearId(
void);
507 static unsigned keyindex(
const char *name,
unsigned size);
523 {
return static_cast<NamedObject*
>(LinkedObject::getNext());};
529 inline char *getId(
void)
const
539 virtual int compare(
const char *name)
const;
546 inline bool equal(
const char *name)
const
547 {
return (compare(name) == 0);};
554 inline bool operator==(
const char *name)
const
555 {
return compare(name) == 0;};
562 inline bool operator!=(
const char *name)
const
563 {
return compare(name) != 0;};
649 NamedTree *getChild(
const char *name)
const;
657 NamedTree *getLeaf(
const char *name)
const;
666 {
return static_cast<NamedTree *
>(child.begin());};
681 {
return static_cast<NamedTree *
>(child.getIndexed(index));};
694 inline operator bool()
const
695 {
return (
id != NULL);};
701 inline bool operator!()
const
702 {
return (
id == NULL);};
709 void setId(
char *name);
721 inline bool isLeaf(
void)
const
722 {
return (child.begin() == NULL);};
728 inline bool isRoot(
void)
const
729 {
return (parent == NULL);};
748 {relistTail(trunk);};
813 inline bool isHead(
void)
const
820 inline bool isTail(
void)
const
835 {
return static_cast<LinkedList*
>(LinkedObject::getNext());};
860 {insertTail(
object);};
867 {insertHead(
object);};
915 class __EXPORT ObjectStack
990 virtual bool equal(
unsigned path, caddr_t key,
size_t size)
const;
1008 void enlist(
unsigned path,
MultiMap **index, caddr_t key,
unsigned size,
size_t keysize = 0);
1014 void delist(
unsigned path);
1020 MultiMap *next(
unsigned path)
const;
1029 static unsigned keyindex(caddr_t key,
unsigned max,
size_t size = 0);
1040 static MultiMap *find(
unsigned path,
MultiMap **index, caddr_t key,
unsigned max,
size_t size = 0);
1050 template <
typename T,
class O=NamedObject>
1060 {LinkedObject::enlist(root); O::id = name;};
1066 inline void operator=(
const T& typed_value)
1067 {this->
set(typed_value);};
1076 {
return static_cast<named_value *
>(NamedObject::find(first, name));};
1087 template <
typename T,
class O=OrderedObject>
1101 {LinkedObject::enlist(root);};
1108 {O::enlist(index);};
1116 {LinkedObject::enlist(root); this->
set(typed_value);};
1124 {O::enlist(index); this->
set(typed_value);};
1130 inline void operator=(
const T& typed_value)
1131 {this->
set(typed_value);};
1216 {
return (T *)OrderedIndex::get();}
1223 {
return (T *)OrderedIndex::get();}
1294 {ptr = pointer.ptr;};
1301 {ptr =
static_cast<T*
>(pointer);};
1308 {ptr =
static_cast<T*
>(index->
begin());};
1328 {ptr = pointer.ptr;};
1335 {ptr =
static_cast<T*
>(index->
begin());};
1342 {ptr =
static_cast<T*
>(pointer);};
1348 inline T* operator->()
const
1355 inline T* operator*()
const
1362 inline operator T*()
const
1368 inline void prev(
void)
1369 {ptr =
static_cast<T*
>(ptr->getPrev());};
1374 inline void next(
void)
1375 {ptr =
static_cast<T*
>(ptr->getNext());};
1381 inline T *getNext(
void)
const
1382 {
return static_cast<T*
>(ptr->getNext());};
1389 inline T *getPrev(
void)
const
1390 {
return static_cast<T*
>(ptr->getPrev());};
1395 inline void operator++()
1396 {ptr =
static_cast<T*
>(ptr->getNext());};
1401 inline void operator--()
1402 {ptr =
static_cast<T*
>(ptr->getPrev());};
1408 inline bool isNext(
void)
const
1409 {
return (ptr->getNext() != NULL);};
1415 inline bool isPrev(
void)
const
1416 {
return (ptr->getPrev() != NULL);};
1422 inline operator bool()
const
1423 {
return (ptr != NULL);};
1429 inline bool operator!()
const
1430 {
return (ptr == NULL);};
1447 template <
typename T,
unsigned P>
1468 inline T &
get(void)
const
1477 {
return static_cast<multimap*
>(MultiMap::next(path));};
1483 inline T& operator*()
const
1497 inline void set(
const T &reference)
1498 {value = reference;};
1504 inline void operator=(
const T& data)
1516 inline static multimap *find(
unsigned path,
MultiMap **index, caddr_t key,
unsigned size,
unsigned keysize = 0)
1517 {
return static_cast<multimap*
>(MultiMap::find(path, index, key, size, keysize));};
1537 template <
typename T>
1556 {value = source.value;};
1572 NamedTree(parent, name) {value = reference;};
1578 inline const T&
get(void)
const
1585 inline const T& operator*()
const
1594 {
return (node == NULL) ? NULL : node->value;};
1600 inline bool isAttribute(
void)
const
1601 {
return (!child.begin() && value != NULL);};
1607 inline const T getPointer(
void)
const
1614 inline const T& getData(
void)
const
1628 inline void set(
const T& reference)
1629 {value = reference;};
1635 inline void operator=(
const T& data)
1644 {
return static_cast<treemap*
>(child.getIndexed(index));};
1651 {
return static_cast<treemap*
>(parent);};
1660 {
return static_cast<treemap*
>(NamedTree::getChild(name));};
1669 {
return static_cast<treemap*
>(NamedTree::getLeaf(name));};
1678 inline T getValue(
const char *name)
const
1679 {
return getPointer(getLeaf(name));};
1688 {
return static_cast<treemap*
>(NamedTree::find(name));};
1697 {
return static_cast<treemap*
>(NamedTree::path(path));};
1706 {
return static_cast<treemap*
>(NamedTree::leaf(name));};
1713 {
return static_cast<treemap*
>(NamedTree::getFirst());};
1723 template <
class T,
unsigned M = 177>
1734 {NamedObject::purge(idx, M);};
1747 inline unsigned limit(
void)
const
1755 inline T *
get(
const char *name)
const
1756 {
return static_cast<T*
>(NamedObject::map(idx, name, M));};
1763 inline T& operator[](
const char *name)
const
1764 {
return static_cast<T*
>(NamedObject::map(idx, name, M));};
1771 inline void add(
const char *name, T&
object)
1772 {
object.NamedObject::add(idx, name, M);};
1779 inline void add(
const char *name, T *
object)
1780 {
object->NamedObject::add(idx, name, M);};
1787 inline T *
remove(
const char *name)
1794 inline T *begin(
void)
const
1795 {
return static_cast<T*
>(NamedObject::skip(idx, NULL, M));};
1802 inline T *next(T *current)
const
1803 {
return static_cast<T*
>(NamedObject::skip(idx, current, M));};
1809 inline unsigned count(
void)
const
1810 {
return NamedObject::count(idx, M);};
1818 inline T **index(
void)
const
1819 {
return NamedObject::index(idx, M);};
1827 inline T **sort(
void)
const
1828 {
return NamedObject::sort(NamedObject::index(idx, M));};
1853 inline T *begin(
void)
1854 {
return static_cast<T*
>(head);};
1862 {
return static_cast<T*
>(tail);};
1870 inline T *create(
const char *name)
1871 {
return new T(
this, name);};
1879 {
return static_cast<T*
>(current->
getNext());};
1886 inline T *find(
const char *name)
1887 {
return static_cast<T*
>(NamedObject::find(begin(), name));};
1889 inline T *offset(
unsigned offset)
1890 {
return static_cast<T*
>(OrderedIndex::find(offset));};
1897 inline T& operator[](
unsigned offset)
1898 {
return static_cast<T&
>(OrderedIndex::find(offset));};
1900 inline T& operator[](
const char *name)
1901 {
return static_cast<T&
>(NamedObject::find(begin(), name));};
1909 inline T **index(
void)
1910 {
return static_cast<T**
>(OrderedIndex::index());};
1918 inline T **sort(
void)
1919 {
return static_cast<T**
>(NamedObject::sort(index()));};
1928 {stack.push(
object);}
1936 {stack.push(
object);}
1944 {
return stack.pull();}
1952 {
return stack.pull();}
1976 {
return fifo.
get();}
1984 {
return fifo.
get();}
1992 {queue.
add(
object);}
2000 {queue.
add(
object);}