30 #ifndef _UCOMMON_OBJECT_H_ 31 #define _UCOMMON_OBJECT_H_ 33 #ifndef _UCOMMON_CPR_H_ 37 #ifndef _UCOMMON_GENERICS_H_ 41 #ifndef _UCOMMON_PROTOCOLS_H_ 56 class __EXPORT CountedObject :
public __PROTOCOL ObjectProtocol
59 volatile unsigned count;
73 CountedObject(
const ObjectProtocol &ref);
80 virtual void dealloc(
void);
85 inline void reset(
void) {
95 inline bool is_copied(
void)
const {
103 inline bool is_retained(
void)
const {
111 inline unsigned copied(
void)
const {
118 void retain(
void) __OVERRIDE;
124 void release(
void) __OVERRIDE;
137 class __EXPORT AutoObject
140 ObjectProtocol *object;
148 AutoObject(ObjectProtocol *
object);
155 AutoObject(
const AutoObject &pointer);
170 void set(ObjectProtocol *object);
183 bool operator!()
const;
189 operator bool()
const;
204 class __EXPORT SparseObjects
207 ObjectProtocol **vector;
210 __DELETE_DEFAULTS(SparseObjects);
218 virtual ObjectProtocol *create(
void) = 0;
225 virtual ObjectProtocol *invalid(
void)
const;
232 ObjectProtocol *
get(
unsigned offset);
239 SparseObjects(
unsigned size);
244 virtual ~SparseObjects();
251 unsigned count(
void);
267 __DELETE_DEFAULTS(
sarray);
274 inline sarray(
unsigned size) : SparseObjects(size) {}
282 inline T *
get(
unsigned offset) {
283 return static_cast<T*
>(SparseObjects::get(offset));
293 return reference_cast<T>(
get(offset));
296 inline T& at(
unsigned offset) {
297 return reference_cast<T>(SparseObjects::get(offset));
300 inline const T* operator()(
unsigned offset)
const {
304 inline void operator()(
unsigned offset, T value) {
310 __LOCAL ObjectProtocol *create(
void) __FINAL {
349 return protocol_cast<T*>(object);
357 return reference_cast<T>(object);
365 return protocol_cast<T*>(object);
372 inline T*
get(void)
const {
373 return protocol_cast<T*>(object);
381 AutoObject::set(polypointer_cast<ObjectProtocol*>(typed));
386 AutoObject::set(polypointer_cast<ObjectProtocol*>(from.object));
393 inline operator bool()
const {
394 return object != NULL;
401 return object == NULL;
Typed smart pointer class.
object_pointer(T *object)
Create a pointer with a reference to a heap object.
T * operator*() const
Reference object we are pointing to through pointer indirection.
object_pointer & operator=(T *typed)
Perform assignment operator to existing object.
object_pointer()
Create a pointer with no reference.
T & operator()() const
Reference object we are pointing to through function reference.
bool operator!() const
See if pointer is not set.
T copy(const T &src)
Convenience function to copy objects.
Generate a typed sparse managed object array.
Abstract interfaces and support.
Generic templates for C++.
T * operator->() const
Reference member of object we are pointing to.
Common namespace for all ucommon objects.
sarray(unsigned size)
Generate a sparse typed array of specified size.
T & operator[](unsigned offset)
Array operation to access member object.
T &() max(T &o1, T &o2)
Convenience function to return max of two objects.