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