Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages

DynObjKey.hh

Go to the documentation of this file.
00001 #ifndef NO_PTR_DYNOBJ_KEY_H
00002 #define NO_PTR_DYNOBJ_KEY_H
00003 
00023 #include "NoPtrFwd.hh" // use
00024 
00025 namespace NoPtr
00026 {
00027     
00028     namespace NoPtrImpl
00029     {
00030 
00031     /*
00032         Key that a class "gives" to DynObj so DynObj can access a 
00033         specific method (that requires the key). This avoids the 
00034         use of friendship in the class itself since it is 
00035         confined here and therefore much diminished. As you can 
00036         see from the private:, only a DynObj can create and copy
00037         the key. Use e.g.: 
00038         \code
00039         class Foo {
00040             void method(DynObjKey);
00041         };
00042         class DynObj {
00043             Foo foo;
00044             void f() { foo.method(DynObjKey()); }
00045         };
00046         \endcode
00047         Note how the DynObj is not given a parameter name in the method
00048         signature, i.e. the optimizer will discard the construction, 
00049         and note how DynObj can just create a temporary. 
00050         */
00051     template <typename ObjType>
00052     class DynObjKey
00053     {
00054         friend class DynObj<ObjType, DefaultDynObjContext>;
00055         friend class DynObj<ObjType, NoPtr::InValueContainer>;
00056         friend class DynObj<ObjType, NoPtr::InValueContainerOpt1>;
00057         friend class DynObj<ObjType, NoPtr::InValueContainerOpt2>;
00058 
00059         private: 
00060             DynObjKey() {}
00061             DynObjKey(const DynObjKey&) {}
00062             DynObjKey& operator=(const DynObjKey&) const {return *this;}
00063     };
00064 
00065     } // implementation namespace
00066     
00067 } // namespace
00068 
00069 #endif // NO_PTR_DYNOBJ_KEY_H
00070 

Generated on Mon Aug 4 18:51:23 2003 for NoPtr C++ Library by doxygen 1.3.2