Bitset.h
Go to the documentation of this file.
00001 /*
00002  * This file is part of ALVAR, A Library for Virtual and Augmented Reality.
00003  *
00004  * Copyright 2007-2012 VTT Technical Research Centre of Finland
00005  *
00006  * Contact: VTT Augmented Reality Team <alvar.info@vtt.fi>
00007  *          <http://www.vtt.fi/multimedia/alvar.html>
00008  *
00009  * ALVAR is free software; you can redistribute it and/or modify it under the
00010  * terms of the GNU Lesser General Public License as published by the Free
00011  * Software Foundation; either version 2.1 of the License, or (at your option)
00012  * any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful, but WITHOUT
00015  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00016  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00017  * for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public License
00020  * along with ALVAR; if not, see
00021  * <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>.
00022  */
00023 
00024 #ifndef BITSET_H
00025 #define BITSET_H
00026 
00033 #include "Alvar.h"
00034 #include <iostream>
00035 #include <deque>
00036 #include <string>
00037 #include <sstream>
00038 #include <iomanip>
00039 
00040 namespace alvar {
00041 
00062 class ALVAR_EXPORT Bitset {
00063 protected:
00064         std::deque<bool> bits;
00065         
00066 public:
00068         int Length();
00072         std::ostream &Output(std::ostream &os) const;
00074         void clear();
00078         void push_back(const bool bit);
00083         void push_back(const unsigned char b, const int bit_count=8);
00088         void push_back(const unsigned short s, const int bit_count=16);
00093         void push_back(const unsigned long l, const int bit_count=32);
00097         void push_back_meaningful(const unsigned long l);
00101         void fill_zeros_left(const size_t bit_count);
00105         void push_back(std::string s);
00107         bool pop_front();
00109         bool pop_back();
00113         void flip(size_t pos);
00115         std::string hex();
00117         unsigned long ulong();
00119         unsigned char uchar();
00121         inline std::deque<bool>& GetBits()
00122         {
00123                 return bits;
00124         }
00125 };
00126 
00135 class ALVAR_EXPORT BitsetExt : public Bitset {
00136 protected:
00137         bool verbose;
00138         void hamming_enc_block(unsigned long block_len, std::deque<bool>::iterator &iter);
00139         int hamming_dec_block(unsigned long block_len, std::deque<bool>::iterator &iter);
00140 public:
00142         BitsetExt();
00144         BitsetExt(bool _verbose);
00146         void SetVerbose(bool _verbose);
00148         static int count_hamming_enc_len(int block_len, int dec_len);
00150         static int count_hamming_dec_len(int block_len, int enc_len);
00152         void hamming_enc(int block_len);
00154         int hamming_dec(int block_len);
00155 };
00156 
00157 } // namespace alvar
00158 
00159 #endif


ar_track_alvar
Author(s): Scott Niekum
autogenerated on Sat Dec 28 2013 16:46:15