Menu

AttributeCompileErrors.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002  *
00003  * Copyright (c) 2008-2010 Michael Schulze <mschulze@ivs.cs.uni-magdeburg.de>
00004  *                    2010 Marcus Foerster <MarcusFoerster1@gmx.de>
00005  * All rights reserved.
00006  *
00007  *    Redistribution and use in source and binary forms, with or without
00008  *    modification, are permitted provided that the following conditions
00009  *    are met:
00010  *
00011  *    * Redistributions of source code must retain the above copyright
00012  *      notice, this list of conditions and the following disclaimer.
00013  *
00014  *    * Redistributions in binary form must reproduce the above copyright
00015  *      notice, this list of conditions and the following disclaimer in
00016  *      the documentation and/or other materials provided with the
00017  *      distribution.
00018  *
00019  *    * Neither the name of the copyright holders nor the names of
00020  *      contributors may be used to endorse or promote products derived
00021  *      from this software without specific prior written permission.
00022  *
00023  *
00024  *    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00025  *    IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00026  *    TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00027  *    PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00028  *    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00029  *    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00030  *    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00031  *    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00032  *    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00033  *    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00034  *    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  *
00037  * $Id$
00038  *
00039  ******************************************************************************/
00040 #ifndef __AttributeDetailCompileErrors_h__
00041 #define __AttributeDetailCompileErrors_h__
00042 
00043 #include <stdint.h>
00044 
00045 #include "assert/static.h"
00046 
00047 #include "boost/mpl/int.hpp"
00048 
00049 namespace famouso {
00050     namespace mw {
00051         namespace attributes {
00052             namespace detail {
00053 
00060                 template <uint16_t seqSize>
00061                 struct ExtendedSequenceBoundError {
00062                         typedef ExtendedSequenceBoundError type;
00063 
00064                         // In case of an extension, assert that the sequence size does not
00065                         //  exceed the bounds of 15 bits (0x7FFF)
00066                         FAMOUSO_STATIC_ASSERT_ERROR(
00067                             ((seqSize & 0x7FFF) == seqSize),
00068                             sequence_length_exceeds_extended_format_bounds,
00069                             (boost::mpl::int_<seqSize>));
00070                 };
00071 
00078                 template <uint16_t seqSize>
00079                 struct UnextendedSequenceBoundError {
00080                         typedef UnextendedSequenceBoundError type;
00081 
00082                         // In case of no extension, assert that the sequence size does not
00083                         //  exceed the bounds of 7 bits (0x7F)
00084                         FAMOUSO_STATIC_ASSERT_ERROR(
00085                             ((seqSize & 0x7F) == seqSize),
00086                             sequence_length_exceeds_unextended_format_bounds,
00087                             (boost::mpl::int_<seqSize>));
00088                 };
00089 
00095                 template <bool isRequirable, typename RelatedAttr, typename Requirement, bool compileError>
00096                 struct AttributeIsNotRequireable {
00097                         typedef AttributeIsNotRequireable type;
00098 
00099                         FAMOUSO_STATIC_ASSERT(
00100                             isRequirable,
00101                             only_requirable_attributes_may_be_used_in_a_requirement,
00102                             (RelatedAttr, Requirement),
00103                             compileError);
00104                 };
00105 
00111                 template <bool contained, typename RelatedAttr, typename Provision, bool compileError>
00112                 struct RequiredAttributeNotContainedInProvision {
00113                         typedef RequiredAttributeNotContainedInProvision type;
00114 
00115                         FAMOUSO_STATIC_ASSERT(
00116                             contained,
00117                             required_attribute_not_contained_in_provision,
00118                             (RelatedAttr, Provision),
00119                             compileError);
00120                 };
00121 
00127                 template <bool valueFits, typename RelatedAttr, typename ProvAttr, bool compileError>
00128                 struct RequiredValueNotProvided {
00129                         typedef RequiredValueNotProvided type;
00130 
00131                         FAMOUSO_STATIC_ASSERT(
00132                             valueFits,
00133                             required_value_not_provided,
00134                             (RelatedAttr, ProvAttr),
00135                             compileError);
00136                 };
00137             }
00138         }
00139     }
00140 }
00141 #endif
00142