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