last update 20 Sep 2009 |
00001 /* 00002 * Copyright (C) 2007 00003 * ITCR, Pablo Alvarado 00004 * 00005 * 00006 * This file is part of the Computer Vision and Robotics Library (CVR-Lib) 00007 * 00008 * The CVR-Lib is free software; you can redistribute it and/or 00009 * modify it under the terms of the BSD License. 00010 * 00011 * All rights reserved. 00012 * 00013 * Redistribution and use in source and binary forms, with or without 00014 * modification, are permitted provided that the following conditions are met: 00015 * 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 00019 * 2. Redistributions in binary form must reproduce the above copyright notice, 00020 * this list of conditions and the following disclaimer in the documentation 00021 * and/or other materials provided with the distribution. 00022 * 00023 * 3. Neither the name of the authors nor the names of its contributors may be 00024 * used to endorse or promote products derived from this software without 00025 * specific prior written permission. 00026 * 00027 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00028 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00029 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00030 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00031 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00032 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00033 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00034 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00035 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00036 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00037 * POSSIBILITY OF SUCH DAMAGE. 00038 */ 00039 00040 00041 /** 00042 * \file cvrGenericChannel.h 00043 * Definition of a meta-programming type which provides the channel 00044 * corresponding to a specific type 00045 * 00046 * \author Pablo Alvarado 00047 * \date 23.09.2007 00048 * 00049 * revisions ..: $Id: cvrGenericChannel.h,v 1.1 2007/10/14 02:45:37 alvarado Exp $ 00050 */ 00051 00052 #ifndef _CVR_GENERIC_CHANNEL_H_ 00053 #define _CVR_GENERIC_CHANNEL_H_ 00054 00055 #include "cvrChannel.h" 00056 #include "cvrChannel8.h" 00057 #include "cvrChannel32.h" 00058 #include "cvrChannelC.h" 00059 00060 namespace cvr { 00061 00062 /** 00063 * Class genericChannel 00064 * 00065 * This is a meta-programming class that allows to obtain the corresponding 00066 * channel from the type of the contained elements. Thus: 00067 * 00068 * - cvr::genericChannel<ubyte>::type equals cvr::channel8 00069 * - cvr::genericChannel<float>::type equals cvr::channel 00070 * - cvr::genericChannel<int32>::type equals cvr::channel32 00071 * - cvr::genericChannel<cvr::fcomplex>::type equals cvr::channelC 00072 * 00073 * Other types will produce a compiler error. 00074 * 00075 * \ingroup gInterfaces 00076 */ 00077 template<typename T> 00078 class genericChannel { 00079 // the default implementation does not have an internal type, so that 00080 // the compiler will generate an error. 00081 }; 00082 00083 template<> 00084 class genericChannel<ubyte> { 00085 public: 00086 typedef channel8 type; 00087 }; 00088 00089 template<> 00090 class genericChannel<float> { 00091 public: 00092 typedef channel type; 00093 }; 00094 00095 template<> 00096 class genericChannel<int32> { 00097 public: 00098 typedef channel32 type; 00099 }; 00100 00101 template<> 00102 class genericChannel< complex<float> > { 00103 public: 00104 typedef channelC type; 00105 }; 00106 00107 } 00108 00109 #endif 00110