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);
551 virtual int compare(
const char *name)
const;
558 inline bool equal(
const char *name)
const
559 {
return (compare(name) == 0);};
567 {
return compare(name) == 0;};
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);};
714 {
return (Id == NULL);};
721 void setId(
char *name);
734 {
return (Child.begin() == NULL);};
741 {
return (Parent == NULL);};
760 {relistTail(trunk);};
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;};
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);};
1143 {this->set(typed_value);};
1170 {ObjectStack::push(
object);}
1177 {ObjectStack::push(
object);}
1184 {
return (T *)ObjectStack::pull();}
1191 {
return (T *)ObjectStack::pull();}
1228 {
return (T *)OrderedIndex::get();}
1235 {
return (T *)OrderedIndex::get();}
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);};
1377 inline operator T*()
const
1384 {ptr =
static_cast<T*
>(ptr->getPrev());};
1390 {ptr =
static_cast<T*
>(ptr->getNext());};
1397 {
return static_cast<T*
>(ptr->getNext());};
1405 {
return static_cast<T*
>(ptr->getPrev());};
1411 {ptr =
static_cast<T*
>(ptr->getNext());};
1417 {ptr =
static_cast<T*
>(ptr->getPrev());};
1424 {
return (ptr->getNext() != NULL);};
1431 {
return (ptr->getPrev() != NULL);};
1437 inline operator bool()
const
1438 {
return (ptr != NULL);};
1445 {
return (ptr == NULL);};
1462 template <
typename T,
unsigned P>
1483 inline T &
get(void)
const
1492 {
return static_cast<multimap*
>(MultiMap::next(path));};
1512 inline void set(
const T &reference)
1513 {value = reference;};
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
1609 {
return (node == NULL) ? NULL : node->value;};
1616 {
return (!Child.begin() && value != NULL);};
1643 inline void set(
const T& reference)
1644 {value = reference;};
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));};
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));};
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));};
1810 {
return static_cast<T*
>(NamedObject::skip(idx, NULL, M));};
1818 {
return static_cast<T*
>(NamedObject::skip(idx, current, M));};
1825 {
return NamedObject::count(idx, M);};
1834 {
return NamedObject::index(idx, M);};
1843 {
return NamedObject::sort(NamedObject::index(idx, M));};
1874 {
return static_cast<T*
>(head);};
1882 {
return static_cast<T*
>(tail);};
1891 {
return new T(
this, name);};
1899 {
return static_cast<T*
>(current->
getNext());};
1907 {
return static_cast<T*
>(NamedObject::find(begin(), name));};
1909 inline T *offset(
unsigned offset)
1910 {
return static_cast<T*
>(OrderedIndex::find(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));};
1930 {
return static_cast<T**
>(OrderedIndex::index());};
1939 {
return static_cast<T**
>(NamedObject::sort(index()));};
T getValue(const char *name) const
Get the value pointer of a leaf node of a pointer tree.
LinkedObject ** root(void) const
Return pointer to our linked pointer to use as root node of a chain.
bool equal(const char *name) const
Equal function which calls compare.
T & operator[](unsigned offset)
Retrieve a specific object by position in list.
unsigned limit(void) const
Retrieve key size to use in NamedObject constructors.
void add(T *object)
Add an object onto the object fifo.
T ** sort(void) const
Convert our hash map into an alphabetically sorted linear object pointer array.
void next(void)
Move (iterate) pointer to next member in linked list.
T * pull(void)
Pull an object from the start of the object queue.
A linked object base class with members found by name.
void setPointer(const T pointer)
Set the pointer of a pointer based value tree.
void operator=(const T &typed_value)
Assign embedded value from related type.
void set(const T &reference)
Set the value of a data based value tree.
void operator=(linked_pointer &pointer)
Assign our pointer from another pointer.
T * operator->() const
Return member from typed object our pointer references.
NamedTree * getFirst(void) const
Get first child node in our ordered list of children.
OrderedObject * getNext(void) const
Get next ordered member when iterating.
objfifo()
Create a new object stack.
objqueue()
Create a new object stack.
NamedObject ** root(void) const
Retrieve root of index to use in NamedObject constructors.
bool is_root(void) const
Test if node is root node.
static NamedObject * find(NamedObject *root, const char *name)
Find a named object from a simple list.
void push(T *object)
Push an object to start of queue.
LinkedObject * end(void) const
Return last object in list for iterators.
void operator+=(LinkedList *object)
Insert object behind our object.
T * next(T *current) const
Find next typed object in hash map for iteration.
A common base class for all managed objects.
treemap * leaf(const char *name) const
Search for a leaf node of our node.
named_value(LinkedObject **root, char *name)
Construct embedded named object on a linked list.
Generic smart pointer class.
char * getId(void) const
Get the named id string of this object.
const T getPointer(void) const
Get the pointer of a pointer based value tree.
void operator=(OrderedIndex *index)
Assign our pointer from the start of an ordered index.
treemap * getIndexed(unsigned index) const
Get child member node by index.
A template for ordered index of typed name key mapped objects.
T * begin(void) const
Find first typed object in hash map to iterate.
T * getNext(void) const
Get the next member in linked list.
NamedObject ** root(void)
Return a root node pointer to use in NamedObject constructors.
~multimap()
Destroy a multimap object.
linked_pointer(OrderedIndex *index)
Create a linked pointer to examine an ordered index.
treemap(treemap *parent, char *name)
Construct a child node on an existing tree.
NamedObject * getNext(void) const
Get next effective object when iterating.
linked_pointer(LinkedObject *pointer)
Create a linked pointer assigned from a raw linked object pointer.
void add(OrderedObject *ordered)
Add an object into the ordered index.
const T & getData(void) const
Get the data value of a data based value tree.
A double-linked Object, used for certain kinds of lists.
treemap * path(const char *path) const
Find a subnode by pathname.
T * pull(void)
Pull an object from the object stack.
void enlistHead(OrderedIndex *index)
List our ordered object at start of a linked list on an index.
objstack()
Create a new object stack.
bool operator==(const char *name) const
Comparison operator between our name and a string.
void operator*=(LinkedList *object)
Insert object in list with our object.
A linked object base class for ordered objects.
bool operator!() const
Test if linked list is empty/we are at end of list.
void setPointer(const T pointer)
Set the pointer of a pointer based value tree.
T * find(const char *name)
Find a specific object by name.
T * operator*() const
Return object we currently point to.
T * create(const char *name)
Create a new typed named object with default constructor.
T ** index(void) const
Convert our hash map into a linear object pointer array.
static unsigned count(const LinkedObject *root)
Count the number of linked objects in a list.
Template value class to embed data structure into a linked list.
void push(T *object)
Push an object onto the object stack.
linked_value(LinkedObject **root)
Construct embedded object on a linked list.
static const LinkedObject * nil
Marker for end of linked list.
bool is_attribute(void) const
Test if this node is a leaf node for a tree pointer table.
A smart pointer template for iterating linked lists.
NamedTree * getParent(void) const
Get parent node we are listed as a child on.
Template for typesafe basic object queue container.
void operator=(const T &typed_value)
Assign embedded value from related type.
virtual void retain(void)=0
Method to retain (or increase retention) of an object.
bool is_leaf(void) const
Test if node has children.
T * begin(void)
Return first item in ordered list.
treemap * getLeaf(const char *name) const
Find a direct typed leaf node on our node.
Common base class for all objects that can be formed into a linked list.
linked_value(LinkedObject **root, const T &typed_value)
Assign embedded value from related type and link to list.
treemap(char *name=((void *) 0))
Construct a typed root node for the tree.
bool is_tail(void) const
Test if we are at the end of a list.
objstack(T *list)
Create an object stack from a list of objects.
static void purge(NamedObject **hash, unsigned size)
Purge a hash indexed table of named objects.
void delist(LinkedObject **root)
Locate and remove ourselves from a list of objects.
T & operator[](const char *name) const
Find a typed object derived from NamedObject in the hash map by name.
static void purge(LinkedObject *root)
Release all objects from a list.
bool is_prev(void) const
Test for previous member in double linked list.
void operator--()
Move (iterate) pointer to previous member in double linked list.
virtual void release(void)=0
Method to release (or decrease retention) of an object.
bool operator!() const
Test if this node is unnamed.
Various miscellaneous platform specific headers and defines.
Template value class to embed data structure into a named list.
void set(const T &reference)
Set the value of a data based value tree.
multimap * next(unsigned path)
Return next multimap typed object.
T ** index(void)
Convert our linked list into a linear object pointer array.
Template for embedding a data structure into a reference counted object.
LinkedList * getNext(void) const
Get next node in the list when iterating.
treemap(const treemap &source)
Construct a copy of the treemap object.
OrderedIndex & operator=(const OrderedIndex &object)
Assign ordered index.
treemap * getParent(void) const
Get the typed parent node for our node.
T * pop(void)
Pull (pop) an object from the object stack.
T * end(void)
Return last item in ordered list.
ReusableObject * getNext(void)
Get next effective reusable object when iterating.
void add(T *object)
Add an object to the end of the object queue.
Template for typesafe basic object fifo container.
Embed data objects into a multipap structured memory database.
linked_pointer()
Create a linked pointer not attached to a list.
static named_value find(named_value *first, const char *name)
Find embedded object in chain by name.
void operator++()
Move (iterate) pointer to next member in linked list.
linked_value(OrderedIndex *index, const T &typed_value)
Assign embedded value from related type and add to list.
An index container for maintaining an ordered list of objects.
void relist(NamedTree *trunk=((void *) 0))
Default relist is by tail...
Embed data objects into a tree structured memory database.
LinkedObject * begin(void) const
Return first object in list for iterators.
T * getPrev(void) const
Get the previous member in double linked list.
T * pull(void)
Pull an object from the object stack.
Reusable objects for forming private heaps.
LinkedObject * getNext(void) const
Get next effective object when iterating.
const T & operator*() const
Return typed value of this node by pointer reference.
void add(const char *name, T &object)
Add a typed object derived from NamedObject to the hash map by name.
static T getPointer(treemap *node)
Return value from tree element when value is a pointer.
The named tree class is used to form a tree oriented list of associated objects.
bool is_head(void) const
Test if we are at the head of a list.
bool operator!=(const char *name) const
Comparison operator between our name and a string.
ObjectStack objstack_t
Convenience type for a stack of linked objects.
A double linked list object.
treemap(treemap *parent, char *name, T &reference)
Construct a child node on an existing tree and assign it's value.
linked_value(OrderedIndex *index)
Construct embedded object on an ordered list.
linked_pointer(const linked_pointer &pointer)
Create a copy of an existing linked pointer.
T ** sort(void)
Convert our linked list into an alphabetically sorted linear object pointer array.
LinkedList * getPrev(void) const
Get previous node in the list for reverse iteration.
T &() max(T &o1, T &o2)
Convenience function to return max of two objects.
ObjectQueue objqueue_t
Convenience type for a queue of linked objects.
LinkedObject * operator*() const
Return head object pointer.
treemap * getChild(const char *name) const
Get direct typed child node of our node of specified name.
OrderedIndex objfifo_t
Convenience type for a fifo of linked objects.
LinkedObject * getIndexed(unsigned index) const
Get an indexed member from the ordered index.
void delist(OrderedIndex *index)
Remove our ordered object from an existing index.
linked_pointer(T *pointer)
Create a linked pointer and assign to start of a list.
treemap * find(const char *name) const
Find a subnode from our node by name.
void enlist(LinkedObject **root)
Add our object to an existing linked list through a pointer.
~keymap()
Destroy the hash map by puring the index chains.
T * pop(void)
Pull (pop) an object from the object stack.
A template class for a hash map.
NamedTree * getIndexed(unsigned index) const
Get child by index number.
void operator=(const T &data)
Assign the value of our node.
void operator=(LinkedObject *pointer)
Assign our pointer from a generic linked object pointer.
void push(T *object)
Push an object onto the object fifo.
OrderedIndex * getIndex(void) const
Get the ordered index of our child nodes.
virtual void enlist(OrderedIndex *index)
List our ordered object in default strategy mode.
void operator-=(LinkedList *object)
Insert object in front of our object.
T * next(LinkedObject *current)
Iterate next object in list.
unsigned count(void) const
Count the number of typed objects in our hash map.
T & operator*() const
Return typed value of this node by pointer reference.
virtual void release(void)
Release list, mark as no longer linked.
void add(const char *name, T *object)
Add a typed object derived from NamedObject to the hash map by name.
treemap * getFirst(void) const
Get first child of our node.
A queue of double linked object.
void operator=(const T &data)
Assign the value of our node.
void enlistTail(OrderedIndex *index)
List our ordered object at end of a linked list on an index.
A multipath linked list where membership is managed in multiple lists.
ObjectProtocol * copy(ObjectProtocol *object)
Convenience function to access object copy.
LinkedObject * LinkedIndex
Convenience typedef for root pointers of single linked lists.
bool is_next(void) const
Test for next member in linked list.
static const LinkedObject * inv
Marker for invalid list pointer.
T * pop(void)
Pop an object from the end of the object queue.
void prev(void)
Move (iterate) pointer to previous member in double linked list.
Template for typesafe basic object stack container.
static multimap * find(unsigned path, MultiMap **index, caddr_t key, unsigned size, unsigned keysize=0)
Find multimap key entry.
void operator=(T *pointer)
Assign our typed iterative pointer from a matching typed object.
linked_value()
Create embedded value object unlinked.
void add(T *object)
Add an object onto the object stack.
Class for resource bound memory pools between threads.
A common object base class with auto-pointer support.
multimap()
Construct a multimap node.