- Added maximization features, with corresponding plugins. Added painting feature...
[mldemos:mldemos.git] / _3rdParty / dlib / entropy_encoder_model / entropy_encoder_model_kernel_c.h
1 // Copyright (C) 2004  Davis E. King (davis@dlib.net)\r
2 // License: Boost Software License   See LICENSE.txt for the full license.\r
3 #ifndef DLIB_ENTROPY_ENCODER_MODEL_KERNEl_C_\r
4 #define DLIB_ENTROPY_ENCODER_MODEL_KERNEl_C_\r
5 \r
6 #include "entropy_encoder_model_kernel_abstract.h"\r
7 #include "../algs.h"\r
8 #include "../assert.h"\r
9 #include <iostream>\r
10 \r
11 namespace dlib\r
12 {\r
13 \r
14     template <\r
15         typename eem_base\r
16         >\r
17     class entropy_encoder_model_kernel_c : public eem_base\r
18     {\r
19         const unsigned long alphabet_size;\r
20         typedef typename eem_base::entropy_encoder_type entropy_encoder;\r
21         \r
22         public:\r
23 \r
24             entropy_encoder_model_kernel_c (\r
25                 entropy_encoder& coder\r
26             ) : eem_base(coder), alphabet_size(eem_base::get_alphabet_size()) {}\r
27 \r
28             void encode (\r
29                 unsigned long symbol\r
30             );\r
31     };\r
32 \r
33 // ----------------------------------------------------------------------------------------\r
34 // ----------------------------------------------------------------------------------------\r
35     // member function definitions\r
36 // ----------------------------------------------------------------------------------------\r
37 // ----------------------------------------------------------------------------------------\r
38 \r
39     template <\r
40         typename eem_base\r
41         >\r
42     void entropy_encoder_model_kernel_c<eem_base>::\r
43     encode (\r
44         unsigned long symbol\r
45     )\r
46     {\r
47         // make sure requires clause is not broken\r
48         DLIB_CASSERT(symbol < alphabet_size,\r
49             "\tvoid entropy_encoder_model::encode()"\r
50             << "\n\tthe symbol must be in the range 0 to alphabet_size-1"\r
51             << "\n\talphabet_size: " << alphabet_size\r
52             << "\n\tsymbol:        " << symbol\r
53             << "\n\tthis:          " << this\r
54             );\r
55 \r
56         // call the real function\r
57         eem_base::encode(symbol);\r
58     }\r
59 \r
60 // ----------------------------------------------------------------------------------------\r
61 \r
62 }\r
63 \r
64 #endif // DLIB_ENTROPY_ENCODER_MODEL_KERNEl_C_\r
65 \r