Jiaming Yuan ae536756ae
Add Model and Configurable interface. (#4945)
* Apply Configurable to objective functions.
* Apply Model to Learner and Regtree, gbm.
* Add Load/SaveConfig to objs.
* Refactor obj tests to use smart pointer.
* Dummy methods for Save/Load Model.
2019-10-18 01:56:02 -04:00

45 lines
963 B
C++

/*!
* Copyright (c) 2019 by Contributors
* \file model.h
* \brief Defines the abstract interface for different components in XGBoost.
*/
#ifndef XGBOOST_MODEL_H_
#define XGBOOST_MODEL_H_
namespace dmlc {
class Stream;
} // namespace dmlc
namespace xgboost {
class Json;
struct Model {
/*!
* \brief Save the model to stream.
* \param fo output write stream
*/
virtual void SaveModel(dmlc::Stream* fo) const = 0;
/*!
* \brief Load the model from stream.
* \param fi input read stream
*/
virtual void LoadModel(dmlc::Stream* fi) = 0;
};
struct Configurable {
/*!
* \brief Load configuration from JSON object
* \param in JSON object containing the configuration
*/
virtual void LoadConfig(Json const& in) = 0;
/*!
* \brief Save configuration to JSON object
* \param out pointer to output JSON object
*/
virtual void SaveConfig(Json* out) const = 0;
};
} // namespace xgboost
#endif // XGBOOST_MODEL_H_