Subversion Repositories HomeAutomation

Rev

Rev 1598 | Go to most recent revision | 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>
25
 
26
#include "common.h"
27
#include "Byteset.h"
28
 
29
namespace atom {
1642 runge 30
namespace common {
1596 runge 31
 
32
class Bitset
33
{
34
public:
35
    typedef boost::shared_ptr<Bitset> Pointer;
36
 
37
    Bitset(unsigned int count);
38
    Bitset(const Byteset& set);
39
    virtual ~Bitset();
40
 
41
    int Set(unsigned int position);
42
    int Unset(unsigned int position);
43
    int Get(unsigned int position);
44
 
45
    unsigned long Read(unsigned int position, unsigned int length);
1598 runge 46
    void Write(unsigned int position, unsigned int length, unsigned long value);
1596 runge 47
 
48
    unsigned int GetCount();
1598 runge 49
    unsigned char* GetBytes() const;
50
 
51
    std::string ToDebugString();
52
 
1597 runge 53
private:
1598 runge 54
    unsigned char* bytes_;
1596 runge 55
    unsigned int count_;
56
};
57
 
58
}; // namespace type
59
}; // namespace atom
60
 
61
#endif // TYPE_BITSET_H