[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

vigra/tuple.hxx

00001 /************************************************************************/
00002 /*                                                                      */
00003 /*               Copyright 1998-2002 by Ullrich Koethe                  */
00004 /*       Cognitive Systems Group, University of Hamburg, Germany        */
00005 /*                                                                      */
00006 /*    This file is part of the VIGRA computer vision library.           */
00007 /*    The VIGRA Website is                                              */
00008 /*        http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/      */
00009 /*    Please direct questions, bug reports, and contributions to        */
00010 /*        ullrich.koethe@iwr.uni-heidelberg.de    or                    */
00011 /*        vigra@informatik.uni-hamburg.de                               */
00012 /*                                                                      */
00013 /*    Permission is hereby granted, free of charge, to any person       */
00014 /*    obtaining a copy of this software and associated documentation    */
00015 /*    files (the "Software"), to deal in the Software without           */
00016 /*    restriction, including without limitation the rights to use,      */
00017 /*    copy, modify, merge, publish, distribute, sublicense, and/or      */
00018 /*    sell copies of the Software, and to permit persons to whom the    */
00019 /*    Software is furnished to do so, subject to the following          */
00020 /*    conditions:                                                       */
00021 /*                                                                      */
00022 /*    The above copyright notice and this permission notice shall be    */
00023 /*    included in all copies or substantial portions of the             */
00024 /*    Software.                                                         */
00025 /*                                                                      */
00026 /*    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND    */
00027 /*    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES   */
00028 /*    OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND          */
00029 /*    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT       */
00030 /*    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,      */
00031 /*    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING      */
00032 /*    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR     */
00033 /*    OTHER DEALINGS IN THE SOFTWARE.                                   */                
00034 /*                                                                      */
00035 /************************************************************************/
00036 
00037 #ifndef VIGRA_TUPLE_HXX
00038 #define VIGRA_TUPLE_HXX
00039 
00040 #include <utility>    // for pair
00041 
00042 namespace vigra {
00043 
00044 /*! \page TupleTypes Tuple Types
00045 
00046     pair, triple, tuple4, tuple5
00047 
00048     <b>\#include</b> <<a href="utilities_8hxx-source.html">vigra/utilities.hxx</a>><br>
00049     Namespace: vigra
00050 
00051     VIGRA defines tuple types \p vigra::triple, \p vigra::tuple4, \p vigra::tuple5.
00052     In addition, \p std::pair is imported into namespace vigra from the C++ standard
00053     library. All these types are defined similarly:
00054 
00055     <ul>
00056 
00057     <li> They are parameterized by the respective number of types. For each tuple,
00058     a constructor is defined that takes that many arguments, e.g.:
00059     \code
00060     template <class First, class Second, class Third>
00061     class Triple { ... };
00062     \endcode
00063     </li>
00064     <li> A number of \p typedef's tells the types stored in the tuple:
00065 
00066     \code
00067     typedef ... first_type;
00068     typedef ... second_type;
00069     typedef ... third_type;  // triple, tuple4, tuple5 only
00070     typedef ... forth_type;  // tuple4, tuple5 only
00071     typedef ... fifth_type;  // tuple5 only
00072     \endcode
00073     </li>
00074     <li> Items are stored in the following public attributes:
00075 
00076     \code
00077 
00078     first;
00079     second;
00080     third;  // triple, tuple4, tuple5 only
00081     forth;  // tuple4, tuple5 only
00082     fifth;  // tuple5 only
00083 
00084     \endcode
00085     </li>
00086     </ul>
00087 
00088 
00089 */
00090 
00091 /********************************************************/
00092 /*                                                      */
00093 /*                          pair                        */
00094 /*                                                      */
00095 /********************************************************/
00096 
00097 using std::pair;
00098 
00099 /********************************************************/
00100 /*                                                      */
00101 /*                          triple                      */
00102 /*                                                      */
00103 /********************************************************/
00104 
00105 template <class T1, class T2, class T3>
00106 struct triple {
00107     typedef T1 first_type;
00108     typedef T2 second_type;
00109     typedef T3 third_type;
00110 
00111     T1 first;
00112     T2 second;
00113     T3 third;
00114     triple() {}
00115     triple(const T1& a, const T2& b, const T3& c)
00116     : first(a), second(b), third(c) {}
00117 };
00118 
00119 template <class T1, class T2, class T3>
00120 triple<T1,T2,T3> make_triple( T1 t1, T2 t2, T3 t3 )
00121 { return triple<T1,T2,T3>( t1, t2, t3 ); }
00122 
00123 /********************************************************/
00124 /*                                                      */
00125 /*                          tuple4                      */
00126 /*                                                      */
00127 /********************************************************/
00128 
00129 template <class T1, class T2, class T3, class T4>
00130 struct tuple4 {
00131     typedef T1 first_type;
00132     typedef T2 second_type;
00133     typedef T3 third_type;
00134     typedef T4 fourth_type;
00135 
00136     T1 first;
00137     T2 second;
00138     T3 third;
00139     T4 fourth;
00140     tuple4() {}
00141     tuple4(const T1& a, const T2& b, const T3& c, const T4& d)
00142     : first(a), second(b), third(c), fourth(d) {}
00143 };
00144 
00145 template <class T1, class T2, class T3, class T4>
00146 tuple4<T1,T2,T3,T4> make_tuple4( T1 t1, T2 t2, T3 t3, T4 t4 )
00147 { return tuple4<T1,T2,T3,T4>( t1, t2, t3, t4 ); }
00148 
00149 /********************************************************/
00150 /*                                                      */
00151 /*                          tuple5                      */
00152 /*                                                      */
00153 /********************************************************/
00154 
00155 template <class T1, class T2, class T3, class T4, class T5>
00156 struct tuple5 {
00157     typedef T1 first_type;
00158     typedef T2 second_type;
00159     typedef T3 third_type;
00160     typedef T4 fourth_type;
00161     typedef T5 fifth_type;
00162 
00163     T1 first;
00164     T2 second;
00165     T3 third;
00166     T4 fourth;
00167     T5 fifth;
00168     tuple5() {}
00169     tuple5(const T1& a, const T2& b, const T3& c, const T4& d, const T5& e)
00170     : first(a), second(b), third(c), fourth(d), fifth(e) {}
00171 };
00172 
00173 template <class T1, class T2, class T3, class T4, class T5>
00174 tuple5<T1,T2,T3,T4,T5> make_tuple5( T1 t1, T2 t2, T3 t3, T4 t4, T5 t5 )
00175 { return tuple5<T1,T2,T3,T4,T5>( t1, t2, t3, t4, t5 ); }
00176 
00177 
00178 } // namespace vigra
00179 
00180 
00181 
00182 #endif /* VIGRA_TUPLE_HXX */

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de)
Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany

html generated using doxygen and Python
VIGRA 1.6.0 (5 Nov 2009)