Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

Exc_Ruby::Ruby_Reference< T, Data_Wrapper > Struct Template Reference

A smartpointer-like wrapper for Ruby VALUEs. More...

#include <ruby_reference.hpp>

Collaboration diagram for Exc_Ruby::Ruby_Reference< T, Data_Wrapper >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef void(* Ruby_Data_Func )(T *obj)
 A function that takes a T* and returns void.


Public Member Functions

 Ruby_Reference (T *obj, VALUE klass, Ruby_Data_Func mark_func=0, Ruby_Data_Func free_func=Ruby_Delete_Strategy< T >::ruby_delete)
template<typename U>  Ruby_Reference (Value_Holder value, Ruby_Type< U > const &klass, bool include_super=false)
 Ruby_Reference (Value_Holder value, VALUE klass, bool include_super=false)
 Ruby_Reference (Value_Holder value)
 Ruby_Reference (Ruby_Reference const &other)
 Make a copy of a Ruby_Reference.

T & operator * () const
 Return a reference to obj_.

T * operator-> () const
 Return a pointer to obj_.

T * get () const
 Return a pointer to obj_.

VALUE value () const

Protected Attributes

T * obj_
volatile VALUE value_

Detailed Description

template<typename T, class Data_Wrapper = Exception_Safe_Ruby_Data_Wrapper<T>>
struct Exc_Ruby::Ruby_Reference< T, Data_Wrapper >

A smartpointer-like wrapper for Ruby VALUEs.

Note: do not use these objects on the heap; they are only designed ! for use on the stack (the Ruby GC marks references to objects it ! finds on the stack, but not references objects on the heap).


Constructor & Destructor Documentation

template<typename T, class Data_Wrapper = Exception_Safe_Ruby_Data_Wrapper<T>>
Exc_Ruby::Ruby_Reference< T, Data_Wrapper >::Ruby_Reference T *  obj,
VALUE  klass,
Ruby_Data_Func  mark_func = 0,
Ruby_Data_Func  free_func = Ruby_Delete_Strategy< T >::ruby_delete
 

Construct a new Ruby reference, with a type (useful for returning the VALUE to a Ruby function). This is the Exc_Ruby equivalent of Data_Wrap_Struct.

template<typename T, class Data_Wrapper = Exception_Safe_Ruby_Data_Wrapper<T>>
template<typename U>
Exc_Ruby::Ruby_Reference< T, Data_Wrapper >::Ruby_Reference Value_Holder  value,
Ruby_Type< U > const &  klass,
bool  include_super = false
 

Wrap an already allocated Ruby object, checking for correct C++ type and Ruby type. Will throw a C++ exception if the Ruby type is wrong, and will fail to compile if the C++ type is wrong. This is the Exc_Ruby equivalent of Data_Get_Struct.

template<typename T, class Data_Wrapper = Exception_Safe_Ruby_Data_Wrapper<T>>
Exc_Ruby::Ruby_Reference< T, Data_Wrapper >::Ruby_Reference Value_Holder  value,
VALUE  klass,
bool  include_super = false
 

Wrap an already allocated Ruby object, checking for correct Ruby type. Will throw a C++ exception if the Ruby type is wrong.

template<typename T, class Data_Wrapper = Exception_Safe_Ruby_Data_Wrapper<T>>
Exc_Ruby::Ruby_Reference< T, Data_Wrapper >::Ruby_Reference Value_Holder  value  ) 
 

Wrap an already allocated Ruby object. The default data wrapper will check to see if the object is a T_DATA object and throw a C++ exception if this is not the case. Other data wrappers may have different behavior.


Member Function Documentation

template<typename T, class Data_Wrapper = Exception_Safe_Ruby_Data_Wrapper<T>>
VALUE Exc_Ruby::Ruby_Reference< T, Data_Wrapper >::value  )  const [inline]
 

Return a ruby refererence < to the held object


Member Data Documentation

template<typename T, class Data_Wrapper = Exception_Safe_Ruby_Data_Wrapper<T>>
volatile VALUE Exc_Ruby::Ruby_Reference< T, Data_Wrapper >::value_ [protected]
 

Keep the VALUE we wrapped on the stack so the Ruby GC will know we are still using it.


The documentation for this struct was generated from the following file:
Generated on Sat Jan 1 12:02:26 2005 for Exceptional Ruby by doxygen 1.3.6