Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGTypedFunctors1.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2002 by the OpenSG Forum                        *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef _OSGTYPEDFUNCTORS1_H_
00040 #define _OSGTYPEDFUNCTORS1_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044 
00045 //---------------------------------------------------------------------------
00046 //  Includes
00047 //---------------------------------------------------------------------------
00048 
00049 #include <OSGTypedFunctorBase.h>
00050 
00051 OSG_BEGIN_NAMESPACE
00052 
00053 //---------------------------------------------------------------------------
00054 //  Forward References
00055 //---------------------------------------------------------------------------
00056 
00057 //---------------------------------------------------------------------------
00058 //   Types
00059 //---------------------------------------------------------------------------
00060 
00061 //---------------------------------------------------------------------------
00062 //  Class
00063 //---------------------------------------------------------------------------
00064 
00069 template <class RetT, 
00070           class CallArgT> 
00071 struct TypedTraits1
00072 {
00073     typedef typename CallArgT::ObjType ObjType;
00074     typedef typename CallArgT::ArgType ArgType;
00075 
00076     typedef typename
00077         FunctorBuildFuncType1<RetT, CallArgT>::FuncFunctionType FunctionF;
00078 
00079     typedef typename
00080         FunctorBuildFuncType1<RetT, CallArgT>::ObjFuncType      ObjMethodF;
00081 
00082     static void callObjectMethodVoid(UInt8 *pData2, ArgType arg1)
00083     {
00084         ObjMethodF  pFunc = *((ObjMethodF *) pData2);
00085         ObjType    *pObj  = CallArgT::getPtr(arg1); 
00086 
00087         (pObj->*pFunc)();
00088     }
00089 
00090     static RetT callObjectMethod(UInt8 *pData2, ArgType arg1)
00091     {
00092         ObjMethodF  pFunc = *((ObjMethodF *) pData2);
00093         ObjType    *pObj  = CallArgT::getPtr(arg1); 
00094 
00095         return (pObj->*pFunc)();
00096     }
00097 };
00098 
00099 
00100 
00101 
00106 template <class RetT, 
00107           class StoredObjCallArgT,
00108           class ArgsT> 
00109 struct TypedSOTraits1
00110 {
00111     typedef typename StoredObjCallArgT::ObjType  ObjType;
00112 
00113     typedef typename ArgsT::ArgType              ArgType;
00114 
00115     typedef          ObjType                    *SetObjectT;
00116     typedef          ObjType                    *StoredObjectT;
00117 
00118     typedef typename
00119         FunctorBuildObjFuncType1<RetT, 
00120                                  StoredObjCallArgT,
00121                                  ArgsT            >::ObjFuncType ObjMethodF;
00122 
00123 
00124     static void setCalledObject(Char8 *pData, SetObjectT obj)
00125     {
00126         *((ObjType **) pData) = obj;
00127     }
00128 
00129     static void callObjectMethodVoid(UInt8   *pData1, 
00130                                      UInt8   *pData2, 
00131                                      ArgType  arg1  )
00132     {
00133         StoredObjectT pObj  = *((StoredObjectT *) pData1);
00134 
00135         ObjMethodF    pFunc = *((ObjMethodF     *) pData2);
00136         
00137         (pObj->*pFunc)(arg1);
00138     }
00139 
00140     static RetT callObjectMethod(UInt8   *pData1, 
00141                                  UInt8   *pData2, 
00142                                  ArgType  arg1  )
00143     {
00144         StoredObjectT pObj  = *((StoredObjectT *) pData1);
00145 
00146         ObjMethodF    pFunc = *((ObjMethodF     *) pData2);
00147         
00148         return (pObj->*pFunc)(arg1);
00149     }
00150 };
00151 
00152 
00153 
00154 
00155 //---------------------------------------------------------------------------
00156 //  Class
00157 //---------------------------------------------------------------------------
00158 
00163 template <class RetT,
00164           class CallArgT,
00165           class SizeTraitsT = DefaultFunctorSizeTraits>
00166 class TypedFunctor1Base : public TypedFunctorBase<SizeTraitsT>
00167 {
00168     /*==========================  PUBLIC  =================================*/
00169 
00170   public:
00171 
00172     /*---------------------------------------------------------------------*/
00176     typedef typename CallArgT::ArgType CallArgType;
00177 
00179     /*---------------------------------------------------------------------*/
00183     TypedFunctor1Base(void);
00184     TypedFunctor1Base(const TypedFunctor1Base &source);
00185 
00187     /*---------------------------------------------------------------------*/
00191     virtual ~TypedFunctor1Base(void); 
00192 
00194     /*---------------------------------------------------------------------*/
00198     virtual RetT call(CallArgType obj);
00199 
00201     /*---------------------------------------------------------------------*/
00205     void operator =(const TypedFunctor1Base &source);
00206 
00208     /*=========================  PROTECTED  ===============================*/
00209 
00210   protected:
00211 
00212     /*==========================  PRIVATE  ================================*/
00213 
00214   private:
00215 
00216     /*---------------------------------------------------------------------*/
00220     typedef TypedFunctorBase<                 SizeTraitsT> Inherited;
00221 
00222     typedef TypedFunctor1Base<RetT, CallArgT, SizeTraitsT> Self;
00223 
00225 };
00226 
00227 
00228 
00229 //---------------------------------------------------------------------------
00230 //  Class
00231 //---------------------------------------------------------------------------
00232 
00237 template <class CallArgT, class SizeTraitsT = DefaultFunctorSizeTraits>
00238 class TypedVoidFunctor1Base : public TypedFunctorBase<SizeTraitsT>
00239 {
00240     /*==========================  PUBLIC  =================================*/
00241 
00242   public:
00243 
00244     /*---------------------------------------------------------------------*/
00248     typedef typename CallArgT::ArgType CallArgType;
00249 
00251     /*---------------------------------------------------------------------*/
00255     TypedVoidFunctor1Base(void);
00256     TypedVoidFunctor1Base(const TypedVoidFunctor1Base &source);
00257 
00259     /*---------------------------------------------------------------------*/
00263     virtual ~TypedVoidFunctor1Base(void); 
00264 
00266     /*---------------------------------------------------------------------*/
00270     virtual void call(CallArgType obj);
00271 
00273     /*---------------------------------------------------------------------*/
00277     void operator =(const TypedVoidFunctor1Base &source);
00278 
00280     /*=========================  PROTECTED  ===============================*/
00281 
00282   protected:
00283 
00284     /*==========================  PRIVATE  ================================*/
00285 
00286   private:
00287 
00288     /*---------------------------------------------------------------------*/
00292     typedef TypedFunctorBase     <          SizeTraitsT> Inherited;
00293 
00294     typedef TypedVoidFunctor1Base<CallArgT, SizeTraitsT> Self;
00295 
00297 };
00298 
00299 
00300 
00301 
00302 //---------------------------------------------------------------------------
00303 //  Class
00304 //---------------------------------------------------------------------------
00305 
00310 template <class RetT, 
00311           class CallArgT, 
00312           class SizeTraitsT = DefaultFunctorSizeTraits>
00313 class TypedFunctionFunctor1 : 
00314     public TypedFunctionFunctorBase<TypedFunctor1Base<RetT,  
00315                                                       CallArgT,
00316                                                       SizeTraitsT>,
00317                                     TypedTraits1<     RetT, 
00318                                                       CallArgT> >
00319 {
00320     /*==========================  PUBLIC  =================================*/
00321 
00322   public:
00323 
00324     /*---------------------------------------------------------------------*/
00328     typedef typename CallArgT::ArgType CallArgType;
00329 
00331     /*---------------------------------------------------------------------*/
00335     TypedFunctionFunctor1(void);
00336     TypedFunctionFunctor1(const TypedFunctionFunctor1 &source);
00337     
00339     /*---------------------------------------------------------------------*/
00343     virtual ~TypedFunctionFunctor1(void); 
00344 
00346     /*---------------------------------------------------------------------*/
00350     virtual RetT call(CallArgType pObj);
00351 
00353     /*=========================  PROTECTED  ===============================*/
00354 
00355   protected:
00356 
00357     /*==========================  PRIVATE  ================================*/
00358 
00359   private:
00360 
00361     /*---------------------------------------------------------------------*/
00365     typedef 
00366         TypedFunctionFunctorBase <TypedFunctor1Base<RetT, 
00367                                                     CallArgT,
00368                                                     SizeTraitsT>,
00369                                   TypedTraits1     <RetT, 
00370                                                     CallArgT>  > Inherited;
00371 
00372     typedef TypedFunctionFunctor1<RetT, CallArgT, SizeTraitsT  > Self;
00373 
00375     /*---------------------------------------------------------------------*/
00380     void operator =(const TypedFunctionFunctor1 &source);
00381 
00383 };
00384 
00394 //---------------------------------------------------------------------------
00395 //  Class
00396 //---------------------------------------------------------------------------
00397 
00402 template <class CallArgT, 
00403           class SizeTraitsT = DefaultFunctorSizeTraits>
00404 class TypedFunctionVoidFunctor1 : 
00405     public TypedFunctionFunctorBase<TypedVoidFunctor1Base<CallArgT,
00406                                                           SizeTraitsT>,
00407                                     TypedTraits1         <void, 
00408                                                           CallArgT> >
00409 {
00410     /*==========================  PUBLIC  =================================*/
00411 
00412   public:
00413 
00414     /*---------------------------------------------------------------------*/
00418     typedef typename CallArgT::ArgType CallArgType;
00419 
00421     /*---------------------------------------------------------------------*/
00425     TypedFunctionVoidFunctor1(void);
00426     TypedFunctionVoidFunctor1(const TypedFunctionVoidFunctor1 &source);
00427 
00429     /*---------------------------------------------------------------------*/
00433     virtual ~TypedFunctionVoidFunctor1(void); 
00434 
00436     /*---------------------------------------------------------------------*/
00440     virtual void call(CallArgType pObj);
00441 
00443     /*=========================  PROTECTED  ===============================*/
00444 
00445   protected:
00446 
00447     /*==========================  PRIVATE  ================================*/
00448 
00449   private:
00450 
00451     /*---------------------------------------------------------------------*/
00455     typedef 
00456         TypedFunctionFunctorBase <TypedVoidFunctor1Base<CallArgT,
00457                                                         SizeTraitsT>,
00458                                   TypedTraits1         <void, 
00459                                                         CallArgT>  > Inherited;
00460 
00461     typedef 
00462         TypedFunctionVoidFunctor1<CallArgT, SizeTraitsT            > Self;
00463 
00465     /*---------------------------------------------------------------------*/
00470     void operator =(const TypedFunctionVoidFunctor1 &source);
00471 
00473 };
00474 
00483 //---------------------------------------------------------------------------
00484 //  Class
00485 //---------------------------------------------------------------------------
00486 
00492 template <class RetT, 
00493           class CallArgT,
00494           class SizeTraitsT = DefaultFunctorSizeTraits>
00495 class TypedObjectFunctor1 : 
00496     public TypedObjectFunctorBase<TypedFunctor1Base<RetT, 
00497                                                     CallArgT,
00498                                                     SizeTraitsT>,
00499                                    TypedTraits1<    RetT, 
00500                                                     CallArgT> >
00501 {
00502     /*==========================  PUBLIC  =================================*/
00503 
00504   public:
00505 
00506     /*---------------------------------------------------------------------*/
00510     typedef typename CallArgT::ArgType CallArgType;
00511 
00513     /*---------------------------------------------------------------------*/
00517     TypedObjectFunctor1(void);
00518     TypedObjectFunctor1(const TypedObjectFunctor1 &source);
00519     
00521     /*---------------------------------------------------------------------*/
00525     virtual ~TypedObjectFunctor1(void); 
00526 
00528     /*---------------------------------------------------------------------*/
00532     virtual RetT call(CallArgType pObj);
00533 
00535     /*=========================  PROTECTED  ===============================*/
00536 
00537   protected:
00538 
00539     /*==========================  PRIVATE  ================================*/
00540 
00541   private:
00542 
00543     /*---------------------------------------------------------------------*/
00547     typedef TypedTraits1<RetT, CallArgT> TypeTraits;
00548 
00549     typedef 
00550         TypedObjectFunctorBase<
00551             TypedFunctor1Base<RetT, 
00552                               CallArgT,
00553                               SizeTraitsT>,
00554             TypedTraits1<     RetT, 
00555                               CallArgT   > > Inherited;
00556 
00557     typedef 
00558         TypedObjectFunctor1   <RetT, 
00559                                CallArgT    > Self;
00560 
00562     /*---------------------------------------------------------------------*/
00567     void operator =(const TypedObjectFunctor1 &source);
00568 
00570 };
00571 
00580 //---------------------------------------------------------------------------
00581 //  Class
00582 //---------------------------------------------------------------------------
00583 
00588 template <class CallArgT, 
00589           class SizeTraitsT = DefaultFunctorSizeTraits>
00590 class TypedObjectVoidFunctor1 : 
00591     public TypedObjectFunctorBase<TypedVoidFunctor1Base<CallArgT,
00592                                                         SizeTraitsT>,
00593                                   TypedTraits1         <void, 
00594                                                         CallArgT> >
00595 {
00596     /*==========================  PUBLIC  =================================*/
00597 
00598   public:
00599 
00600     /*---------------------------------------------------------------------*/
00604     typedef typename CallArgT::ArgType CallArgType;
00605 
00607     /*---------------------------------------------------------------------*/
00611     TypedObjectVoidFunctor1(void);
00612     TypedObjectVoidFunctor1(const TypedObjectVoidFunctor1 &source);
00613     
00615     /*---------------------------------------------------------------------*/
00619     virtual ~TypedObjectVoidFunctor1(void); 
00620 
00622     /*---------------------------------------------------------------------*/
00626     virtual void call(CallArgType obj);
00627 
00629     /*=========================  PROTECTED  ===============================*/
00630 
00631   protected:
00632 
00633     /*==========================  PRIVATE  ================================*/
00634 
00635   private:
00636 
00637     /*---------------------------------------------------------------------*/
00641     typedef TypedTraits1<void, CallArgT> TypeTraits;
00642 
00643     typedef 
00644         TypedObjectFunctorBase<
00645             TypedVoidFunctor1Base<CallArgT,
00646                                   SizeTraitsT>,
00647             TypedTraits1         <void, 
00648                                   CallArgT> > Inherited;
00649 
00650     typedef 
00651         TypedObjectVoidFunctor1<CallArgT, 
00652                                 SizeTraitsT > Self;
00653 
00655     /*---------------------------------------------------------------------*/
00660     void operator =(const TypedObjectVoidFunctor1 &source);
00661 
00663 };
00664 
00672 //---------------------------------------------------------------------------
00673 //  Class
00674 //---------------------------------------------------------------------------
00675 
00680 template <class RetT, 
00681           class StoredObjectT,
00682           class ArgsT,
00683           class SizeTraitsT = DefaultFunctorSizeTraits>
00684 class TypedStoredObjectFunctor1 : 
00685     public TypedStoredObjectFunctorBase<
00686         TypedFunctor1Base<RetT, 
00687                           ArgsT,
00688                           SizeTraitsT>,
00689         TypedSOTraits1   <RetT, 
00690                           StoredObjectT,
00691                           typename ArgsT::ArgsC> >
00692 {
00693     /*==========================  PUBLIC  =================================*/
00694 
00695   public:
00696 
00697     /*---------------------------------------------------------------------*/
00701     typedef typename ArgsT::ArgType CallArgType;
00702 
00704     /*---------------------------------------------------------------------*/
00708     TypedStoredObjectFunctor1(void);
00709     TypedStoredObjectFunctor1(const TypedStoredObjectFunctor1 &source);
00710     
00712     /*---------------------------------------------------------------------*/
00716     virtual ~TypedStoredObjectFunctor1(void); 
00717 
00719     /*---------------------------------------------------------------------*/
00723     virtual RetT call(CallArgType obj);
00724 
00726     /*=========================  PROTECTED  ===============================*/
00727 
00728   protected:
00729 
00730     /*==========================  PRIVATE  ================================*/
00731 
00732   private:
00733 
00734     /*---------------------------------------------------------------------*/
00738     typedef TypedSOTraits1<RetT, 
00739                            StoredObjectT, 
00740                            typename ArgsT::ArgsC> TypeTraits;
00741 
00742     typedef 
00743         TypedStoredObjectFunctorBase<
00744             TypedFunctor1Base<RetT, 
00745                               ArgsT,
00746                               SizeTraitsT>,
00747             TypedSOTraits1   <RetT, 
00748                               StoredObjectT,
00749                               typename ArgsT::ArgsC> > Inherited;
00750 
00751     typedef 
00752         TypedStoredObjectFunctor1<RetT, 
00753                                   StoredObjectT, 
00754                                   ArgsT, 
00755                                   SizeTraitsT        > Self;
00756 
00758     /*---------------------------------------------------------------------*/
00763     void operator =(const TypedStoredObjectFunctor1 &source);
00764 
00766 };
00767 
00778 //---------------------------------------------------------------------------
00779 //  Class
00780 //---------------------------------------------------------------------------
00781 
00786 template <class StoredObjectT, 
00787           class ArgsT,
00788           class SizeTraitsT  = DefaultFunctorSizeTraits>
00789 class TypedStoredObjectVoidFunctor1 : 
00790     public TypedStoredObjectFunctorBase<TypedVoidFunctor1Base<ArgsT,
00791                                                               SizeTraitsT>,
00792                                         TypedSOTraits1       <void, 
00793                                                               StoredObjectT,
00794                                                      typename ArgsT::ArgsC> >
00795 {
00796     /*==========================  PUBLIC  =================================*/
00797 
00798   public:
00799 
00800     /*---------------------------------------------------------------------*/
00804     typedef typename ArgsT::ArgType CallArgType;
00805 
00807     /*---------------------------------------------------------------------*/
00811     TypedStoredObjectVoidFunctor1(void);
00812     TypedStoredObjectVoidFunctor1(const TypedStoredObjectVoidFunctor1 &source);
00813     
00815     /*---------------------------------------------------------------------*/
00819     virtual ~TypedStoredObjectVoidFunctor1(void); 
00820 
00822     /*---------------------------------------------------------------------*/
00826     virtual void call(CallArgType pObj);
00827 
00829     /*=========================  PROTECTED  ===============================*/
00830 
00831   protected:
00832 
00833     /*==========================  PRIVATE  ================================*/
00834 
00835   private:
00836 
00837     /*---------------------------------------------------------------------*/
00841     typedef TypedSOTraits1<void, 
00842                            StoredObjectT, 
00843                            typename ArgsT::ArgsC> TypeTraits;
00844 
00845     typedef 
00846         TypedStoredObjectFunctorBase<
00847             TypedVoidFunctor1Base<ArgsT,
00848                                   SizeTraitsT>,
00849             TypedSOTraits1       <void, 
00850                                   StoredObjectT,
00851                                   typename ArgsT::ArgsC> > Inherited;
00852 
00853     typedef 
00854     TypedStoredObjectVoidFunctor1<StoredObjectT,
00855                                   ArgsT,
00856                                   SizeTraitsT            > Self;
00857 
00859     /*---------------------------------------------------------------------*/
00864     void operator =(const TypedStoredObjectVoidFunctor1 &source);
00865 
00867 };
00868 
00877 OSG_END_NAMESPACE
00878 
00879 #include <OSGTypedFunctors1.inl>
00880 
00881 #endif /* _OSGTYPEDFUNCTORS1_H_ */
00882 
00883 
00884 
00885 
00886 

Generated on Thu Aug 25 04:11:55 2005 for OpenSG by  doxygen 1.4.3