32 #ifndef _UCOMMON_LINKED_H_
33 #define _UCOMMON_LINKED_H_
35 #ifndef _UCOMMON_CONFIG_H_
39 #ifndef _UCOMMON_OBJECT_H_
62 friend class LinkedRing;
64 friend class ObjectStack;
215 unsigned count(
void)
const;
231 virtual void lock_index(
void);
237 virtual void unlock_index(
void);
294 {
copy(
object);
return *
this;}
439 virtual void clearId(
void);
448 void add(
NamedObject **hash,
char *name,
unsigned size = 1);
455 static void purge(
NamedObject **hash,
unsigned size);
472 static unsigned count(
NamedObject **hash,
unsigned size);
523 static unsigned keyindex(
const char *name,
unsigned size);
555 virtual int compare(
const char *name)
const;
562 inline bool equal(
const char *name)
const
563 {
return (compare(name) == 0);}
571 {
return compare(name) == 0;}
579 {
return compare(name) != 0;}
665 NamedTree *getChild(
const char *name)
const;
673 NamedTree *getLeaf(
const char *name)
const;
710 inline operator bool()
const
711 {
return (Id != NULL);}
718 {
return (Id == NULL);}
725 void setId(
char *name);
738 {
return (Child.
begin() == NULL);}
745 {
return (Parent == NULL);}
876 {insertTail(
object);}
883 {insertHead(
object);}
931 class __EXPORT ObjectStack
965 {
return ObjectStack::pull();}
1006 virtual bool equal(
unsigned path, caddr_t key,
size_t size)
const;
1014 void enlist(
unsigned path,
MultiMap **root);
1024 void enlist(
unsigned path,
MultiMap **index, caddr_t key,
unsigned size,
size_t keysize = 0);
1030 void delist(
unsigned path);
1036 MultiMap *next(
unsigned path)
const;
1045 static unsigned keyindex(caddr_t key,
unsigned max,
size_t size = 0);
1056 static MultiMap *find(
unsigned path,
MultiMap **index, caddr_t key,
unsigned max,
size_t size = 0);
1066 template <
typename T,
class O=NamedObject>
1083 {this->
set(typed_value);}
1103 template <
typename T,
class O=OrderedObject>
1140 {O::enlist(index); this->
set(typed_value);}
1147 {this->
set(typed_value);}
1174 {ObjectStack::push(
object);}
1181 {ObjectStack::push(
object);}
1188 {
return (T *)ObjectStack::pull();}
1195 {
return (T *)ObjectStack::pull();}
1310 {ptr = pointer.ptr;}
1317 {ptr =
static_cast<T*
>(pointer);}
1320 {ptr =
static_cast<T*
>(pointer);}
1327 {ptr =
static_cast<T*
>(index->
begin());}
1347 {ptr = pointer.ptr;}
1354 {ptr =
static_cast<T*
>(index->
begin());}
1361 {ptr =
static_cast<T*
>(pointer);}
1381 inline operator T*()
const
1388 {ptr =
static_cast<T*
>(ptr->getPrev());}
1394 {ptr =
static_cast<T*
>(ptr->getNext());}
1401 {
return static_cast<T*
>(ptr->getNext());}
1409 {
return static_cast<T*
>(ptr->getPrev());}
1415 {ptr =
static_cast<T*
>(ptr->getNext());}
1421 {ptr =
static_cast<T*
>(ptr->getPrev());}
1428 {
return (ptr->getNext() != NULL);}
1435 {
return (ptr->getPrev() != NULL);}
1441 inline operator bool()
const
1442 {
return (ptr != NULL);}
1449 {
return (ptr == NULL);}
1466 template <
typename T,
unsigned P>
1487 inline T &
get(void)
const
1516 inline void set(
const T &reference)
1517 {value = reference;}
1556 template <
typename T>
1575 {value = source.value;};
1591 NamedTree(parent, name) {value = reference;}
1597 inline const T&
get(void)
const
1613 {
return (node == NULL) ? NULL : node->value;}
1620 {
return (!Child.
begin() && value != NULL);}
1647 inline void set(
const T& reference)
1648 {value = reference;}
1670 {
return static_cast<treemap*
>(Parent);}
1742 template <
class T,
unsigned M = 177>
1774 inline T *
get(
const char *name)
const
1790 inline void add(
const char *name, T&
object)
1791 {
object.NamedObject::add(idx, name, M);}
1798 inline void add(
const char *name, T *
object)
1799 {
object->NamedObject::add(idx, name, M);}
1806 inline T *
remove(
const char *name)
1878 {
return static_cast<T*
>(head);}
1886 {
return static_cast<T*
>(tail);}
1895 {
return new T(
this, name);}
1903 {
return static_cast<T*
>(current->
getNext());}
1913 inline T *offset(
unsigned offset)
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.
NamedTree * path(const char *path) const
Find a subnode by a dot separated list of node names.
T ** sort(void)
Convert our linked list into an alphabetically sorted linear object pointer array.
treemap * path(const char *path) const
Find a subnode by pathname.
LinkedObject * get(void)
Get (pull) object off the list.
DLinkedObject * pull(void)
Pull an object from the front of the queue.
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.
static unsigned count(NamedObject **hash, unsigned size)
Count the total named objects in a hash table.
void setPointer(const T pointer)
Set the pointer of a pointer based value tree.
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 * getPrev(void) const
Get the previous member in double linked list.
void operator=(linked_pointer &pointer)
Assign our pointer from another pointer.
NamedTree * getLeaf(const char *name) const
Find a direct leaf node on our node.
static LinkedObject * getIndexed(LinkedObject *root, unsigned index)
Get member by index.
T & operator*() const
Return typed value of this node by pointer reference.
objstack(T *list)
Create an object stack from a list of objects.
A common object base class with auto-pointer support.
~multimap()
Destroy a multimap object.
void release(SharedAccess &object)
Convenience function to unlock shared object through it's protocol.
static NamedObject ** sort(NamedObject **list, size_t count=0)
Sort an array of named objects in alphabetical order.
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.
void add(const char *name, T &object)
Add a typed object derived from NamedObject to the hash map by name.
DLinkedObject * pop(void)
Pop an object from the end of the queue.
bool operator!() const
Test if linked list is empty/we are at end of list.
NamedObject ** root(void)
Return a root node pointer to use in NamedObject constructors.
A double linked list object.
Common namespace for all ucommon objects.
T * operator->() const
Return member from typed object our pointer references.
treemap * getParent(void) const
Get the typed parent node for our node.
static MultiMap * find(unsigned path, MultiMap **index, caddr_t key, unsigned max, size_t size=0)
Find a multikey node.
void add(const char *name, T *object)
Add a typed object derived from NamedObject to the hash map by name.
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.
T * next(LinkedObject *current)
Iterate next object in list.
OrderedIndex * getIndex(void) const
Get the ordered index of our child nodes.
void push(T *object)
Push an object onto the object stack.
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.
void retain(ObjectProtocol *object)
Convenience function to access object retention.
T * pop(void)
Pop an object from the end of the object queue.
LinkedObject * getIndexed(unsigned index) const
Get an indexed member from the ordered index.
NamedTree * find(const char *name) const
Find a child node of our object with the specified name.
LinkedObject ** index(void) const
Return a pointer to the head of the list.
static NamedObject ** index(NamedObject **hash, unsigned size)
Convert a hash index into a linear object pointer array.
bool is_attribute(void) const
Test if this node is a leaf node for a tree pointer table.
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.
void set(const T &object)
Assign our value from a typed data object.
Generic smart pointer class.
linked_value(LinkedObject **root)
Construct embedded object on a linked list.
bool is_prev(void) const
Test for previous member in double linked list.
unsigned limit(void) const
Retrieve key size to use in NamedObject constructors.
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.
void set(const T &reference)
Set the value of a data based value tree.
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.
NamedObject ** root(void) const
Retrieve root of index to use in NamedObject constructors.
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.
bool is_root(void) const
Test if node is root node.
T * find(const char *name)
Find a specific object by name.
static NamedObject * remove(NamedObject **root, const char *name)
Remove a named object from a simple list.
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 push(DLinkedObject *object)
Push an object to the front of the queue.
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.
multimap()
Construct a multimap node.
~keymap()
Destroy the hash map by puring the index chains.
linked_pointer(OrderedIndex *index)
Create a linked pointer to examine an ordered index.
Class for resource bound memory pools between threads.
Template for typesafe basic object stack container.
T ** sort(void) const
Convert our hash map into an alphabetically sorted linear object pointer array.
NamedTree * getParent(void) const
Get parent node we are listed as a child on.
A smart pointer template for iterating linked lists.
const T getPointer(void) const
Get the pointer of a pointer based value tree.
T * begin(void)
Return first item in ordered list.
LinkedList * getPrev(void) const
Get previous node in the list for reverse iteration.
Embed data objects into a multipap structured memory database.
void prev(void)
Move (iterate) pointer to previous member in double linked 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.
MultiMap * next(unsigned path) const
Get next node from single chain.
void setPointer(const T pointer)
Set the pointer of a pointer based value tree.
T ** index(void) const
Convert our hash map into a linear object pointer array.
linked_value()
Create embedded value object unlinked.
static NamedObject * find(NamedObject *root, const char *name)
Find a named object from a simple list.
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.
unsigned count(void) const
Count the number of typed objects in our hash map.
treemap * leaf(const char *name) const
Search for a leaf node of our node.
ReusableObject * getNext(void)
Get next effective reusable object when iterating.
linked_pointer(const linked_pointer &pointer)
Create a copy of an existing linked pointer.
T * create(const char *name)
Create a new typed named object with default constructor.
A double-linked Object, used for certain kinds of lists.
linked_pointer(T *pointer)
Create a linked pointer and assign to start of a list.
T * begin(void) const
Find first typed object in hash map to iterate.
Embed data objects into a tree structured memory database.
treemap(treemap *parent, char *name, T &reference)
Construct a child node on an existing tree and assign it's value.
A template class for a hash map.
Reusable objects for forming private heaps.
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.
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.
LinkedObject * find(unsigned offset) const
Find a specific member in the ordered list.
multimap * next(unsigned path)
Return next multimap typed object.
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 add(DLinkedObject *object)
Add an object to the end of the queue.
T & operator[](unsigned offset)
Retrieve a specific object by position in list.
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.
static NamedObject * map(NamedObject **hash, const char *name, unsigned size)
Find a named object through a hash map table.
Template value class to embed data structure into a linked list.
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.
linked_pointer< T > iterator
Convenience typedef for iterative pointer.
void operator*=(LinkedList *object)
Insert object in list with our object.
Template for typesafe basic object queue container.
NamedTree * getChild(const char *name) const
Find a direct child of our node which matches the specified name.
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.
void operator=(const T &data)
Assign the value of our node.
A queue of double linked object.
T & operator[](const char *name) const
Find a typed object derived from NamedObject in the hash map by name.
OrderedIndex & operator=(const OrderedIndex &object)
Assign ordered index.
linked_pointer< T > iterator
Convenience typedef for iterative pointer.
treemap(const treemap &source)
Construct a copy of the treemap object.
A multipath linked list where membership is managed in multiple lists.
A template for ordered index of typed name key mapped objects.
T * next(T *current) const
Find next typed object in hash map for iteration.
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.
T * pull(void)
Pull an object from the start of the object queue.
NamedTree * leaf(const char *name) const
Find a child leaf node of our object with the specified name.
T * end(void)
Return last item in ordered list.
A linked object base class for ordered objects.
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.
T ** index(void)
Convert our linked list into a linear object pointer array.
treemap(char *name=((void *) 0))
Construct a typed root node for the tree.
static multimap * find(unsigned path, MultiMap **index, caddr_t key, unsigned size, unsigned keysize=0)
Find multimap key entry.
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.
static NamedObject * skip(NamedObject **hash, NamedObject *current, unsigned size)
Iterate through a hash map table.
linked_pointer()
Create a linked pointer not attached to a list.