// MyClassName - class declaration (This file should be called "MyClassName.h") // // Copyright boilerplate stuff // // Replace MyClassName with class name #if !defined(LOCK_MyClassName) // This file cannot be included recursively #define LOCK_MyClassName #if defined(DEFINITION) #define DEFINITION_MyClassName #endif #if defined(PRIVATE) #if defined(PROTECTED) #error PROTECTED defined in addition to PRIVATE #elif defined(PUBLIC) #error PUBLIC defined in addition to PRIVATE #endif #define PRIVATE_MyClassName #undef PRIVATE #elif defined(PROTECTED) #if defined(PUBLIC) #error PUBLIC defined in addition to PROTECTED #endif #define PROTECTED_MyClassName #undef PROTECTED #elif defined(PUBLIC) #define PUBLIC_MyClassName #undef PUBLIC #elif !defined(DEFINITION) // Default must be from a c++ file #define DEFINITION #if defined(CPP) // From THE c++ file #undef CPP #define CPP_MyClassName // Mark that this template was called from c++ file #define PRIVATE_MyClassName #endif #endif #if defined(DEFINITION) #if !defined(DEFINED_MyClassName) // Defining this class #define DEFINED_MyClassName // PREVENT REENTRY PERMANENTLY #ifndef SEEN_PCH // Only useful if using precompiled headers #error include 'anyPCH.h' before including 'MyClassName.hpp' #endif // ========================================================================== // | CLib - Use #include | // -------------------------------------------------------------------------- // ========================================================================== // | Libraries - Use #include "Library.h" | // -------------------------------------------------------------------------- // ========================================================================== // | Temp1ates - Use #include "Temp1ate.hxx" | // -------------------------------------------------------------------------- // ========================================================================== // | Base classes - Include definitions of base classes | // | (not in library) e.g. #include "Baseclass.hpp" | // -------------------------------------------------------------------------- // ========================================================================== // | Member objects - Include definitions of classes used by member objects | // | (not in library) e.g. #include "MemberObject.hpp" | // -------------------------------------------------------------------------- // ========================================================================== // | References - Declare class references (including any definitions of| // | (not in library) types & used classes) e.g. class CReference; | // -------------------------------------------------------------------------- // ========================================================================== /* DESCRIPTION *///------------------------------------------------------------------------- class MyClassName // Always refers to at least one instance { private: protected: MyClassName(); ~MyClassName(); public: #if defined(USE_OSTREAM) friend ostream& operator<<(ostream&,const MyClassName&); #endif }; /* NOTES *///========================================================================= #if defined(INCLUDE_MESSAGES) #pragma message("Defined class MyClassName") #endif #endif #undef DEFINITION #endif #if defined(PRIVATE_MyClassName) // classes this class uses privately (i.e. for PRIVATE file's benefit) #define DEFINITION // This will include definitions of classes who have declared us friends #define PRIVATE // This will include private, prot & pub class references of classes who have declared us friends // ========================================================================== // | Friends - Include definitions of classes declaring us friends | // | (not in library) e.g. #include "classDeclaringUsFriend.hpp" | // -------------------------------------------------------------------------- // ========================================================================== #undef DEFINITION #undef PRIVATE #endif #if defined(PRIVATE_MyClassName) || defined(PROTECTED_MyClassName) || defined(PUBLIC_MyClassName) #if defined(PUBLIC_MyClassName) #define PUBLIC #else #define PROTECTED #endif // ========================================================================== // | Base classes - Include definitions of classes used by base class | // | (not in library) e.g. #include "Baseclass.hpp" | // -------------------------------------------------------------------------- // ========================================================================== #if defined(PUBLIC_MyClassName) #undef PUBLIC #else #undef PROTECTED #endif #endif #if defined(PRIVATE_MyClassName) #define DEFINITION #define PUBLIC // ========================================================================== // | Private - Include definitions of private references to classes | // | (not in library) e.g. #include "Reference.hpp" | // -------------------------------------------------------------------------- // ========================================================================== #undef PUBLIC #undef DEFINITION #endif #if defined(PRIVATE_MyClassName) || defined(PROTECTED_MyClassName) #define DEFINITION #define PUBLIC // ========================================================================== // | Protected - Include definitions of protected references to classes| // | (not in library) e.g. #include "Reference.hpp" | // -------------------------------------------------------------------------- // ========================================================================== #undef PUBLIC #undef DEFINITION #endif #if !defined(DPUBLIC_MyClassName) && (defined(PRIVATE_MyClassName) || defined(PROTECTED_MyClassName) || defined(PUBLIC_MyClassName)) #define DPUBLIC_MyClassName #define DEFINITION #define PUBLIC // ========================================================================== // | Public - Include definitions of public references to classes | // | (not in library) e.g. #include "Reference.hpp" | // -------------------------------------------------------------------------- // ========================================================================== #undef PUBLIC #undef DEFINITION #endif #if defined(PRIVATE_MyClassName) #undef PRIVATE_MyClassName #define PRIVATE #elif defined(PROTECTED_MyClassName) #undef PROTECTED_MyClassName #define PROTECTED #elif defined(PUBLIC_MyClassName) #undef PUBLIC_MyClassName #define PUBLIC #endif #if defined(DEFINITION) #error DEFINITION should be undefined at this point #endif #if defined(CPP_MyClassName) #undef CPP_MyClassName #undef PRIVATE #endif #if defined(DEFINITION_MyClassName) #define DEFINITION #undef DEFINITION_MyClassName #endif #undef LOCK_MyClassName #else // LOCK_MyClassName #if defined(INCLUDE_BREACH) #pragma message("Breach of LOCK_MyClassName attempted") #endif #endif // LOCK_MyClassName /*********************** Always exits with all macros in the same state as at entry apart from: CPP will be undefined if defined at entry DEFINED_MyClassName will be defined if DEFINITION was defined at entry DPUBLIC_MyClassName will be defined */