Tulip  4.6.0
Better Visualization Through Research
library/tulip-core/include/tulip/Array.h
00001 /*
00002  *
00003  * This file is part of Tulip (www.tulip-software.org)
00004  *
00005  * Authors: David Auber and the Tulip development Team
00006  * from LaBRI, University of Bordeaux
00007  *
00008  * Tulip is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation, either version 3
00011  * of the License, or (at your option) any later version.
00012  *
00013  * Tulip is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  *
00018  */
00019 #ifndef _TLP_GEO_ARRAY_H
00020 #define _TLP_GEO_ARRAY_H
00021 
00022 #include <cassert>
00023 #include <iostream>
00024 #include <tulip/tulipconf.h>
00025 
00026 namespace tlp {
00027 
00028 /**
00029  * @brief Fixed-size array encapsulation.
00030  * @ingroup Structures
00031  * In debug mode, a bound check is performed at each access.
00032  * Stream operators implementations are provided.
00033  *
00034  * @author : David Auber auber@tulip-software.org
00035  */
00036 template <typename Obj,unsigned int SIZE>
00037 struct Array {
00038   /**
00039    * @brief array The underlying array of data.
00040    */
00041   Obj array[SIZE];
00042 
00043   /**
00044    * @brief operator [] Read-only accessor.
00045    * @param i The index of the element to read.
00046    * @return The element at index i.
00047    */
00048   inline Obj  operator[](const unsigned int i) const;
00049 
00050   /**
00051    * @brief operator [] Write accessor.
00052    * @param i The index at which to write a value.
00053    * @return A reference to the value at index i.
00054    */
00055   inline Obj& operator[](const unsigned int i);
00056 };
00057 
00058 template <typename Obj,unsigned int SIZE>
00059 /**
00060  * @brief operator << stream operator to easily print an array, or save it to a file.
00061  * @param os The stream to output to.
00062  * @param array The array to output.
00063  * @return The stream to output to, to chain calls.
00064  */
00065 std::ostream& operator<<(std::ostream &os,const Array<Obj,SIZE> &array);
00066 
00067 template <typename Obj,unsigned int SIZE>
00068 /**
00069  * @brief operator >> stream operator to easily read an array
00070  * @param is The stream to read from.
00071  * @param array A reference to an array, that will be written to.
00072  * @return The stream to read from, to chain calls.
00073  */
00074 std::istream& operator>>(std::istream &is, Array<Obj,SIZE> &array);
00075 
00076 //template <typename Obj,unsigned int SIZE>
00077 //QDebug operator<<(QDebug dbg,const Array<Obj,SIZE>& s);
00078 }
00079 
00080 #include "cxx/Array.cxx"
00081 
00082 #endif
 All Classes Files Functions Variables Enumerations Enumerator Properties