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

ruby_class.hpp

00001 #ifndef Exc_Ruby__ruby_class__hpp_
00002 #define Exc_Ruby__ruby_class__hpp_
00003 
00004 #include "../detail/Iterator_Definer.hpp"
00005 #include "ruby_module.hpp"
00006 
00007 namespace Exc_Ruby
00008 {
00009 
00010 class Class
00011   : public Module
00012   // TODO: Can't do this without making define_iterator ambiguous
00013   // , public detail::Iterator_Definer<Class>
00014 {
00015 public:
00016   explicit Class(VALUE v);
00017 
00018   // TODO: Move this to creation_funcs.hpp
00019   // (there is no need for the default allocation func to be a template
00020   // function, and it's not portably useful if it is one).
00021   static VALUE default_allocation_func(VALUE klass)
00022   {
00023     return Exc_Ruby::default_allocation_func<int>(klass);
00024   }
00025 
00026   template<typename Constructor_T>
00027   Class & define_constructor(
00028       Constructor_T constructor);
00029 
00030   // define the methods used to allocate and initialize an instance
00031   template<typename Initialize_Func_T>
00032   Class & define_creation_funcs(
00033       RUBY_VALUE_FUNC allocate_func,
00034       Initialize_Func_T initialize_func);
00035 
00036   // disallow creation of an instance from Ruby code
00037   Class & undef_creation_funcs();
00038 
00039   // define an exception handler to be used with every method in this
00040   // class defined hereafter
00041   template<typename Exception_T, typename Functor_T>
00042   Class & add_handler(
00043       Functor_T functor);
00044 
00045   // define an instance method called name and implemented by function
00046   // func
00047   template<typename Func_T>
00048   Class & define_method(
00049       char const * name,
00050       Func_T func);
00051 
00052   // define an singleton method called name and implemented by function
00053   // func
00054   template<typename Func_T>
00055   Class & define_singleton_method(
00056       char const * name,
00057       Func_T func);
00058 
00059   // define a module function called name and implemented by function
00060   // func
00061   template<typename Func_T>
00062   Class & define_module_function(
00063       char const * name,
00064       Func_T func);
00065 };
00066 
00067 Class define_class_under(
00068     Value_Holder module,
00069     char const * name,
00070     Value_Holder superclass = rb_cObject);
00071 
00072 Class define_class(
00073     char const * name,
00074     Value_Holder superclass = rb_cObject);
00075 
00076 } // namespace Exc_Ruby
00077 
00078 #include "ruby_class.ipp"
00079 
00080 #endif // Exc_Ruby__ruby_class__hpp_
00081 

Generated on Sat Jan 1 12:02:19 2005 for Exceptional Ruby by doxygen 1.3.6