Objective-C++ Preprocessor  5.0 with ARC & GC
C++ classes to enhance syntax and manage reference counting.
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
OOReference< RTYPE > Class Template Reference

#include <objcpp.h>

Public Member Functions

oo_inline OOReference ()
 
oo_inline OOReference (RTYPE obj)
 oo_inline OOReference( id obj ) { init( obj ); }
 
oo_inline OOReference (CFNullRef obj)
 
oo_inline OOReference (const OOReference &val)
 
oo_inline OOReference (const OOArraySub< RTYPE > &obj)
 
oo_inline OOReference (const OODictionarySub< RTYPE > &obj)
 
oo_inline void * ptr ()
 
oo_inline RTYPE alloc () OO_RETURNS
 
oo_inline void copy (RTYPE val)
 
oo_inline OOReferencedeepcopy (RTYPE val)
 
oo_inline RTYPE get () const OO_RETURNS
 
oo_inline operator RTYPE () const
 
oo_inline RTYPE operator-> () const OO_RETURNS
 
oo_inline OO_AUTOTYPE operator& () const OO_AUTORETURNS
 
oo_inline RTYPE operator* () const OO_RETURNS
 
oo_inline BOOL operator! () const
 
oo_inline OOReferenceoperator<<= (const OOReference &val)
 
oo_inline OOReferenceoperator<<= (id val)
 
oo_inline OOReferenceoperator= (const OOReference &val)
 
oo_inline OOReferenceoperator= (CFNullRef val)
 
oo_inline OOReferenceoperator= (RTYPE val)
 
oo_inline OOReferenceoperator= (int val)
 
oo_inline BOOL operator== (const OOReference &val) const
 
oo_inline BOOL operator!= (const OOReference &val) const
 
oo_inline OOReferenceoperator+= (id val)
 for OOArray<id>
 
oo_inline id operator[] (NSString *key) const
 
oo_inline OOReference operator~ ()
 
oo_inline ~OOReference ()
 

Protected Member Functions

oo_inline void destruct ()
 
oo_inline RTYPE rawset (RTYPE val) OO_RETURNS
 
oo_inline RTYPE set (RTYPE val) OO_RETURNS
 
oo_inline RTYPE set (NSUInteger nilOrCapacity) OO_RETURNS
 
oo_inline OO_AUTOTYPE noalloc () const OO_AUTORETURNS
 
oo_inline OO_AUTOTYPE autoget () const OO_AUTORETURNS
 

Private Member Functions

oo_inline Class classOfReference () const
 
oo_inline RTYPE init (RTYPE val=OOEmpty) OO_RETURNS
 

Private Attributes

RTYPE ref
 

Detailed Description

template<typename RTYPE>
class OOReference< RTYPE >

A class managing basic ref counting references retain/release mechansim for use in instance variables which will not allow constructors or destructors. Use the &operator to get a pointer with "autorelease" scope for use in the rest of your program.

To free the ref either assign nil references the "=" operator or call use the ~ operator which returns a transient ref. Use &~var to free the ref with autorelrease scope.

Usage:

 OOReference<NSString *> immutableRef = "STRING"; // take referrence to a string
 OOReference<NSMutableArray *> mutableRef <<= [NSArray array]; // take mutable copy
 NSMutableArray *ptr = &mutableRef; // get autoreleasing pointer to original object
 NSMutableArray *ptr = *mutableRef; // get pointer to original object
 ~mutableRef; // clear out pointer and remove "release" object.
  • (NSString *)function:(NSString *)str { OOReference<NSString *> ref = str; // take ref
do something
 return &str; // get autoreleasing pointer to return
ref is discarded when object destructed on function exit.
 } 
 

Definition at line 313 of file objcpp.h.

Constructor & Destructor Documentation

template<typename RTYPE>
oo_inline OOReference< RTYPE >::OOReference ( )
inline

Definition at line 385 of file objcpp.h.

template<typename RTYPE>
oo_inline OOReference< RTYPE >::OOReference ( RTYPE  obj)
inline

oo_inline OOReference( id obj ) { init( obj ); }

Definition at line 387 of file objcpp.h.

template<typename RTYPE>
oo_inline OOReference< RTYPE >::OOReference ( CFNullRef  obj)
inline

Definition at line 388 of file objcpp.h.

template<typename RTYPE>
oo_inline OOReference< RTYPE >::OOReference ( const OOReference< RTYPE > &  val)
inline

Definition at line 389 of file objcpp.h.

template<typename RTYPE>
oo_inline OOReference< RTYPE >::OOReference ( const OOArraySub< RTYPE > &  obj)
inline

Definition at line 390 of file objcpp.h.

template<typename RTYPE>
oo_inline OOReference< RTYPE >::OOReference ( const OODictionarySub< RTYPE > &  obj)
inline

Definition at line 391 of file objcpp.h.

template<typename RTYPE>
oo_inline OOReference< RTYPE >::~OOReference ( )
inline

Definition at line 477 of file objcpp.h.

Member Function Documentation

template<typename RTYPE>
oo_inline RTYPE OOReference< RTYPE >::alloc ( )
inline

Definition at line 398 of file objcpp.h.

template<typename RTYPE>
oo_inline OO_AUTOTYPE OOReference< RTYPE >::autoget ( ) const
inlineprotected

Definition at line 379 of file objcpp.h.

template<typename RTYPE>
oo_inline Class OOReference< RTYPE >::classOfReference ( ) const
inlineprivate

Definition at line 317 of file objcpp.h.

template<typename RTYPE>
oo_inline void OOReference< RTYPE >::copy ( RTYPE  val)
inline

Definition at line 414 of file objcpp.h.

template<typename RTYPE>
oo_inline OOReference& OOReference< RTYPE >::deepcopy ( RTYPE  val)
inline

Definition at line 421 of file objcpp.h.

template<typename RTYPE>
oo_inline void OOReference< RTYPE >::destruct ( )
inlineprotected

Definition at line 330 of file objcpp.h.

template<typename RTYPE>
oo_inline RTYPE OOReference< RTYPE >::get ( ) const
inline

Definition at line 431 of file objcpp.h.

template<typename RTYPE>
oo_inline RTYPE OOReference< RTYPE >::init ( RTYPE  val = OOEmpty)
inlineprivate

Definition at line 322 of file objcpp.h.

template<typename RTYPE>
oo_inline OO_AUTOTYPE OOReference< RTYPE >::noalloc ( ) const
inlineprotected

Definition at line 375 of file objcpp.h.

template<typename RTYPE>
oo_inline OOReference< RTYPE >::operator RTYPE ( ) const
inline

Definition at line 436 of file objcpp.h.

template<typename RTYPE>
oo_inline BOOL OOReference< RTYPE >::operator! ( ) const
inline

Definition at line 440 of file objcpp.h.

template<typename RTYPE>
oo_inline BOOL OOReference< RTYPE >::operator!= ( const OOReference< RTYPE > &  val) const
inline

Definition at line 458 of file objcpp.h.

template<typename RTYPE>
oo_inline OO_AUTOTYPE OOReference< RTYPE >::operator& ( ) const
inline

Definition at line 438 of file objcpp.h.

template<typename RTYPE>
oo_inline RTYPE OOReference< RTYPE >::operator* ( ) const
inline

Definition at line 439 of file objcpp.h.

template<typename RTYPE>
oo_inline OOReference& OOReference< RTYPE >::operator+= ( id  val)
inline

for OOArray<id>

Definition at line 461 of file objcpp.h.

template<typename RTYPE>
oo_inline RTYPE OOReference< RTYPE >::operator-> ( ) const
inline

Definition at line 437 of file objcpp.h.

template<typename RTYPE>
oo_inline OOReference& OOReference< RTYPE >::operator<<= ( const OOReference< RTYPE > &  val)
inline

Definition at line 443 of file objcpp.h.

template<typename RTYPE>
oo_inline OOReference& OOReference< RTYPE >::operator<<= ( id  val)
inline

Definition at line 446 of file objcpp.h.

template<typename RTYPE>
oo_inline OOReference& OOReference< RTYPE >::operator= ( const OOReference< RTYPE > &  val)
inline

Definition at line 451 of file objcpp.h.

template<typename RTYPE>
oo_inline OOReference& OOReference< RTYPE >::operator= ( CFNullRef  val)
inline

Definition at line 452 of file objcpp.h.

template<typename RTYPE>
oo_inline OOReference& OOReference< RTYPE >::operator= ( RTYPE  val)
inline

Definition at line 453 of file objcpp.h.

template<typename RTYPE>
oo_inline OOReference& OOReference< RTYPE >::operator= ( int  val)
inline

Definition at line 454 of file objcpp.h.

template<typename RTYPE>
oo_inline BOOL OOReference< RTYPE >::operator== ( const OOReference< RTYPE > &  val) const
inline

Definition at line 457 of file objcpp.h.

template<typename RTYPE>
oo_inline id OOReference< RTYPE >::operator[] ( NSString *  key) const
inline

Definition at line 467 of file objcpp.h.

template<typename RTYPE>
oo_inline OOReference OOReference< RTYPE >::operator~ ( )
inline

Definition at line 469 of file objcpp.h.

template<typename RTYPE>
oo_inline void* OOReference< RTYPE >::ptr ( )
inline

Definition at line 393 of file objcpp.h.

template<typename RTYPE>
oo_inline RTYPE OOReference< RTYPE >::rawset ( RTYPE  val)
inlineprotected

Definition at line 339 of file objcpp.h.

template<typename RTYPE>
oo_inline RTYPE OOReference< RTYPE >::set ( RTYPE  val)
inlineprotected

Definition at line 357 of file objcpp.h.

template<typename RTYPE>
oo_inline RTYPE OOReference< RTYPE >::set ( NSUInteger  nilOrCapacity)
inlineprotected

Definition at line 362 of file objcpp.h.

Member Data Documentation

template<typename RTYPE>
RTYPE OOReference< RTYPE >::ref
private

Definition at line 314 of file objcpp.h.


The documentation for this class was generated from the following file: