PageRenderTime 30ms CodeModel.GetById 20ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 4ms

/Src/Dependencies/Boost/boost/iostreams/detail/access_control.hpp

http://hadesmem.googlecode.com/
C++ Header | 87 lines | 46 code | 18 blank | 23 comment | 1 complexity | ba17349d19b9f616cd80bfd9ebb1ec60 MD5 | raw file
 1// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
 2// (C) Copyright 2003-2007 Jonathan Turkanis
 3// Distributed under the Boost Software License, Version 1.0. (See accompanying
 4// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
 5
 6// See http://www.boost.org/libs/iostreams for documentation.
 7
 8// Contains the definition of the class template access_control, which
 9// allows the type of inheritance from a provided base class to be specified 
10// using a template parameter.
11
12
13#ifndef BOOST_IOSTREAMS_ACCESS_CONTROL_HPP_INCLUDED
14#define BOOST_IOSTREAMS_ACCESS_CONTROL_HPP_INCLUDED
15
16#if defined(_MSC_VER) && (_MSC_VER >= 1020)
17# pragma once
18#endif              
19
20#include <boost/iostreams/detail/select.hpp>
21#include <boost/mpl/identity.hpp>
22#include <boost/type_traits/is_same.hpp>
23
24namespace boost { namespace iostreams {
25
26struct protected_ { };  // Represents protected inheritance.
27struct public_ { };     // Represents public inheritance.
28
29
30namespace detail {
31
32    // Implements protected inheritance.
33    template<typename U>
34    struct prot_ : protected U 
35    { 
36        prot_() { }
37        template<typename V> prot_(V v) : U(v) { }
38    };
39
40    // Implements public inheritance.
41    template<typename U> struct pub_ : public U { 
42        pub_() { }
43        template<typename V> pub_(V v) : U(v) { }
44    };
45
46//
47// Used to deduce the base type for the template access_control.
48//
49template<typename T, typename Access>
50struct access_control_base {
51    typedef int                                 bad_access_specifier;
52    typedef typename 
53            iostreams::select<  // Disambiguation for Tru64
54                ::boost::is_same<
55                    Access, protected_
56                >,                              prot_<T>,
57                ::boost::is_same<
58                    Access, public_
59                >,                              pub_<T>,
60                else_,                          bad_access_specifier
61            >::type                             type;
62};
63
64} // End namespace detail.
65
66//
67// Template name: access_control.
68// Description: Allows the type of inheritance from a provided base class
69//      to be specified using an int template parameter.
70// Template parameters:
71//      Base - The class from which to inherit (indirectly.)
72//      Access - The type of access desired. Must be one of the 
73//          values access_base::prot or access_base::pub.
74//
75template< typename T, typename Access,
76          typename Base = // VC6 workaraound (Compiler Error C2516)
77              typename detail::access_control_base<T, Access>::type >
78struct access_control : public Base { 
79    access_control() { }
80    template<typename U> explicit access_control(U u) : Base(u) { }
81};
82
83//----------------------------------------------------------------------------//
84
85} } // End namespaces iostreams, boost.
86
87#endif // #ifndef BOOST_IOSTREAMS_ACCESS_CONTROL_HPP_INCLUDED