GCC Code Coverage Report


Directory: ./
File: lib/geogram/image/image_serializer.h
Date: 2026-09-07 02:25:23
Exec Total Coverage
Lines: 1 1 100.0%
Functions: 0 0 -%
Branches: 0 0 -%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2000-2022 Inria
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * * Neither the name of the ALICE Project-Team nor the names of its
14 * contributors may be used to endorse or promote products derived from this
15 * software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Contact: Bruno Levy
30 *
31 * https://www.inria.fr/fr/bruno-levy
32 *
33 * Inria,
34 * Domaine de Voluceau,
35 * 78150 Le Chesnay - Rocquencourt
36 * FRANCE
37 *
38 */
39
40 #ifndef H_OGF_IMAGE_IO_IMAGE_SERIALIZER_H
41 #define H_OGF_IMAGE_IO_IMAGE_SERIALIZER_H
42
43 #include <geogram/basic/common.h>
44 #include <geogram/image/image.h>
45 #include <geogram/basic/counted.h>
46 #include <geogram/basic/smart_pointer.h>
47
48 #include <iostream>
49
50 /**
51 * \file geogram/image/image_serializer.h
52 * \brief Baseclass for loading and saving images.
53 */
54
55 namespace GEO {
56
57 //_________________________________________________________
58
59
60 class Image ;
61
62 /**
63 * \brief Loads and saves images.
64 */
65 1245 class GEOGRAM_API ImageSerializer : public Counted {
66 public:
67
68 /**
69 * \brief reads an image from a file.
70 * \param[in] file_name the name of the file
71 * \return a pointer to the loaded image or nil if
72 * the image could not be loaded
73 * \note the loaded image can be stored in an Image_var
74 */
75 virtual Image* serialize_read(const std::string& file_name) ;
76
77 /**
78 * \brief writes an image into a file.
79 * \param[in] file_name the name of the file
80 * \param[in] image a pointer to the image to be saved
81 * \retval true if the image could be saved
82 * \retval false otherwise
83 */
84 virtual bool serialize_write(
85 const std::string& file_name, const Image* image
86 ) ;
87
88 /**
89 * \brief reads an image from a stream.
90 * \param[in,out] stream the stream where the image should
91 * be read from
92 * \return a pointer to the loaded image or nil if
93 * the image could not be loaded
94 * \note the loaded image can be stored in an Image_var
95 */
96 virtual Image* serialize_read_from_stream(std::istream& stream) ;
97
98 /**
99 * \brief writes an image into a stream.
100 * \param[in,out] stream the stream where the image should be written
101 * \param[in] image a pointer to the image to be saved
102 * \retval true if the image could be saved
103 * \retval false otherwise
104 */
105 virtual bool serialize_write_to_stream(
106 std::ostream& stream, const Image* image
107 ) ;
108
109 /**
110 * \brief Tests whether the file format is binary or ASCII.
111 * \details It is used to determine whether a stream should be
112 * opened in ASCII or binary mode for loading image files.
113 * Default implementation in base class returns true.
114 * \retval true if the file format is binary
115 * \retval false if the file format is ASCII
116 */
117 virtual bool binary() const ;
118
119 /**
120 * \brief Tests whether the functions that use streams
121 * are supported.
122 * \details Default implementation in base class returns true.
123 * \retval true if the functions that use streams are
124 * supported
125 * \retval false otherwise
126 */
127 virtual bool streams_supported() const ;
128
129 /**
130 * \brief Tests whether reading is implemented.
131 * \details Some serializers implement only reading or only
132 * writing. Default implementation returns false
133 * \retval true if reading is supported
134 * \retval false otherwise
135 */
136 virtual bool read_supported() const ;
137
138 /**
139 * \brief Tests whether writing is implemented.
140 * \details Some serializers implement only reading or only
141 * writing. Default implementation returns false
142 * \retval true if writing is supported
143 * \retval false otherwise
144 */
145 virtual bool write_supported() const ;
146 } ;
147
148 /**
149 * \brief An automatic reference-counted pointer to an ImageSerializer
150 */
151 typedef SmartPointer<ImageSerializer> ImageSerializer_var ;
152
153 //_________________________________________________________
154
155 }
156 #endif
157