00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef eoBit_h
00034 #define eoBit_h
00035
00036
00037
00038 #include <algorithm>
00039 #include <functional>
00040 #include <iostream>
00041 #include <string>
00042
00043 #include "eoVector.h"
00044
00057 template <class FitT> class eoBit: public eoVector<FitT, bool>
00058 {
00059 public:
00060
00061 using eoVector< FitT, bool >::begin;
00062 using eoVector< FitT, bool >::end;
00063 using eoVector< FitT, bool >::resize;
00064 using eoVector< FitT, bool >::size;
00065
00070 eoBit(unsigned size = 0, bool value = false):
00071 eoVector<FitT, bool>(size, value) {}
00072
00074 virtual std::string className() const
00075 {
00076 return "eoBit";
00077 }
00078
00083 virtual void printOn(std::ostream& os) const
00084 {
00085 EO<FitT>::printOn(os);
00086 os << ' ';
00087 os << size() << ' ';
00088 std::copy(begin(), end(), std::ostream_iterator<bool>(os));
00089 }
00090
00095 virtual void readFrom(std::istream& is)
00096 {
00097 EO<FitT>::readFrom(is);
00098 unsigned s;
00099 is >> s;
00100 std::string bits;
00101 is >> bits;
00102 if (is)
00103 {
00104 resize(bits.size());
00105 std::transform(bits.begin(), bits.end(), begin(),
00106 std::bind2nd(std::equal_to<char>(), '1'));
00107 }
00108 }
00109 };
00110
00111
00112
00113 #endif //eoBit_h
00114
00115
00116
00117
00118
00119
00120
00121
00122