33 #ifndef _UCOMMON_LINKED_H_ 34 #define _UCOMMON_LINKED_H_ 36 #ifndef _UCOMMON_CONFIG_H_ 40 #ifndef _UCOMMON_OBJECT_H_ 85 virtual void release(
void) __OVERRIDE;
90 virtual void retain(
void) __OVERRIDE;
157 virtual void release(
void) __OVERRIDE;
212 unsigned count(
void)
const;
228 virtual void lock_index(
void);
234 virtual void unlock_index(
void);
420 virtual void clearId(
void);
429 void add(
NamedObject **hash,
char *name,
unsigned size = 1);
436 static void purge(
NamedObject **hash,
unsigned size);
453 static unsigned count(
NamedObject **hash,
unsigned size);
504 static unsigned keyindex(
const char *name,
unsigned size);
538 virtual int compare(
const char *name)
const;
545 inline bool equal(
const char *name)
const {
546 return (compare(name) == 0);
555 return compare(name) == 0;
564 return compare(name) != 0;
651 NamedTree *getChild(
const char *name)
const;
659 NamedTree *getLeaf(
const char *name)
const;
700 inline operator bool()
const {
717 void setId(
char *name);
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) {
1322 return static_cast<treemap*
>(Child.getIndexed(index));
1330 return static_cast<treemap*
>(Parent);
1361 return getPointer(getLeaf(name));
Class for resource bound memory pools between threads.
A common base class for all managed objects.
void setPointer(const T pointer)
Set the pointer of a pointer based value tree.
void enlist(LinkedObject **root)
Add our object to an existing linked list through a pointer.
DLinkedObject * getNext(void) const
Get next node in the list when iterating.
treemap * getLeaf(const char *name) const
Find a direct typed leaf node on our node.
Template value class to embed data structure into a linked list.
DLinkedObject & operator-=(DLinkedObject *object)
Insert object in front of our object.
A linked object base class with members found by name.
char * getId(void) const
Get the named id string of this object.
const T & operator*() const
Return typed value of this node by pointer reference.
Reusable objects for forming private heaps.
NamedTree * leaf(const char *name) const
Find a child leaf node of our object with the specified name.
T copy(const T &src)
Convenience function to copy objects.
void prev(void)
Move (iterate) pointer to previous member in double linked list.
OrderedObject * getNext(void) const
Get next ordered member when iterating.
Embed data objects into a tree structured memory database.
linked_value(LinkedObject **root)
Construct embedded object on a linked list.
treemap * find(const char *name) const
Find a subnode from our node by name.
LinkedObject * end(void) const
Return last object in list for iterators.
A double linked list object.
NamedTree * getChild(const char *name) const
Find a direct child of our node which matches the specified name.
void operator=(const T &data)
Assign the value of our node.
void operator=(T *pointer)
Assign our typed iterative pointer from a matching typed object.
T * getNext(void) const
Get the next member in linked list.
bool is_root(void) const
Test if node is root node.
bool operator==(const char *name) const
Comparison operator between our name and a string.
T * getPrev(void) const
Get the previous member in double linked list.
A common object base class with auto-pointer support.
OrderedIndex * getIndex(void) const
Get the ordered index of our child nodes.
NamedTree * getIndexed(unsigned index) const
Get child by index number.
treemap * leaf(const char *name) const
Search for a leaf node of our node.
static T getPointer(treemap *node)
Return value from tree element when value is a pointer.
DLinkedObject & operator+=(DLinkedObject *object)
Insert object behind our object.
bool is_next(void) const
Test for next member in linked list.
void operator=(OrderedIndex *index)
Assign our pointer from the start of an ordered index.
linked_pointer(LinkedObject *pointer)
Create a linked pointer assigned from a raw linked object pointer.
bool operator!() const
Test if this node is unnamed.
treemap(treemap *parent, char *name, T &reference)
Construct a child node on an existing tree and assign it's value.
LinkedObject * LinkedIndex
Convenience typedef for root pointers of single linked lists.
bool is(T &object)
Convenience function to validate object assuming it is castable to bool.
linked_pointer(T *pointer)
Create a linked pointer and assign to start of a list.
static LinkedObject * getIndexed(LinkedObject *root, unsigned index)
Get member by index.
NamedTree * getParent(void) const
Get parent node we are listed as a child on.
NamedTree * getLeaf(const char *name) const
Find a direct leaf node on our node.
bool operator!=(const char *name) const
Comparison operator between our name and a string.
const T & getData(void) const
Get the data value of a data based value tree.
ReusableObject * getNext(void)
Get next effective reusable object when iterating.
T * operator->() const
Return member from typed object our pointer references.
treemap * getIndexed(unsigned index) const
Get child member node by index.
bool equal(const char *name) const
Equal function which calls compare.
NamedTree * find(const char *name) const
Find a child node of our object with the specified name.
NamedTree * path(const char *path) const
Find a subnode by a dot separated list of node names.
Various miscellaneous platform specific headers and defines.
Common namespace for all ucommon objects.
void operator--()
Move (iterate) pointer to previous member in double linked list.
treemap * getChild(const char *name) const
Get direct typed child node of our node of specified name.
linked_pointer()
Create a linked pointer not attached to a list.
treemap * path(const char *path) const
Find a subnode by pathname.
T * operator*() const
Return object we currently point to.
LinkedObject * getIndexed(unsigned index) const
Get an indexed member from the ordered index.
NamedTree * getFirst(void) const
Get first child node in our ordered list of children.
bool operator!() const
Test if linked list is empty/we are at end of list.
A linked object base class for ordered objects.
OrderedIndex & operator=(const OrderedIndex &object)
Assign ordered index.
LinkedObject ** root(void) const
Return pointer to our linked pointer to use as root node of a chain.
void operator=(linked_pointer &pointer)
Assign our pointer from another pointer.
Common base class for all objects that can be formed into a linked list.
treemap * getParent(void) const
Get the typed parent node for our node.
const T getPointer(void) const
Get the pointer of a pointer based value tree.
bool is_tail(void) const
Test if we are at the end of a list.
bool is_leaf(void) const
Test if node has children.
treemap * getFirst(void) const
Get first child of our node.
treemap(const treemap &source)
Construct a copy of the treemap object.
bool is_attribute(void) const
Test if this node is a leaf node for a tree pointer table.
linked_value(OrderedIndex *index, const T &typed_value)
Assign embedded value from related type and add to list.
DLinkedObject * getPrev(void) const
Get previous node in the list for reverse iteration.
treemap(char *name=((void *) 0))
Construct a typed root node for the tree.
A smart pointer template for iterating linked lists.
DLinkedObject & operator*=(DLinkedObject *object)
Insert object in list with our object.
The named tree class is used to form a tree oriented list of associated objects.
LinkedObject * operator*() const
Return head object pointer.
treemap(treemap *parent, char *name)
Construct a child node on an existing tree.
void next(void)
Move (iterate) pointer to next member in linked list.
linked_pointer(OrderedIndex *index)
Create a linked pointer to examine an ordered index.
linked_value(OrderedIndex *index)
Construct embedded object on an ordered list.
LinkedObject * begin(void) const
Return first object in list for iterators.
void relist(NamedTree *trunk=((void *) 0))
Default relist is by tail...
linked_value()
Create embedded value object unlinked.
linked_pointer(const linked_pointer &pointer)
Create a copy of an existing linked pointer.
Generic smart pointer class.
linked_value & operator=(const T &typed_value)
Assign embedded value from related type.
void operator++()
Move (iterate) pointer to next member in linked list.
LinkedObject * getNext(void) const
Get next effective object when iterating.
NamedObject * getNext(void) const
Get next effective object when iterating.
T getValue(const char *name) const
Get the value pointer of a leaf node of a pointer tree.
linked_value(LinkedObject **root, const T &typed_value)
Assign embedded value from related type and link to list.
bool is_head(void) const
Test if we are at the head of a list.
bool is_prev(void) const
Test for previous member in double linked list.
An index container for maintaining an ordered list of objects.
void operator=(LinkedObject *pointer)
Assign our pointer from a generic linked object pointer.