VR-Forces 4.0.4 Class Documentation
include/geometry/ssFunctor.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 2005 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 *********************************************************************/
00005 /*********************************************************************
00006 ** $RCSfile: ssFunctor.h,v $ $Revision: 1.1 $ $State: Exp $
00007 *********************************************************************/
00008 #ifndef ssFunctor_H_
00009 #define ssFunctor_H_
00010 
00011 #include "geometry/spatialSubdivision.h"
00012 
00013 //
00014 // This is the base class for spatial subdivision related functors. 
00015 // For efficiency and flexibility, the spatial subdivision intersectors use 
00016 // functors as a parameter to some of their intersection functions.  The functors
00017 // are applied to the intersection results, with the intersector determining the
00018 // specific parameters.
00019 // For more information on the usage of the functors, see the specific 
00020 // spatial subdivision intersectors.
00021 
00022 // IMPORTANT:
00023 // The functors are different from standard library functors in two important ways.
00024 // 1) The SS Functors return value expresses whether or not the functors are done
00025 // processing, @b not whether or not an error occurred.  When an intersector is
00026 // applying the functor to the intersection results, a return value of true
00027 // means that the intersector no longer needs to apply the functor.
00028 // The benefit of this is efficiency - functors that have found what they are looking
00029 // for (or whatever else signals done processing) do have to be applied anymore.
00030 // The drawback of this approach is a slightly tighter coupling between the 
00031 // ss intersectors and the functors (the functors know more about the intersectors
00032 // then they should.
00033 // 
00034 // With regards to error handling, either the functors should be designed to 
00035 // not have errors (other than a few exceptional cases, such as out of memory),
00036 // or some other error handling mechanism should be used (exceptions, internal 
00037 // error state, etc.) 
00038 //
00039 // 2) The functors expect themselves to be passed by @ reference.  This is very 
00040 // important as it is different from the standard practice of passing functors 
00041 // by value.  This is done because of the need for some functors to maintain complicated
00042 // internal state, which makes copying inefficient and lifecycle management of hte
00043 // internal state, such as by using pointers, complicated.
00044 // 
00045 template <typename S, typename T>
00046 class DtSsFunctor
00047 {
00048 public:
00049    DtSsFunctor();
00050    virtual ~DtSsFunctor();
00051 
00052    // @returns Always returns true as this functor does nothing.
00053    virtual bool operator()(S& item, T& item2);
00054 
00055 private:
00056    // not implemented
00057    DtSsFunctor(const DtSsFunctor& original);
00058    DtSsFunctor& operator=(const DtSsFunctor& original);
00059 
00060 };
00061 
00062 //------------------------------------------------------
00063 //  INLINE METHODS
00064 //------------------------------------------------------
00065 template <typename S, typename T>
00066 DtSsFunctor<S, T>::DtSsFunctor()
00067 {
00068 }
00069 
00070 template <typename S, typename T>
00071 DtSsFunctor<S, T>::~DtSsFunctor()
00072 {
00073 }
00074 
00075 template <typename S, typename T>
00076 bool DtSsFunctor<S, T>::operator()(S& item, T& item2) 
00077 { 
00078    return true;
00079 };
00080 
00081 
00082 #endif
00083 
00084 

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)