Line data Source code
1 :
2 : /* Copyright (c) 2013-2014, Stefan.Eilemann@epfl.ch
3 : *
4 : * This file is part of Lunchbox <https://github.com/Eyescale/Lunchbox>
5 : *
6 : * This library is free software; you can redistribute it and/or modify it under
7 : * the terms of the GNU Lesser General Public License version 2.1 as published
8 : * by the Free Software Foundation.
9 : *
10 : * This library is distributed in the hope that it will be useful, but WITHOUT
11 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 : * details.
14 : *
15 : * You should have received a copy of the GNU Lesser General Public License
16 : * along with this library; if not, write to the Free Software Foundation, Inc.,
17 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 : */
19 :
20 : #ifndef LUNCHBOX_DECOMPRESSOR_H
21 : #define LUNCHBOX_DECOMPRESSOR_H
22 :
23 : #include <lunchbox/api.h>
24 : #include <lunchbox/types.h>
25 : #include <lunchbox/thread.h> // thread-safety macros
26 :
27 : namespace lunchbox
28 : {
29 : namespace detail { class Decompressor; }
30 :
31 : /**
32 : * A C++ class to handle one decompressor plugin instance.
33 : *
34 : * Example: @include tests/compressor.cpp
35 : */
36 : class Decompressor : public boost::noncopyable
37 : {
38 : typedef detail::Decompressor* const Decompressor::*bool_t;
39 :
40 : public:
41 : /** Construct a new, invalid decompressor instance. @version 1.7.1 */
42 : LUNCHBOX_API Decompressor();
43 :
44 : /**
45 : * Construct a new decompressor instance.
46 : *
47 : * @param from the plugin registry.
48 : * @param name the name of the decompressor.
49 : * @version 1.7.1
50 : */
51 : LUNCHBOX_API Decompressor( PluginRegistry& from, const uint32_t name );
52 :
53 : /** Destruct this decompressor. @version 1.7.1 */
54 : LUNCHBOX_API virtual ~Decompressor();
55 :
56 : /** @return true if the instance is usable. @version 1.7.1 */
57 : LUNCHBOX_API bool isGood() const;
58 :
59 : /**
60 : * @return true if the instance is usable, false otherwise.
61 : * @version 1.9.1
62 : */
63 : operator bool_t() const { return isGood() ? &Decompressor::impl_ : 0; }
64 :
65 : /** @return true if the instance is not usable. @version 1.9.1 */
66 153 : bool operator ! () const { return !isGood(); }
67 :
68 : /**
69 : * @return true if the instance is usable for the given name.
70 : * @version 1.7.1
71 : */
72 : LUNCHBOX_API bool uses( const uint32_t name ) const;
73 :
74 : /** @return the information about the allocated instance. @version 1.7.1 */
75 : LUNCHBOX_API const EqCompressorInfo& getInfo() const;
76 :
77 : /**
78 : * Set up a new, named decompressor instance.
79 : *
80 : * @param from the plugin registry.
81 : * @param name the name of the decompressor.
82 : * @return true on success, false otherwise.
83 : * @version 1.7.1
84 : */
85 : LUNCHBOX_API bool setup( PluginRegistry& from, const uint32_t name );
86 :
87 : /** Reset to EQ_COMPRESSOR_NONE. @version 1.7.1 */
88 : LUNCHBOX_API void clear();
89 :
90 : /**
91 : * Decompress one-dimensional data.
92 : *
93 : * @param in the pointer to an array of input data pointers
94 : * @param inSizes the array of input data sizes in bytes
95 : * @param numInputs the number of input data elements
96 : * @param out the pointer to a pre-allocated buffer for the
97 : * uncompressed output result.
98 : * @param outDim the dimensions of the output data.
99 : * @version 1.7.1
100 : */
101 : LUNCHBOX_API void decompress( const void* const* in,
102 : const uint64_t* const inSizes,
103 : const unsigned numInputs, void* const out,
104 : uint64_t outDim[2] );
105 : /**
106 : * Decompress two-dimensional data.
107 : *
108 : * The output is not modified on error.
109 : *
110 : * @param input the compressed data
111 : * @param out the pointer to a pre-allocated buffer for the
112 : * uncompressed output result.
113 : * @param pvpOut the dimensions of the output data.
114 : * @param flags capability flags for the decompression.
115 : * @return true on success, false otherwise
116 : * @version 1.9.1
117 : */
118 : LUNCHBOX_API bool decompress( const CompressorResult& input,
119 : void* const out, uint64_t pvpOut[4],
120 : const uint64_t flags );
121 : LUNCHBOX_API void decompress( const void* const* in,
122 : const uint64_t* const inSizes,
123 : const unsigned numInputs, void* const out,
124 : uint64_t pvpOut[4], const uint64_t flags )
125 : LB_DEPRECATED;
126 :
127 : private:
128 : detail::Decompressor* const impl_;
129 306 : LB_TS_VAR( _thread );
130 : };
131 : }
132 : #endif // LUNCHBOX_DECOMPRESSOR_H
|