| 1 | /** |
| 2 | * Copyright 2019-2025, XGBoost Contributors |
| 3 | * |
| 4 | * @file model.h |
| 5 | * @brief Defines the abstract interface for different components in XGBoost. |
| 6 | */ |
| 7 | #ifndef XGBOOST_MODEL_H_ |
| 8 | #define XGBOOST_MODEL_H_ |
| 9 | |
| 10 | namespace xgboost { |
| 11 | |
| 12 | class Json; |
| 13 | |
| 14 | struct Model { |
| 15 | virtual ~Model() = default; |
| 16 | /*! |
| 17 | * \brief load the model from a JSON object |
| 18 | * \param in JSON object where to load the model from |
| 19 | */ |
| 20 | virtual void LoadModel(Json const& in) = 0; |
| 21 | /*! |
| 22 | * \brief saves the model config to a JSON object |
| 23 | * \param out JSON container where to save the model to |
| 24 | */ |
| 25 | virtual void SaveModel(Json* out) const = 0; |
| 26 | }; |
| 27 | |
| 28 | struct Configurable { |
| 29 | virtual ~Configurable() = default; |
| 30 | /*! |
| 31 | * \brief Load configuration from JSON object |
| 32 | * \param in JSON object containing the configuration |
| 33 | */ |
| 34 | virtual void LoadConfig(Json const& in) = 0; |
| 35 | /*! |
| 36 | * \brief Save configuration to JSON object |
| 37 | * \param out pointer to output JSON object |
| 38 | */ |
| 39 | virtual void SaveConfig(Json* out) const = 0; |
| 40 | }; |
| 41 | } // namespace xgboost |
| 42 | |
| 43 | #endif // XGBOOST_MODEL_H_ |