Go to the documentation of this file.
33 #ifndef _UCOMMON_LINKED_H_
34 #define _UCOMMON_LINKED_H_
36 #ifndef _UCOMMON_CONFIG_H_
40 #ifndef _UCOMMON_OBJECT_H_
90 virtual void retain(
void) __OVERRIDE;
271 return polystatic_cast<LinkedObject*>(head);
279 return polystatic_cast<LinkedObject*>(tail);
287 return polystatic_cast<LinkedObject*>(head);
504 static unsigned keyindex(
const char *name,
unsigned size);
545 inline bool equal(
const char *name)
const {
546 return (compare(name) == 0);
555 return compare(name) == 0;
564 return compare(name) != 0;
700 inline operator bool()
const {
730 return (Child.
begin() == NULL);
738 return (Parent == NULL);
771 friend class ObjectQueue;
827 return polypointer_cast<DLinkedObject *>(Root->head) ==
this;
835 return polypointer_cast<DLinkedObject *>(Root->tail) ==
this;
908 template <
typename T,
class O = LinkedObject>
958 inline void set(
const T& typed_value) {
971 inline T& operator*() {
975 inline operator T&() {
979 inline void operator()(
const T data) {
1018 ptr =
static_cast<T*
>(
pointer);
1022 ptr =
static_cast<T*
>(
pointer);
1030 ptr =
static_cast<T*
>(index->
begin());
1061 ptr =
static_cast<T*
>(index->
begin());
1069 ptr =
static_cast<T*
>(
pointer);
1092 inline operator T*()
const {
1100 ptr =
static_cast<T*
>(ptr->getPrev());
1107 ptr =
static_cast<T*
>(ptr->getNext());
1115 return static_cast<T*
>(ptr->getNext());
1124 return static_cast<T*
>(ptr->getPrev());
1131 ptr =
static_cast<T*
>(ptr->getNext());
1138 ptr =
static_cast<T*
>(ptr->getPrev());
1146 return (ptr->getNext() != NULL);
1154 return (ptr->getPrev() != NULL);
1161 inline operator bool()
const {
1162 return (ptr != NULL);
1170 return (ptr == NULL);
1173 inline bool is()
const {
1174 return (ptr != NULL);
1204 template <
typename T>
1223 value = source.value;
1247 inline const T&
get(
void)
const {
1265 return (node == NULL) ? NULL : node->value;
1273 return (!Child.
begin() && value != NULL);
1304 inline void set(
const T& reference) {
1330 return static_cast<treemap*
>(Parent);
LinkedObject * getNext(void) const
Get next effective object when iterating.
LinkedObject * operator*() const
Return head object pointer.
linked_pointer()
Create a linked pointer not attached to a list.
linked_value(OrderedIndex *index)
Construct embedded object on an ordered list.
void enlistHead(OrderedIndex *index)
Attach our object to the start of a linked list though an ordered index.
NamedObject * getNext(void) const
Get next effective object when iterating.
static void purge(LinkedObject *root)
Release all objects from a list.
A common base class for all managed objects.
LinkedObject(LinkedObject **root)
Construct base class attached to a chain of objects.
treemap(treemap *parent, char *name, T &reference)
Construct a child node on an existing tree and assign it's value.
static unsigned count(const LinkedObject *root)
Count the number of linked objects in a list.
DLinkedObject * getNext(void) const
Get next node in the list when iterating.
virtual ~OrderedIndex()
Destroy index.
LinkedObject * getIndexed(unsigned index) const
Get an indexed member from the ordered index.
T * getNext(void) const
Get the next member in linked list.
treemap * getChild(const char *name) const
Get direct typed child node of our node of specified name.
linked_pointer(LinkedObject *pointer)
Create a linked pointer assigned from a raw linked object pointer.
OrderedIndex & operator=(const OrderedIndex &object)
Assign ordered index.
A common object base class with auto-pointer support.
const T & getData(void) const
Get the data value of a data based value tree.
void remove(void)
Remove our node from our parent list.
void set(const T &reference)
Set the value of a data based value tree.
virtual ~NamedTree()
Delete node in a tree.
virtual void clearId(void)
The behavior of clearing id's can be overridden if they are not assigned as strdup's from the heap....
NamedTree(NamedTree *parent, char *name)
Create a tree node as a child of an existing node.
DLinkedObject & operator-=(DLinkedObject *object)
Insert object in front of our object.
void enlist(LinkedObject **root)
Add our object to an existing linked list through a pointer.
Common namespace for all ucommon objects.
Various miscellaneous platform specific headers and defines.
virtual void lock_index(void)
Used to synchronize lists managed by multiple threads.
OrderedIndex * getIndex(void) const
Get the ordered index of our child nodes.
ReusableObject * getNext(void)
Get next effective reusable object when iterating.
bool operator!=(const char *name) const
Comparison operator between our name and a string.
T * operator*() const
Return object we currently point to.
DLinkedObject(OrderedIndex *index)
Construct and add our object to an existing double linked list at end.
void operator=(linked_pointer &pointer)
Assign our pointer from another pointer.
OrderedObject * getNext(void) const
Get next ordered member when iterating.
static NamedObject * find(NamedObject *root, const char *name)
Find a named object from a simple list.
treemap(char *name=NULL)
Construct a typed root node for the tree.
virtual ~DLinkedObject()
Delete linked list object.
linked_value & operator=(const T &typed_value)
Assign embedded value from related type.
bool is_tail(void) const
Test if we are at the end of a list.
treemap(const treemap &source)
Construct a copy of the treemap object.
OrderedIndex()
Create and initialize an empty index.
void setPointer(const T pointer)
Set the pointer of a pointer based value tree.
bool operator==(const char *name) const
Comparison operator between our name and a string.
NamedTree * getParent(void) const
Get parent node we are listed as a child on.
NamedTree(const NamedTree &source)
Construct a copy of the tree.
virtual int compare(const char *name) const
Compare the name of our object to see if equal.
~NamedObject()
Destroy named object.
Generic smart pointer class.
T getValue(const char *name) const
Get the value pointer of a leaf node of a pointer tree.
LinkedObject * get(void)
Get (pull) object off the list.
treemap * path(const char *path) const
Find a subnode by pathname.
static void purge(NamedObject **hash, unsigned size)
Purge a hash indexed table of named objects.
NamedTree * getChild(const char *name) const
Find a direct child of our node which matches the specified name.
NamedTree * getFirst(void) const
Get first child node in our ordered list of children.
linked_pointer(OrderedIndex *index)
Create a linked pointer to examine an ordered index.
static LinkedObject * getIndexed(LinkedObject *root, unsigned index)
Get member by index.
bool is_leaf(void) const
Test if node has children.
void enlistTail(OrderedIndex *index)
Attach our object to the end of a linked list though an ordered index.
NamedTree * find(const char *name) const
Find a child node of our object with the specified name.
Class for resource bound memory pools between threads.
void relistTail(NamedTree *trunk)
Add leaf to a trunk, by order.
const T & get(void) const
Return the typed value of this node.
static NamedObject * remove(NamedObject **hash, const char *name, unsigned size)
Remove an object from a hash map table.
static unsigned keyindex(const char *name, unsigned size)
Internal function to convert a name to a hash index number.
virtual void enlist(OrderedIndex *index)
List our ordered object in default strategy mode.
static unsigned count(NamedObject **hash, unsigned size)
Count the total named objects in a hash table.
void operator=(OrderedIndex *index)
Assign our pointer from the start of an ordered index.
A double linked list object.
NamedTree(char *name=NULL)
Create a stand-alone or root tree node, with an optional name.
linked_value(OrderedIndex *index, const T &typed_value)
Assign embedded value from related type and add to list.
virtual void release(void)
Release list, mark as no longer linked.
void purge(void)
Performs object destruction.
void enlistHead(OrderedIndex *index)
List our ordered object at start of a linked list on an index.
bool is_prev(void) const
Test for previous member in double linked list.
NamedObject(OrderedIndex *index, char *name)
Created a named object on an ordered list.
const T & operator*() const
Return typed value of this node by pointer reference.
bool is_head(void) const
Test if we are at the head of a list.
void operator=(LinkedObject *pointer)
Assign our pointer from a generic linked object pointer.
LinkedObject()
Construct base class unattached to anyone.
NamedObject(NamedObject **hash, char *name, unsigned size=1)
Create a named object and add to hash indexed list.
Reusable objects for forming private heaps.
treemap * getFirst(void) const
Get first child of our node.
void enlistTail(OrderedIndex *index)
List our ordered object at end of a linked list on an index.
T * operator->() const
Return member from typed object our pointer references.
treemap * find(const char *name) const
Find a subnode from our node by name.
treemap * getParent(void) const
Get the typed parent node for our node.
static NamedObject * remove(NamedObject **root, const char *name)
Remove a named object from a simple list.
void insertHead(DLinkedObject *object)
Insert object in front of our object.
NamedTree * path(const char *path) const
Find a subnode by a dot separated list of node names.
NamedObject()
Create an empty unnamed cell object.
bool is_member(LinkedObject *list) const
Search to see if we are a member of a specific list.
void delist(OrderedIndex *index)
Remove our ordered object from an existing index.
bool operator!() const
Test if linked list is empty/we are at end of list.
NamedTree * getIndexed(unsigned index) const
Get child by index number.
DLinkedObject * getPrev(void) const
Get previous node in the list for reverse iteration.
unsigned count(void) const
Count of objects this list manages.
void add(OrderedObject *ordered)
Add an object into the ordered index.
void operator=(T *pointer)
Assign our typed iterative pointer from a matching typed object.
DLinkedObject & operator*=(DLinkedObject *object)
Insert object in list with our object.
void relist(NamedTree *trunk=NULL)
Default relist is by tail...
NamedTree * leaf(const char *name) const
Find a child leaf node of our object with the specified name.
LinkedObject * LinkedIndex
Convenience typedef for root pointers of single linked lists.
void prev(void)
Move (iterate) pointer to previous member in double linked list.
LinkedObject * begin(void) const
Return first object in list for iterators.
NamedTree * getLeaf(const char *name) const
Find a direct leaf node on our node.
treemap * leaf(const char *name) const
Search for a leaf node of our node.
void purge(void)
Purge the linked list and then set the index to empty.
virtual void unlock_index(void)
Used to synchronize lists managed by multiple threads.
char * getId(void) const
Get the named id string of this object.
A smart pointer template for iterating linked lists.
void operator*=(OrderedObject *object)
Add object to our list.
linked_pointer(T *pointer)
Create a linked pointer and assign to start of a list.
bool is_root(void) const
Test if node is root node.
static T getPointer(treemap *node)
Return value from tree element when value is a pointer.
void operator--()
Move (iterate) pointer to previous member in double linked list.
The named tree class is used to form a tree oriented list of associated objects.
linked_value()
Create embedded value object unlinked.
LinkedObject ** index(void) const
Return a pointer to the head of the list.
OrderedObject(OrderedIndex *index)
Construct an ordered object aot end of a an index.
LinkedObject ** root(void) const
Return pointer to our linked pointer to use as root node of a chain.
static NamedObject * skip(NamedObject **hash, NamedObject *current, unsigned size)
Iterate through a hash map table.
OrderedObject()
Construct an ordered object unattached.
bool equal(const char *name) const
Equal function which calls compare.
static NamedObject * map(NamedObject **hash, const char *name, unsigned size)
Find a named object through a hash map table.
void operator++()
Move (iterate) pointer to next member in linked list.
DLinkedObject()
Construct an unlinked object.
Embed data objects into a tree structured memory database.
void next(void)
Move (iterate) pointer to next member in linked list.
void enlist(OrderedIndex *index)
Attach our object to a linked list.
linked_value(LinkedObject **root, const T &typed_value)
Assign embedded value from related type and link to list.
LinkedObject * end(void) const
Return last object in list for iterators.
bool operator!() const
Test if this node is unnamed.
A linked object base class for ordered objects.
const T getPointer(void) const
Get the pointer of a pointer based value tree.
LinkedObject * find(unsigned offset) const
Find a specific member in the ordered list.
Common base class for all objects that can be formed into a linked list.
static NamedObject ** sort(NamedObject **list, size_t count=0)
Sort an array of named objects in alphabetical order.
Template value class to embed data structure into a linked list.
virtual void retain(void)
Retain by marking as self referenced list.
void delist(LinkedObject **root)
Locate and remove ourselves from a list of objects.
void operator=(const T &data)
Assign the value of our node.
T * getPrev(void) const
Get the previous member in double linked list.
virtual void insert(DLinkedObject *object)
Insert object, method in derived object.
A linked object base class with members found by name.
linked_pointer(const linked_pointer &pointer)
Create a copy of an existing linked pointer.
void insertTail(DLinkedObject *object)
Insert object behind our object.
linked_value(LinkedObject **root)
Construct embedded object on a linked list.
DLinkedObject & operator+=(DLinkedObject *object)
Insert object behind our object.
treemap * getLeaf(const char *name) const
Find a direct typed leaf node on our node.
static NamedObject ** index(NamedObject **hash, unsigned size)
Convert a hash index into a linear object pointer array.
void delist(void)
Remove our object from the list it is currently part of.
void setId(char *name)
Set or replace the name id of this node.
An index container for maintaining an ordered list of objects.
bool is_next(void) const
Test for next member in linked list.
treemap * getIndexed(unsigned index) const
Get child member node by index.
void reset(void)
Reset linked list to empty without purging.
treemap(treemap *parent, char *name)
Construct a child node on an existing tree.
void add(NamedObject **hash, char *name, unsigned size=1)
Add object to hash indexed list.
T copy(const T &src)
Convenience function to copy objects.
void relistHead(NamedTree *trunk)
Add leaf to a trunk, by reverse order.
bool is_attribute(void) const
Test if this node is a leaf node for a tree pointer table.
virtual void release(void)
Release list, mark as no longer linked.