9 #ifndef IMPKERNEL_OPTIMIZER_STATE_MACROS_H
10 #define IMPKERNEL_OPTIMIZER_STATE_MACROS_H
11 #include <IMP/kernel/kernel_config.h>
14 #include "internal/utility.h"
19 #define IMP_OPTIMIZER_STATE(Name) \
20 IMPKERNEL_DEPRECATED_MACRO(2.1, "Declare the methods youself."); \
21 virtual void update() IMP_OVERRIDE; \
22 IMP_OBJECT_NO_WARNING(Name)
26 #define IMP_PERIODIC_OPTIMIZER_STATE(Name) \
27 IMPKERNEL_DEPRECATED_MACRO(2.1, "Use IMP::core::PeriodicOptimizerState."); \
28 virtual void update() { \
31 if (call_number_ % (skip_ + 1) == 0) { \
32 do_update(update_number_); \
36 IMP_PROTECTED_METHOD(void, do_update, (unsigned int call_number), , ); \
41 void set_is_optimizing(bool tf) { \
43 do_update(update_number_); \
48 IMP_NO_DOXYGEN(void set_skip_steps(unsigned int k) { set_period(k + 1); }); \
49 void set_period(unsigned int p) { \
50 IMP_USAGE_CHECK(p > 0, "Period must be positive."); \
54 unsigned int get_period() const { return skip_ + 1; } \
59 IMP_OBJECT_NO_WARNING(Name); \
62 ::IMP::kernel::internal::Counter skip_, call_number_, update_number_
79 #define IMP_MODEL_SAVE(Name, args, vars, constr, functs, save_action) \
80 IMPKERNEL_DEPRECATED_MACRO(2.1, "Just expand in place."); \
81 class Name##OptimizerState : public OptimizerState { \
82 std::string file_name_; \
83 vars virtual void do_update(unsigned int update_number) IMP_OVERRIDE { \
84 std::ostringstream oss; \
85 bool formatted = false; \
87 oss << boost::format(file_name_) % update_number; \
93 write(oss.str(), update_number, false); \
95 write(file_name_, update_number, update_number != 0); \
103 Name##OptimizerState args \
104 : OptimizerState(std::string("Writer to ") + file_name), \
105 file_name_(file_name) { \
108 functs void write(std::string file_name, unsigned int call = 0, \
109 bool append = false) const { \
111 IMP_UNUSED(append); \
116 IMP_OBJECT_METHODS(Name##OptimizerState); \
118 IMP_OBJECTS(Name##OptimizerState, Name##OptimizerStates);
Various general useful macros for IMP.
Various general useful macros for IMP.