File size: 3,373 Bytes
9375c9a |
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 |
// Copyright (C) 2003 Davis E. King ([email protected])
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_ENTROPY_ENCODER_KERNEl_C_
#define DLIB_ENTROPY_ENCODER_KERNEl_C_
#include "entropy_encoder_kernel_abstract.h"
#include "../algs.h"
#include "../assert.h"
#include <iostream>
namespace dlib
{
template <
typename encoder
>
class entropy_encoder_kernel_c : public encoder
{
public:
std::ostream& get_stream (
) const;
void encode (
uint32 low_count,
uint32 high_count,
uint32 total
);
void flush (
);
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// member function definitions
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template <
typename encoder
>
std::ostream& entropy_encoder_kernel_c<encoder>::
get_stream (
) const
{
// make sure requires clause is not broken
DLIB_CASSERT( this->stream_is_set() == true,
"\tstd::ostream& entropy_encoder::get_stream()"
<< "\n\tyou must set a stream for this object before you can get it"
<< "\n\tthis: " << this
);
// call the real function
return encoder::get_stream();
}
// ----------------------------------------------------------------------------------------
template <
typename encoder
>
void entropy_encoder_kernel_c<encoder>::
encode (
uint32 low_count,
uint32 high_count,
uint32 total
)
{
// make sure requires clause is not broken
DLIB_CASSERT( (0 < total) && (total < 65536) && (low_count < high_count) && (high_count <= total) &&
(this->stream_is_set() == true),
"\tvoid entropy_encoder::encode()"
<< "\n\trefer to the ensures clause for this function for further information"
<< "\n\tthis: " << this
<< "\n\ttotal: " << total
<< "\n\tlow_count: " << low_count
<< "\n\thigh_count: " << high_count
<< "\n\tis_stream_set(): " << (this->stream_is_set() ? "true" : "false" )
);
// call the real function
encoder::encode(low_count,high_count,total);
}
// ----------------------------------------------------------------------------------------
template <
typename encoder
>
void entropy_encoder_kernel_c<encoder>::
flush (
)
{
// make sure requires clause is not broken
DLIB_CASSERT( this->stream_is_set() == true,
"\tvoid entropy_encoder::flush()"
<< "\n\tyou must set a stream for this object before you can flush to it"
<< "\n\tthis: " << this
);
// call the real function
encoder::flush();
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_ENTROPY_ENCODER_KERNEl_C_
|