33 #ifndef _UCOMMON_LINKED_H_
34 #define _UCOMMON_LINKED_H_
36 #ifndef _UCOMMON_CONFIG_H_
40 #ifndef _UCOMMON_OBJECT_H_
63 friend class LinkedRing;
65 friend class ObjectStack;
91 virtual void release(
void) __OVERRIDE;
96 virtual
void retain(
void) __OVERRIDE;
163 virtual void release(
void) __OVERRIDE;
219 unsigned count(
void)
const;
235 virtual void lock_index(
void);
241 virtual void unlock_index(
void);
450 virtual void clearId(
void);
459 void add(
NamedObject **hash,
char *name,
unsigned size = 1);
466 static void purge(
NamedObject **hash,
unsigned size);
483 static unsigned count(
NamedObject **hash,
unsigned size);
534 static unsigned keyindex(
const char *name,
unsigned size);
568 virtual int compare(
const char *name)
const;
575 inline bool equal(
const char *name)
const {
576 return (compare(name) == 0);
585 return compare(name) == 0;
594 return compare(name) != 0;
681 NamedTree *getChild(
const char *name)
const;
689 NamedTree *getLeaf(
const char *name)
const;
730 inline operator bool()
const {
747 void setId(
char *name);
760 return (Child.
begin() == NULL);
768 return (Parent == NULL);
855 return polypointer_cast<
LinkedList *>(Root->head) ==
this;
863 return polypointer_cast<
LinkedList *>(Root->tail) ==
this;
963 class __EXPORT ObjectStack
997 return ObjectStack::pull();
1039 virtual bool equal(
unsigned path, caddr_t key,
size_t size)
const;
1047 void enlist(
unsigned path,
MultiMap **root);
1057 void enlist(
unsigned path,
MultiMap **index, caddr_t key,
unsigned size,
size_t keysize = 0);
1063 void delist(
unsigned path);
1069 MultiMap *next(
unsigned path)
const;
1078 static unsigned keyindex(caddr_t key,
unsigned max,
size_t size = 0);
1089 static MultiMap *find(
unsigned path,
MultiMap **index, caddr_t key,
unsigned max,
size_t size = 0);
1099 template <
typename T,
class O=NamedObject>
1118 this->
set(typed_value);
1140 template <
typename T,
class O=OrderedObject>
1172 this->
set(typed_value);
1182 this->
set(typed_value);
1190 this->
set(typed_value);
1218 ObjectStack::push(polypointer_cast<LinkedObject*>(
object));
1226 ObjectStack::push(polypointer_cast<LinkedObject*>(
object));
1234 return static_cast<T *
>(ObjectStack::pull());
1242 return static_cast<T *
>(ObjectStack::pull());
1375 ptr =
static_cast<T*
>(pointer);
1379 ptr =
static_cast<T*
>(pointer);
1387 ptr =
static_cast<T*
>(index->
begin());
1418 ptr =
static_cast<T*
>(index->
begin());
1426 ptr =
static_cast<T*
>(pointer);
1449 inline operator T*()
const {
1457 ptr =
static_cast<T*
>(ptr->getPrev());
1464 ptr =
static_cast<T*
>(ptr->getNext());
1472 return static_cast<T*
>(ptr->getNext());
1481 return static_cast<T*
>(ptr->getPrev());
1488 ptr =
static_cast<T*
>(ptr->getNext());
1495 ptr =
static_cast<T*
>(ptr->getPrev());
1503 return (ptr->getNext() != NULL);
1511 return (ptr->getPrev() != NULL);
1518 inline operator bool()
const {
1519 return (ptr != NULL);
1527 return (ptr == NULL);
1530 inline bool is()
const {
1531 return (ptr != NULL);
1551 template <
typename T,
unsigned P>
1572 inline T &
get(void)
const {
1605 inline void set(
const T &reference) {
1648 template <
typename T>
1667 value = source.value;
1691 inline const T&
get(void)
const {
1709 return (node == NULL) ? NULL : node->value;
1717 return (!Child.
begin() && value != NULL);
1748 inline void set(
const T& reference) {
1774 return static_cast<treemap*
>(Parent);
1854 template <
class T,
unsigned M = 177>
1889 inline T *
get(
const char *name)
const {
1907 inline void add(
const char *name, T&
object) {
1908 object.NamedObject::add(idx, name, M);
1916 inline void add(
const char *name, T *
object) {
1917 object->NamedObject::add(idx, name, M);
1925 inline T *
remove(
const char *name) {
2004 return static_cast<T*
>(head);
2013 return static_cast<T*
>(tail);
2023 return new T(
this, name);
2032 return static_cast<T*
>(current->
getNext());
2044 inline T *offset(
unsigned offset) {
treemap(treemap *parent, char *name)
Construct a child node on an existing tree.
NamedTree * getFirst(void) const
Get first child node in our ordered list of children.
bool is_next(void) const
Test for next member in linked list.
treemap * leaf(const char *name) const
Search for a leaf node of our node.
linked_value(LinkedObject **root)
Construct embedded object on a linked list.
const T & operator*() const
Return typed value of this node by pointer reference.
ObjectStack objstack_t
Convenience type for a stack of linked objects.
void release(SharedAccess &object)
Convenience function to unlock shared object through it's protocol.
T ** sort(void)
Convert our linked list into an alphabetically sorted linear object pointer array.
objstack()
Create a new object stack.
static void purge(NamedObject **hash, unsigned size)
Purge a hash indexed table of named objects.
Template for typesafe basic object queue container.
void operator=(OrderedIndex *index)
Assign our pointer from the start of an ordered index.
NamedTree * find(const char *name) const
Find a child node of our object with the specified name.
A queue of double linked object.
NamedTree * path(const char *path) const
Find a subnode by a dot separated list of node names.
void operator+=(LinkedList *object)
Insert object behind our object.
objstack(T *list)
Create an object stack from a list of objects.
Various miscellaneous platform specific headers and defines.
void add(T *object)
Add an object onto the object stack.
const T getPointer(void) const
Get the pointer of a pointer based value tree.
void relist(NamedTree *trunk=((void *) 0))
Default relist is by tail...
void add(T *object)
Add an object onto the object fifo.
multimap * next(unsigned path)
Return next multimap typed object.
LinkedObject * operator*() const
Return head object pointer.
bool operator==(const char *name) const
Comparison operator between our name and a string.
void setPointer(const T pointer)
Set the pointer of a pointer based value tree.
T * pull(void)
Pull an object from the object stack.
Template value class to embed data structure into a linked list.
T * operator*() const
Return object we currently point to.
NamedTree * getLeaf(const char *name) const
Find a direct leaf node on our node.
void add(const char *name, T &object)
Add a typed object derived from NamedObject to the hash map by name.
treemap * find(const char *name) const
Find a subnode from our node by name.
static T getPointer(treemap *node)
Return value from tree element when value is a pointer.
bool is_root(void) const
Test if node is root node.
NamedObject ** root(void)
Return a root node pointer to use in NamedObject constructors.
void push(DLinkedObject *object)
Push an object to the front of the queue.
Common base class for all objects that can be formed into a linked list.
static MultiMap * find(unsigned path, MultiMap **index, caddr_t key, unsigned max, size_t size=0)
Find a multikey node.
bool operator!() const
Test if this node is unnamed.
objqueue()
Create a new object stack.
void add(const char *name, T *object)
Add a typed object derived from NamedObject to the hash map by name.
T * next(LinkedObject *current)
Iterate next object in list.
treemap(treemap *parent, char *name, T &reference)
Construct a child node on an existing tree and assign it's value.
Embed data objects into a multipap structured memory database.
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=(T *pointer)
Assign our typed iterative pointer from a matching typed object.
linked_pointer(LinkedObject *pointer)
Create a linked pointer assigned from a raw linked object pointer.
A linked object base class for ordered objects.
const T & getData(void) const
Get the data value of a data based value tree.
DLinkedObject * pull(void)
Pull an object from the front of the queue.
T * pull(void)
Pull an object from the object stack.
NamedObject * getNext(void) const
Get next effective object when iterating.
treemap(const treemap &source)
Construct a copy of the treemap object.
LinkedObject * end(void) const
Return last object in list for iterators.
Template value class to embed data structure into a named list.
void prev(void)
Move (iterate) pointer to previous member in double linked list.
void set(const T &object)
Assign our value from a typed data object.
ObjectProtocol * copy(ObjectProtocol *object)
Convenience function to access object copy.
void operator=(LinkedObject *pointer)
Assign our pointer from a generic linked object pointer.
bool is_head(void) const
Test if we are at the head of a list.
bool is_leaf(void) const
Test if node has children.
unsigned limit(void) const
Retrieve key size to use in NamedObject constructors.
ObjectQueue objqueue_t
Convenience type for a queue of linked objects.
objfifo()
Create a new object stack.
static NamedObject * map(NamedObject **hash, const char *name, unsigned size)
Find a named object through a hash map table.
NamedTree * getIndexed(unsigned index) const
Get child by index number.
LinkedList * getNext(void) const
Get next node in the list when iterating.
LinkedObject * getNext(void) const
Get next effective object when iterating.
DLinkedObject * pop(void)
Pop an object from the end of the queue.
NamedObject ** root(void) const
Retrieve root of index to use in NamedObject constructors.
LinkedObject * LinkedIndex
Convenience typedef for root pointers of single linked lists.
bool operator!() const
Test if linked list is empty/we are at end of list.
void operator*=(LinkedList *object)
Insert object in list with our object.
T * find(const char *name)
Find a specific object by name.
A common base class for all managed objects.
Embed data objects into a tree structured memory database.
A double linked list object.
LinkedObject * get(void)
Get (pull) object off the list.
~keymap()
Destroy the hash map by puring the index chains.
A common object base class with auto-pointer support.
Reusable objects for forming private heaps.
OrderedIndex * getIndex(void) const
Get the ordered index of our child nodes.
bool is_tail(void) const
Test if we are at the end of a list.
An index container for maintaining an ordered list of objects.
linked_pointer(const linked_pointer &pointer)
Create a copy of an existing linked pointer.
T ** sort(void) const
Convert our hash map into an alphabetically sorted linear object pointer array.
void operator=(const T &typed_value)
Assign embedded value from related type.
treemap * getChild(const char *name) const
Get direct typed child node of our node of specified name.
T * begin(void)
Return first item in ordered list.
treemap(char *name=((void *) 0))
Construct a typed root node for the tree.
bool equal(const char *name) const
Equal function which calls compare.
void add(T *object)
Add an object to the end of the object queue.
MultiMap * next(unsigned path) const
Get next node from single chain.
Generic smart pointer class.
NamedTree * getParent(void) const
Get parent node we are listed as a child on.
T ** index(void) const
Convert our hash map into a linear object pointer array.
bool is_prev(void) const
Test for previous member in double linked list.
multimap()
Construct a multimap node.
static const LinkedObject * nil
Marker for end of linked list.
T & operator*() const
Return typed value of this node by pointer reference.
unsigned count(void) const
Count the number of typed objects in our hash map.
static LinkedObject * getIndexed(LinkedObject *root, unsigned index)
Get member by index.
NamedTree * getChild(const char *name) const
Find a direct child of our node which matches the specified name.
T * create(const char *name)
Create a new typed named object with default constructor.
Common namespace for all ucommon objects.
A double-linked Object, used for certain kinds of lists.
treemap * getParent(void) const
Get the typed parent node for our node.
treemap * path(const char *path) const
Find a subnode by pathname.
void set(const T &reference)
Set the value of a data based value tree.
T * begin(void) const
Find first typed object in hash map to iterate.
OrderedIndex & operator=(const OrderedIndex &object)
Assign ordered index.
static NamedObject * remove(NamedObject **root, const char *name)
Remove a named object from a simple list.
static unsigned count(NamedObject **hash, unsigned size)
Count the total named objects in a hash table.
void retain(ObjectProtocol *object)
Convenience function to access object retention.
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.
A template class for a hash map.
treemap * getFirst(void) const
Get first child of our node.
void next(void)
Move (iterate) pointer to next member in linked list.
NamedTree * leaf(const char *name) const
Find a child leaf node of our object with the specified name.
Class for resource bound memory pools between threads.
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.
OrderedIndex objfifo_t
Convenience type for a fifo of linked objects.
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.
The named tree class is used to form a tree oriented list of associated objects.
void enlist(LinkedObject **root)
Add our object to an existing linked list through a pointer.
A smart pointer template for iterating linked lists.
T * pop(void)
Pull (pop) an object from the object stack.
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 operator=(const T &data)
Assign the value of our node.
LinkedList * getPrev(void) const
Get previous node in the list for reverse iteration.
static NamedObject * skip(NamedObject **hash, NamedObject *current, unsigned size)
Iterate through a hash map table.
void operator--()
Move (iterate) pointer to previous member in double linked list.
void operator-=(LinkedList *object)
Insert object in front of our object.
T & operator[](unsigned offset)
Retrieve a specific object by position in list.
linked_value(OrderedIndex *index, const T &typed_value)
Assign embedded value from related type and add to list.
void push(T *object)
Push an object onto the object fifo.
T * pop(void)
Pop an object from the end of the object queue.
T * pop(void)
Pull (pop) an object from the object stack.
T getValue(const char *name) const
Get the value pointer of a leaf node of a pointer tree.
Template for embedding a data structure into a reference counted object.
static NamedObject * find(NamedObject *root, const char *name)
Find a named object from a simple list.
T * operator->() const
Return member from typed object our pointer references.
linked_pointer< T > iterator
Convenience typedef for iterative pointer.
LinkedObject ** root(void) const
Return pointer to our linked pointer to use as root node of a chain.
Template for typesafe basic object stack container.
linked_pointer()
Create a linked pointer not attached to a list.
static const LinkedObject * inv
Marker for invalid list pointer.
Template for typesafe basic object fifo container.
T &() max(T &o1, T &o2)
Convenience function to return max of two objects.
OrderedObject * getNext(void) const
Get next ordered member when iterating.
void push(T *object)
Push an object onto the object stack.
linked_pointer(T *pointer)
Create a linked pointer and assign to start of a list.
LinkedObject * begin(void) const
Return first object in list for iterators.
T & operator[](const char *name) const
Find a typed object derived from NamedObject in the hash map by name.
LinkedObject * getIndexed(unsigned index) const
Get an indexed member from the ordered index.
T * getNext(void) const
Get the next member in linked list.
void operator=(const T &typed_value)
Assign embedded value from related type.
T * pull(void)
Pull an object from the start of the object queue.
linked_pointer< T > iterator
Convenience typedef for iterative pointer.
A multipath linked list where membership is managed in multiple lists.
linked_pointer(OrderedIndex *index)
Create a linked pointer to examine an ordered index.
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.
LinkedObject ** index(void) const
Return a pointer to the head of the list.
named_value(LinkedObject **root, char *name)
Construct embedded named object on a linked list.
linked_value(LinkedObject **root, const T &typed_value)
Assign embedded value from related type and link to list.
T * end(void)
Return last item in ordered list.
static named_value find(named_value *first, const char *name)
Find embedded object in chain by name.
T ** index(void)
Convert our linked list into a linear object pointer array.
void push(T *object)
Push an object to start of queue.
ReusableObject * getNext(void)
Get next effective reusable object when iterating.
A linked object base class with members found by name.
LinkedObject * find(unsigned offset) const
Find a specific member in the ordered list.
void operator++()
Move (iterate) pointer to next member in linked list.
void set(const T &reference)
Set the value of a data based value tree.
void setPointer(const T pointer)
Set the pointer of a pointer based value tree.
~multimap()
Destroy a multimap object.
char * getId(void) const
Get the named id string of this object.
void operator=(const T &data)
Assign the value of our node.
linked_value()
Create embedded value object unlinked.
void add(DLinkedObject *object)
Add an object to the end of the queue.