degate  0.1.2
TypeConstraints.h
Go to the documentation of this file.
00001 /* -*-c++-*-
00002 
00003  This file is part of the IC reverse engineering tool degate.
00004 
00005  Copyright 2008, 2009, 2010 by Martin Schobert
00006 
00007  Degate is free software: you can redistribute it and/or modify
00008  it under the terms of the GNU General Public License as published by
00009  the Free Software Foundation, either version 3 of the License, or
00010  any later version.
00011 
00012  Degate is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU General Public License for more details.
00016 
00017  You should have received a copy of the GNU General Public License
00018  along with degate. If not, see <http://www.gnu.org/licenses/>.
00019 
00020 */
00021 
00022 #ifndef __TYPECONSTRAINTS_H__
00023 #define __TYPECONSTRAINTS_H__
00024 
00025 #include <Image.h>
00026 #include <PixelPolicies.h>
00027 #include <StoragePolicies.h>
00028 
00029 namespace degate {
00030 
00031   /**
00032    * A dummy method to get rid of compiler warnings.
00033    */
00034 
00035   template <class T> inline void ignore_unused_variable_warning(T const&) {}
00036 
00037   /**
00038    * Compile time check for single channel image types.
00039    */
00040 
00041   template<class ImageType>
00042   struct assert_is_single_channel_image {
00043     static void constraints(ImageType img) {
00044       typedef typename ImageType::pixel_policy PolicyType;
00045       PolicyType::is_single_channel();
00046     }
00047     assert_is_single_channel_image() {
00048       void(*p)(ImageType) = constraints;
00049       ignore_unused_variable_warning(p);
00050     }
00051   };
00052 
00053   /**
00054    * Compile time check for multi channel image types.
00055    */
00056 
00057   template<class ImageType>
00058   struct assert_is_multi_channel_image {
00059     static void constraints(ImageType img) {
00060       typedef typename ImageType::pixel_policy PolicyType;
00061       PolicyType::is_multi_channel();
00062     }
00063     assert_is_multi_channel_image() {
00064       void(*p)(ImageType) = constraints;
00065       ignore_unused_variable_warning(p);
00066     }
00067   };
00068 
00069 }
00070 
00071 #endif