#ifndef __SCIP_OBJPRESOL_H__
#define __SCIP_OBJPRESOL_H__
#include <cstring>
#include <utility>
#include "scip/scip.h"
#include "objscip/objcloneable.h"
namespace scip
{
class ObjPresol : public ObjCloneable
{
public:
SCIP* scip_;
char* scip_name_;
char* scip_desc_;
const int scip_priority_;
const int scip_maxrounds_;
const SCIP_PRESOLTIMING scip_timing_;
ObjPresol(
SCIP* scip,
const char* name,
const char* desc,
int priority,
int maxrounds,
SCIP_PRESOLTIMING timing
)
: scip_(scip),
scip_name_(0),
scip_desc_(0),
scip_priority_(priority),
scip_maxrounds_(maxrounds),
scip_timing_(timing)
{
SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_name_, name, std::strlen(name)+1) );
SCIP_CALL_ABORT( SCIPduplicateMemoryArray(scip_, &scip_desc_, desc, std::strlen(desc)+1) );
}
ObjPresol(const ObjPresol& o)
: ObjPresol(o.scip_, o.scip_name_, o.scip_desc_, o.scip_priority_, o.scip_maxrounds_, o.scip_timing_)
{
}
ObjPresol(ObjPresol&& o)
: scip_(o.scip_),
scip_name_(0),
scip_desc_(0),
scip_priority_(o.scip_priority_),
scip_maxrounds_(o.scip_maxrounds_),
scip_timing_(o.scip_timing_)
{
std::swap(scip_name_, o.scip_name_);
std::swap(scip_desc_, o.scip_desc_);
}
virtual ~ObjPresol()
{
SCIPfreeMemoryArray(scip_, &scip_name_);
SCIPfreeMemoryArray(scip_, &scip_desc_);
}
ObjPresol& operator=(const ObjPresol& o) = delete;
ObjPresol& operator=(ObjPresol&& o) = delete;
virtual SCIP_DECL_PRESOLFREE(scip_free)
{
return SCIP_OKAY;
}
virtual SCIP_DECL_PRESOLINIT(scip_init)
{
return SCIP_OKAY;
}
virtual SCIP_DECL_PRESOLEXIT(scip_exit)
{
return SCIP_OKAY;
}
virtual SCIP_DECL_PRESOLINITPRE(scip_initpre)
{
return SCIP_OKAY;
}
virtual SCIP_DECL_PRESOLEXITPRE(scip_exitpre)
{
return SCIP_OKAY;
}
virtual SCIP_DECL_PRESOLEXEC(scip_exec) = 0;
};
}
SCIP_EXPORT
SCIP_RETCODE SCIPincludeObjPresol(
SCIP* scip,
scip::ObjPresol* objpresol,
SCIP_Bool deleteobject
);
SCIP_EXPORT
scip::ObjPresol* SCIPfindObjPresol(
SCIP* scip,
const char* name
);
SCIP_EXPORT
scip::ObjPresol* SCIPgetObjPresol(
SCIP* scip,
SCIP_PRESOL* presol
);
#endif