- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# deferrer.hh

Go to the documentation of this file.

    00001 // deferrer.hh: this file is part of the Vaucanson project.
    00002 //
    00003 // Vaucanson, a generic library for finite state machines.
    00004 //
    00005 // Copyright (C) 2004, 2005, 2006 The Vaucanson Group.
    00006 //
    00007 // This program is free software; you can redistribute it and/or
    00008 // modify it under the terms of the GNU General Public License
    00009 // as published by the Free Software Foundation; either version 2
    00010 // of the License, or (at your option) any later version.
    00011 //
    00012 // The complete GNU General Public Licence Notice can be found as the
    00013 // `COPYING' file in the root directory.
    00014 //
    00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
    00016 //
    00017 #ifndef VCSN_MISC_DEFERRER_HH
    00018 # define VCSN_MISC_DEFERRER_HH
    00019
    00031 namespace vcsn
    00032 {
    00033   namespace misc
    00034   {
    00035
    00038 # ifndef VCSN_NDEBUG
    00039     enum { deferrer_runtime_checks_default = true };
    00040 # else // VCSN_NDEBUG
    00041     enum { deferrer_runtime_checks_default = false };
    00042 # endif // ! VCSN_NDEBUG
    00043
    00045
    00046     template <class T, bool B>
    00047     struct DeferrerDebugPart
    00048     {
    00049       protected:
    00050         // Defaults to true.
    00051         DeferrerDebugPart (void* ptr, bool is_valid = false);
    00052
    00053         void     set_valid (bool b);
    00054         T&       cast (void*);
    00055         const T& cast (const void*) const;
    00056
    00057         bool is_valid_;
    00058     };
    00059
    00060     template <class T>
    00061     struct DeferrerDebugPart<T, false>
    00062     {
    00063       protected:
    00064         // False version.
    00065         DeferrerDebugPart (void* ptr, bool is_valid = false);
    00066         void     set_valid (bool b);
    00067         T&       cast (void*);
    00068         const T& cast (const void*) const;
    00069     };
    00095     template <class T, bool rt_checks = deferrer_runtime_checks_default>
    00096     struct Deferrer : DeferrerDebugPart<T, rt_checks>
    00097     {
    00098         typedef T deferred_type;
    00099
    00108         Deferrer ();
    00109
    00117         Deferrer&
    00118         operator= (const deferred_type&);
    00119
    00121         operator T () const;
    00122       protected:
    00123         typedef unsigned char data_t[sizeof (deferred_type)];
    00124
    00132         data_t data;
    00133     };
    00134
    00136   } // End of namespace misc.
    00137 } // End of namespace vcsn.
    00138
    00139 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
    00140 #  include <vaucanson/misc/deferrer.hxx>
    00141 # endif // VCSN_USE_INTERFACE_ONLY
    00142
    00143 #endif // ! VCSN_MISC_DEFERRER_HH