File: bandplane.h

package info (click to toggle)
splix 2.0.0-2.2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,912 kB
  • ctags: 653
  • sloc: cpp: 4,514; makefile: 332; sh: 86; ansic: 42
file content (129 lines) | stat: -rw-r--r-- 4,207 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
 * 	    bandplane.h               (C) 2006-2008, Aurélien Croc (AP²C)
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; version 2 of the License.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the
 *  Free Software Foundation, Inc.,
 *  59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 *  $Id: bandplane.h 247 2008-11-24 23:18:31Z ap2c $
 * 
 */
#ifndef _BANDPLANE_H_
#define _BANDPLANE_H_

/**
  * @brief This class contains data related to a band plane.
  *
  */
class BandPlane
{
    public:
        enum Endian {
            /** Machine dependant */
            Dependant,
            /** Big endian */
            BigEndian,
            /** Little endian */
            LittleEndian,
        };

    protected:
        unsigned char           _colorNr;
        unsigned long           _size;
        unsigned char*          _data;
        unsigned long           _checksum;
        Endian                  _endian;
        unsigned char           _compression;

    public:
        /**
          * Initialize the band plane instance.
          */
        BandPlane();
        /**
          * Destroy the instance
          */
        virtual ~BandPlane();

    public:
        /**
          * Set the color number of this plane.
          * @param nr the color number
          */
        void                    setColorNr(unsigned char nr) {_colorNr = nr;}
        /**
          * Set the data buffer.
          * The buffer will be freed during the destruction of this instance.
          * @param data the data buffer
          * @param size the size of the data
          */
        void                    setData(unsigned char *data, 
                                    unsigned long size);
        /**
          * Set the endian to use.
          * @param endian the endian to use.
          */
        void                    setEndian(Endian endian) {_endian = endian;}
        /**
         * Set the compression algorithm used.
         * @param compression the compression algorithm used.
         */
        void                    setCompression(unsigned char compression)
                                    {_compression = compression;}

        /**
          * @return the color number.
          */
        unsigned char           colorNr() const {return _colorNr;}
        /**
          * @return the data size.
          */
        unsigned long           dataSize() const {return _size;}
        /**
          * @return the data.
          */
        const unsigned char*    data() const {return _data;}
        /**
          * @return the endian to use.
          */
        Endian                  endian() const {return _endian;}
        /**
          * @return the checksum.
          */
        unsigned long           checksum() const {return _checksum;}
        /**
         * @return the compression algorithm used.
         */
        unsigned char           compression() const {return _compression;}

    public:
        /**
          * Swap this instance on the disk.
          * @param fd the file descriptor where the instance has to be swapped
          * @return TRUE if the instance has been successfully swapped. 
          *         Otherwise it returns FALSE.
          */
        bool                    swapToDisk(int fd);
        /**
          * Restore an instance from the disk into memory.
          * @param fd the file descriptor where the instance has been swapped
          * @return a bandplane instance if it has been successfully restored. 
          *         Otherwise it returns NULL.
          */
        static BandPlane*       restoreIntoMemory(int fd);
};

#endif /* _BANDPLANE_H_ */

/* vim: set expandtab tabstop=4 shiftwidth=4 smarttab tw=80 cin enc=utf8: */