OpenJPH
Open-source implementation of JPEG2000 Part-15
ojph_message.h
Go to the documentation of this file.
1//***************************************************************************/
2// This software is released under the 2-Clause BSD license, included
3// below.
4//
5// Copyright (c) 2019, Aous Naman
6// Copyright (c) 2019, Kakadu Software Pty Ltd, Australia
7// Copyright (c) 2019, The University of New South Wales, Australia
8//
9// Redistribution and use in source and binary forms, with or without
10// modification, are permitted provided that the following conditions are
11// met:
12//
13// 1. Redistributions of source code must retain the above copyright
14// notice, this list of conditions and the following disclaimer.
15//
16// 2. Redistributions in binary form must reproduce the above copyright
17// notice, this list of conditions and the following disclaimer in the
18// documentation and/or other materials provided with the distribution.
19//
20// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
26// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31//***************************************************************************/
32// This file is part of the OpenJPH software implementation.
33// File: ojph_message.h
34// Author: Aous Naman
35// Date: 29 August 2019
36//***************************************************************************/
37
38#ifndef OJPH_MESSAGE_H
39#define OJPH_MESSAGE_H
40
41#include <cstring>
42#include "ojph_arch.h"
43
44namespace ojph {
45
47 enum OJPH_MSG_LEVEL : int
48 {
49 NO_MSG = 0,
50 INFO = 1,
51 WARN = 2,
52 ERROR = 3
53 };
54
57 public:
59 virtual void operator() (int warn_code, const char* file_name,
60 int line_num, const char *fmt, ...) = 0;
61 };
62
65 {
66 public:
68 virtual void operator() (int info_code, const char* file_name,
69 int line_num, const char* fmt, ...);
70 };
71
74 void set_info_stream(FILE* s);
79
82 {
83 public:
85 virtual void operator() (int warn_code, const char* file_name,
86 int line_num, const char* fmt, ...);
87 };
88
91 void set_warning_stream(FILE* s);
96
99 {
100 public:
102 virtual void operator() (int warn_code, const char* file_name,
103 int line_num, const char *fmt, ...);
104 };
105
108 void set_error_stream(FILE *s);
113}
114
116#if (defined OJPH_OS_WINDOWS)
117 #define __OJPHFILE__ \
118 (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
119#else
120 #define __OJPHFILE__ \
121 (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
122#endif
123
125#define OJPH_INFO(t, ...) \
126 { ojph::get_info()(t, __OJPHFILE__, __LINE__, __VA_ARGS__); }
128#define OJPH_WARN(t, ...) \
129 { ojph::get_warning()(t, __OJPHFILE__, __LINE__, __VA_ARGS__); }
131#define OJPH_ERROR(t, ...) \
132 { ojph::get_error()(t, __OJPHFILE__, __LINE__,__VA_ARGS__); }
133
134
135#endif // !OJPH_MESSAGE_H
virtual OJPH_EXPORT void operator()(int warn_code, const char *file_name, int line_num, const char *fmt,...)=0
virtual OJPH_EXPORT void operator()(int warn_code, const char *file_name, int line_num, const char *fmt,...)
virtual OJPH_EXPORT void operator()(int info_code, const char *file_name, int line_num, const char *fmt,...)
virtual OJPH_EXPORT void operator()(int warn_code, const char *file_name, int line_num, const char *fmt,...)
message_warning warn
OJPH_EXPORT message_error & get_error()
OJPH_EXPORT void set_error_stream(FILE *s)
message_info info
OJPH_EXPORT void configure_error(message_error *error)
OJPH_EXPORT message_warning & get_warning()
OJPH_MSG_LEVEL
Definition: ojph_message.h:48
@ ERROR
Definition: ojph_message.h:52
@ WARN
Definition: ojph_message.h:51
@ INFO
Definition: ojph_message.h:50
@ NO_MSG
Definition: ojph_message.h:49
OJPH_EXPORT void set_warning_stream(FILE *s)
OJPH_EXPORT void set_info_stream(FILE *s)
OJPH_EXPORT void configure_warning(message_warning *warn)
OJPH_EXPORT message_info & get_info()
OJPH_EXPORT void configure_info(message_info *info)
message_error error
#define OJPH_EXPORT
Definition: ojph_arch.h:85