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

vigra/tuple.hxx |

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