Skip to content

Commit 95c4612

Browse files
authored
a few small tweaks to the public API (#215)
Signed-off-by: Anton Dukhovnikov <[email protected]>
1 parent 439d1fb commit 95c4612

File tree

7 files changed

+28
-24
lines changed

7 files changed

+28
-24
lines changed

include/rawtoaces/image_converter.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ class ImageConverter
147147
bool parse_parameters( const OIIO::ArgParse &arg_parser );
148148

149149
/// Collects all illuminants supported by this version.
150-
std::vector<std::string> supported_illuminants();
150+
std::vector<std::string> get_supported_illuminants() const;
151151

152152
/// Collects all camera models for which spectral sensitivity data is
153153
/// available in the database.
154-
std::vector<std::string> supported_cameras();
154+
std::vector<std::string> get_supported_cameras() const;
155155

156156
/// Configures the converter using the requested white balance and colour
157157
/// matrix method, and the metadata of the file provided in `input_file`.
@@ -160,14 +160,14 @@ class ImageConverter
160160
/// decode the pixels.
161161
/// @param input_filename
162162
/// A file name of the raw image file to read the metadata from.
163-
/// @param options
163+
/// @param hints
164164
/// Conversion hints to be passed to OIIO when reading an image file.
165165
/// The list can be pre- or post- updated with other hints, unrelated to
166166
/// the rawtoaces conversion.
167167
/// @result
168168
/// `true` if configured successfully.
169169
bool configure(
170-
const std::string &input_filename, OIIO::ParamValueList &options );
170+
const std::string &input_filename, const OIIO::ParamValueList &hints );
171171

172172
/// Configures the converter using the requested white balance and colour
173173
/// matrix method, and the metadata of the given OIIO::ImageSpec object.
@@ -181,8 +181,8 @@ class ImageConverter
181181
/// the rawtoaces conversion.
182182
/// @result
183183
/// `true` if configured successfully.
184-
bool
185-
configure( const OIIO::ImageSpec &imageSpec, OIIO::ParamValueList &hints );
184+
bool configure(
185+
const OIIO::ImageSpec &imageSpec, const OIIO::ParamValueList &hints );
186186

187187
/// Load an image from a given `path` into a `buffer` using the `hints`
188188
/// calculated by the `configure` method. The hints can be manually
@@ -261,19 +261,19 @@ class ImageConverter
261261
/// image. The multipliers become available after calling either of the
262262
/// two `configure` methods.
263263
/// @result a reference to the multipliers vector.
264-
const std::vector<double> &get_WB_multipliers();
264+
const std::vector<double> &get_WB_multipliers() const;
265265

266266
/// Get the solved input transform matrix of the currently processed image.
267267
/// The multipliers become available after calling either of the two
268268
/// `configure` methods.
269269
/// @result a reference to the matrix.
270-
const std::vector<std::vector<double>> &get_IDT_matrix();
270+
const std::vector<std::vector<double>> &get_IDT_matrix() const;
271271

272272
/// Get the solved chromatic adaptation transform matrix of the currently
273273
/// processed image. The multipliers become available after calling either
274274
/// of the two `configure` methods.
275275
/// @result a reference to the matrix.
276-
const std::vector<std::vector<double>> &get_CAT_matrix();
276+
const std::vector<std::vector<double>> &get_CAT_matrix() const;
277277

278278
private:
279279
// Solved transform of the current image.

include/rawtoaces/spectral_data.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ struct Spectrum
8686

8787
/// Integrate the spectral curve.
8888
/// @result the sum of all elements in `values`.
89-
double integrate();
89+
double integrate() const;
9090

9191
/// Find the maximum element in `values`
9292
/// @result the maximum element in `values`.

include/rawtoaces/usage_timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class UsageTimer
2424
/// passed since the last invocation of `reset()`.
2525
/// @param path The file math to print.
2626
/// @param message The message to print.
27-
void print( const std::string &path, const std::string &message );
27+
void print( const std::string &path, const std::string &message ) const;
2828

2929
private:
3030
double _start_time = 0.0;

src/rawtoaces_core/spectral_data.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void Spectrum::reshape()
151151
shape = ReferenceShape;
152152
}
153153

154-
double Spectrum::integrate()
154+
double Spectrum::integrate() const
155155
{
156156
double result = 0;
157157
for ( auto &v: values )

src/rawtoaces_util/image_converter.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ bool ImageConverter::parse_parameters( const OIIO::ArgParse &arg_parser )
910910

911911
if ( arg_parser["list-cameras"].get<int>() )
912912
{
913-
auto cameras = supported_cameras();
913+
auto cameras = get_supported_cameras();
914914
std::cout
915915
<< std::endl
916916
<< "Spectral sensitivity data is available for the following cameras:"
@@ -921,7 +921,7 @@ bool ImageConverter::parse_parameters( const OIIO::ArgParse &arg_parser )
921921

922922
if ( arg_parser["list-illuminants"].get<int>() )
923923
{
924-
auto illuminants = supported_illuminants();
924+
auto illuminants = get_supported_illuminants();
925925
std::cout << std::endl
926926
<< "The following illuminants are supported:" << std::endl
927927
<< OIIO::Strutil::join( illuminants, "\n" ) << std::endl;
@@ -1169,7 +1169,7 @@ bool ImageConverter::parse_parameters( const OIIO::ArgParse &arg_parser )
11691169
return true;
11701170
}
11711171

1172-
std::vector<std::string> ImageConverter::supported_illuminants()
1172+
std::vector<std::string> ImageConverter::get_supported_illuminants() const
11731173
{
11741174
std::vector<std::string> result;
11751175

@@ -1190,7 +1190,7 @@ std::vector<std::string> ImageConverter::supported_illuminants()
11901190
return result;
11911191
}
11921192

1193-
std::vector<std::string> ImageConverter::supported_cameras()
1193+
std::vector<std::string> ImageConverter::get_supported_cameras() const
11941194
{
11951195
std::vector<std::string> result;
11961196

@@ -1242,8 +1242,9 @@ void fix_metadata( OIIO::ImageSpec &spec )
12421242
}
12431243

12441244
bool ImageConverter::configure(
1245-
const std::string &input_filename, OIIO::ParamValueList &options )
1245+
const std::string &input_filename, const OIIO::ParamValueList &hints = {} )
12461246
{
1247+
OIIO::ParamValueList options = hints;
12471248
options["raw:ColorSpace"] = "XYZ";
12481249
options["raw:use_camera_wb"] = 0;
12491250
options["raw:use_auto_wb"] = 0;
@@ -1277,8 +1278,9 @@ bool ImageConverter::configure(
12771278
// -G - green_matching() filter
12781279

12791280
bool ImageConverter::configure(
1280-
const OIIO::ImageSpec &image_spec, OIIO::ParamValueList &options )
1281+
const OIIO::ImageSpec &image_spec, const OIIO::ParamValueList &hints = {} )
12811282
{
1283+
OIIO::ParamValueList options = hints;
12821284
options["raw:use_camera_wb"] = 0;
12831285
options["raw:use_auto_wb"] = 0;
12841286

@@ -1977,17 +1979,17 @@ bool ImageConverter::process_image( const std::string &input_filename )
19771979
return ( true );
19781980
}
19791981

1980-
const std::vector<double> &ImageConverter::get_WB_multipliers()
1982+
const std::vector<double> &ImageConverter::get_WB_multipliers() const
19811983
{
19821984
return _wb_multipliers;
19831985
}
19841986

1985-
const std::vector<std::vector<double>> &ImageConverter::get_IDT_matrix()
1987+
const std::vector<std::vector<double>> &ImageConverter::get_IDT_matrix() const
19861988
{
19871989
return _idt_matrix;
19881990
}
19891991

1990-
const std::vector<std::vector<double>> &ImageConverter::get_CAT_matrix()
1992+
const std::vector<std::vector<double>> &ImageConverter::get_CAT_matrix() const
19911993
{
19921994
return _cat_matrix;
19931995
}

src/rawtoaces_util/usage_timer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ void UsageTimer::reset()
3838
}
3939
}
4040

41-
void UsageTimer::print( const std::string &path, const std::string &message )
41+
void UsageTimer::print(
42+
const std::string &path, const std::string &message ) const
4243
{
4344
if ( enabled && _initialized )
4445
{

tests/test_image_converter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ std::string run_rawtoaces_with_data_dir(
728728
}
729729

730730
/// This test verifies that when --list-cameras is provided, the method
731-
/// calls supported_cameras() and outputs the camera list, then exits
731+
/// calls get_supported_cameras() and outputs the camera list, then exits
732732
void test_parse_parameters_list_cameras( bool use_dir_path_arg = false )
733733
{
734734
std::cout << std::endl
@@ -771,7 +771,8 @@ void test_parse_parameters_list_cameras( bool use_dir_path_arg = false )
771771
}
772772

773773
/// This test verifies that when --list-illuminants is provided, the method
774-
/// calls supported_illuminants() and outputs the illuminant list, then exits
774+
/// calls get_supported_illuminants() and outputs the illuminant list,
775+
/// then exits
775776
void test_parse_parameters_list_illuminants( bool use_dir_path_arg = false )
776777
{
777778
std::cout << std::endl

0 commit comments

Comments
 (0)