Subversion Repositories HomeAutomation

Rev

Rev 1642 | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
1596 runge 1
/*
2
 *
3
 *  Copyright (C) 2010  Mattias Runge
4
 *
5
 *  This program is free software; you can redistribute it and/or modify
6
 *  it under the terms of the GNU General Public License as published by
7
 *  the Free Software Foundation; either version 2 of the License, or
8
 *  (at your option) any later version.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License along
16
 *  with this program; if not, write to the Free Software Foundation, Inc.,
17
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
 *
19
 */
20
 
21
#ifndef TYPE_BITSET_H
22
#define TYPE_BITSET_H
23
 
24
#include <boost/shared_ptr.hpp>
2118 runge 25
#include <stdint.h>
1596 runge 26
 
27
#include "common.h"
28
#include "Byteset.h"
29
 
30
namespace atom {
1642 runge 31
namespace common {
1596 runge 32
 
33
class Bitset
34
{
35
public:
36
    typedef boost::shared_ptr<Bitset> Pointer;
37
 
38
    Bitset(unsigned int count);
39
    Bitset(const Byteset& set);
40
    virtual ~Bitset();
41
 
42
    int Set(unsigned int position);
43
    int Unset(unsigned int position);
44
    int Get(unsigned int position);
45
 
2118 runge 46
    uint64_t Read(unsigned int position, unsigned int length);
47
    void Write(unsigned int position, unsigned int length, uint64_t value);
1596 runge 48
 
49
    unsigned int GetCount();
1598 runge 50
    unsigned char* GetBytes() const;
51
 
52
    std::string ToDebugString();
53
 
1597 runge 54
private:
1598 runge 55
    unsigned char* bytes_;
1596 runge 56
    unsigned int count_;
57
};
58
 
59
}; // namespace type
60
}; // namespace atom
61
 
62
#endif // TYPE_BITSET_H