00001 00010 /***************************************************************************** 00011 ** Ifdefs 00012 *****************************************************************************/ 00013 00014 #ifndef ECL_CONTAINERS_PUSH_AND_POP_FORMATTERS_HPP_ 00015 #define ECL_CONTAINERS_PUSH_AND_POP_FORMATTERS_HPP_ 00016 00017 /***************************************************************************** 00018 ** Includes 00019 *****************************************************************************/ 00020 00021 #include <cmath> 00022 #include <ecl/config/macros.hpp> 00023 #include <ecl/formatters/common.hpp> 00024 #include <ecl/formatters/number.hpp> 00025 #include <ecl/formatters/floats.hpp> 00026 #include "../common/formatters.hpp" 00027 #include "../push_and_pop.hpp" 00028 00029 /***************************************************************************** 00030 ** Namespaces 00031 *****************************************************************************/ 00032 00033 namespace ecl 00034 { 00035 namespace formatters 00036 { 00037 00038 /***************************************************************************** 00039 ** Using 00040 *****************************************************************************/ 00041 00065 template<typename Type, size_t N> 00066 class ECL_PUBLIC PushAndPopFormatter 00067 { 00068 public: 00069 virtual ~PushAndPopFormatter() 00070 {} 00077 ecl::PushAndPop<Type,N>& operator()(ecl::PushAndPop<Type,N> &container) { 00078 return container; 00079 } 00080 }; 00081 00082 /***************************************************************************** 00083 ** Specialisations [PushAndPopFormatter][Char Types] 00084 *****************************************************************************/ 00085 00099 template<size_t N> 00100 class ECL_PUBLIC PushAndPopFormatter< unsigned char,N > 00101 { 00102 public: 00103 // should really be using const with the arg here, but it needs some framework updates to allow 00104 // for the likes of Stencil< const Array<...) 00105 typename ecl::formatters::ByteArrayFormatter<unsigned char, N>& operator()(ecl::PushAndPop<unsigned char> &container) { 00106 //Stencil< Array<unsigned char, N> > stencil(container.data, 0, container.size()); 00107 //return array_formatter(stencil); 00108 return array_formatter(container.data.stencil(0,container.size())); 00109 } 00110 00111 private: 00112 typename ecl::formatters::ByteArrayFormatter<unsigned char, N> array_formatter; 00113 }; 00114 00115 00116 /***************************************************************************** 00117 ** Not Yet Implemented 00118 *****************************************************************************/ 00120 // * @brief Convenience formatter for viewing a signed char array in hex format. 00121 // * 00122 // * We dont accept a wide range of arguments for this class, it is simply 00123 // * designed to present byte arrays in hex format byte by byte. If you 00124 // * want specialised formatting for the byte array, iterate over it 00125 // * with the Format<char> (or signed/unsigned char) class. 00126 // * 00127 // * It will also accept stencils which have an underlying array of the 00128 // * required type. 00129 // * 00130 // * @tparam N : the size of the container to be formatted. 00131 // */ 00132 //template<size_t N> 00133 //class ECL_PUBLIC PushAndPopFormatter< signed char,N > : public BytePushAndPopFormatter<signed char, N> 00134 //{}; 00135 // 00137 // * @brief Convenience formatter for viewing a char array in hex format. 00138 // * 00139 // * We dont accept a wide range of arguments for this class, it is simply 00140 // * designed to present byte arrays in hex format byte by byte. If you 00141 // * want specialised formatting for the byte array, iterate over it 00142 // * with the Format<char> (or signed/unsigned char) class. 00143 // * 00144 // * It will also accept stencils which have an underlying array of the 00145 // * required type. 00146 // * 00147 // * @tparam N : the size of the container to be formatted. 00148 // */ 00149 //template<size_t N> 00150 //class ECL_PUBLIC PushAndPopFormatter< char,N > : public BytePushAndPopFormatter<char, N> 00151 //{}; 00152 00154 // * @brief Formatter for fixed size float arrays. 00155 // * 00156 // * Allows precision settings for formatting of fixed size float arrays. 00157 // * 00158 // * @tparam N : the size of the fixed size float array to be formatted. 00159 // * 00160 // * @sa @ref ecl::formatters::FloatContainerFormatter "FloatContainerFormatter". 00161 // */ 00162 //template<size_t N> 00163 //class ECL_PUBLIC PushAndPopFormatter< float,N > : public FloatContainerFormatter< Array<float,N> > 00164 //{ 00165 //public: 00166 // /** 00167 // * @brief Default constructor. 00168 // * 00169 // * Optionally accepts a precision setting for the contents of the array. 00170 // * 00171 // * @param p : the number of decimal places of precision [default : 2]. 00172 // * @param w : width [default : no width constraint] 00173 // */ 00174 // PushAndPopFormatter(const int p=2, const int w=-1) : FloatContainerFormatter< Array<float,N> >(p,w) 00175 // {}; 00176 // virtual ~PushAndPopFormatter() 00177 // {} 00178 //}; 00180 // * @brief Formatter for fixed size double arrays. 00181 // * 00182 // * Allows precision settings for formatting of fixed size double arrays. 00183 // * 00184 // * @tparam N : the size of the fixed size double array to be formatted. 00185 // * 00186 // * @sa @ref ecl::formatters::FloatContainerFormatter "FloatContainerFormatter". 00187 // */ 00188 //template<size_t N> 00189 //class ECL_PUBLIC PushAndPopFormatter< double,N > : public FloatContainerFormatter< Array<double,N> > 00190 //{ 00191 //public: 00192 // /** 00193 // * @brief Default constructor. 00194 // * 00195 // * Optionally accepts a precision setting for the contents of the array. 00196 // * 00197 // * @param p : the number of decimal places of precision [default : 2]. 00198 // * @param w : width [default : no width constraint] 00199 // */ 00200 // PushAndPopFormatter(const int p=2, const int w=-1) : FloatContainerFormatter< Array<double,N> >(p,w) 00201 // {}; 00202 // virtual ~PushAndPopFormatter() 00203 // {} 00204 //}; 00205 00206 } // namespace formatters 00207 } // namespace ecl 00208 00209 00210 #endif /* ECL_CONTAINERS_PUSH_AND_POP_FORMATTERS_HPP_ */