Skip to content

Commit

Permalink
remove file constants.h, move code to print.h
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Jun 27, 2024
1 parent e25e0c9 commit 460e6ab
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
#include <antares/exception/InitializationError.hpp>
#include <antares/logs/logs.h>
#include "antares/concurrency/concurrency.h"
#include "antares/solver//variable/constants.h"
#include "antares/solver//variable/print.h"
#include "antares/solver/variable/print.h"
#include "antares/solver/hydro/management/management.h" // Added for use of randomReservoirLevel(...)
#include "antares/solver/simulation/apply-scenario.h"
#include "antares/solver/simulation/opt_time_writer.h"
Expand Down
3 changes: 1 addition & 2 deletions src/solver/variable/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ set(SRC_VARIABLE
include/antares/solver/variable/setofareas.hxx
include/antares/solver/variable/bindConstraints.h
include/antares/solver/variable/bindConstraints.hxx
include/antares/solver/variable/constants.h
include/antares/solver/variable/categories.h
include/antares/solver/variable/surveyresults.h
include/antares/solver/variable/surveyresults/reportbuilder.hxx
Expand Down Expand Up @@ -183,4 +182,4 @@ target_link_libraries(antares-solver-variable-info

install(DIRECTORY include/antares
DESTINATION "include"
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#define __SOLVER_VARIABLE_CATEGORIES_H__

#include <antares/antares/constants.h>
#include "constants.h"

namespace Antares::Solver::Variable::Category
{
Expand Down
121 changes: 0 additions & 121 deletions src/solver/variable/include/antares/solver/variable/constants.h

This file was deleted.

102 changes: 94 additions & 8 deletions src/solver/variable/include/antares/solver/variable/print.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@

#include <yuni/yuni.h>

namespace Antares
{
namespace Solver
{
namespace Variable
namespace Antares::Solver::Variable
{
class PrintInfosStdCout final
{
Expand Down Expand Up @@ -86,8 +82,98 @@ class PrintInfosStdCout final
Yuni::String pBuffer;
};

} // namespace Variable
} // namespace Solver
} // namespace Antares
template<int I>
struct PrecisionToPrintfFormat
{
static const char* Value()
{
return "%.6f";
}
};

template<>
struct PrecisionToPrintfFormat<0>
{
static const char* Value()
{
return "%.0f";
}
};

template<>
struct PrecisionToPrintfFormat<1>
{
static const char* Value()
{
return "%.1f";
}
};

template<>
struct PrecisionToPrintfFormat<2>
{
static const char* Value()
{
return "%.2f";
}
};

template<>
struct PrecisionToPrintfFormat<3>
{
static const char* Value()
{
return "%.3f";
}
};

template<>
struct PrecisionToPrintfFormat<4>
{
static const char* Value()
{
return "%.4f";
}
};

template<>
struct PrecisionToPrintfFormat<5>
{
static const char* Value()
{
return "%.5f";
}
};

template<class StringT>
static inline void AssignPrecisionToPrintfFormat(StringT& out, uint precision)
{
switch (precision)
{
case 0:
out.assign("%.0f", 4);
break;
case 1:
out.assign("%.1f", 4);
break;
case 2:
out.assign("%.2f", 4);
break;
case 3:
out.assign("%.3f", 4);
break;
case 4:
out.assign("%.4f", 4);
break;
case 5:
out.assign("%.5f", 4);
break;
default:
out.assign("%.6f", 4);
break;
}
}

} // namespace Antares::Solver::Variable

#endif // __SOLVER_VARIABLE_PRINT_H__
2 changes: 0 additions & 2 deletions src/solver/variable/include/antares/solver/variable/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
#include "antares/solver/simulation/sim_structure_donnees.h"
#include "antares/solver/simulation/sim_structure_probleme_economique.h"

#include "constants.h"

namespace Antares::Solver::Variable
{
class ThermalState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#ifndef __SOLVER_VARIABLE_STORAGE_INTERMEDIATE_HXX__
#define __SOLVER_VARIABLE_STORAGE_INTERMEDIATE_HXX__

#include <antares/solver/variable/print.h>

namespace Antares
{
namespace Solver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <yuni/core/static/if.h>

#include "categories.h"
#include "constants.h"
#include "container.h"
#include "endoflist.h"
#include "info.h"
Expand Down
1 change: 1 addition & 0 deletions src/solver/variable/surveyresults/surveyresults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <antares/logs/logs.h>
#include <antares/study/study.h>
#include <antares/utils/utils.h>
#include <antares/solver/variable/print.h>

using namespace Yuni;
using namespace Antares;
Expand Down

0 comments on commit 460e6ab

Please sign in to comment.