-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from akleeman/crtp_model_base
CRTP: ModelBase
- Loading branch information
Showing
7 changed files
with
563 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (C) 2019 Swift Navigation Inc. | ||
* Contact: Swift Navigation <dev@swiftnav.com> | ||
* | ||
* This source is subject to the license found in the file 'LICENSE' which must | ||
* be distributed together with this source. All other rights reserved. | ||
* | ||
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, | ||
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. | ||
*/ | ||
|
||
#ifndef ALBATROSS_CORE_FIT_MODEL_H | ||
#define ALBATROSS_CORE_FIT_MODEL_H | ||
|
||
namespace albatross { | ||
|
||
template <typename ModelType, typename Fit> | ||
class FitModel { | ||
public: | ||
template <typename X, typename Y, typename Z> | ||
friend class Prediction; | ||
|
||
static_assert(std::is_move_constructible<Fit>::value, | ||
"Fit type must be move constructible to avoid unexpected copying."); | ||
|
||
FitModel(const ModelType &model, | ||
Fit &&fit) | ||
: model_(model), fit_(std::move(fit)) {} | ||
|
||
template <typename PredictFeatureType> | ||
Prediction<ModelType, PredictFeatureType, Fit> | ||
get_prediction(const std::vector<PredictFeatureType> &features) const { | ||
return Prediction<ModelType, PredictFeatureType, Fit>(*this, features); | ||
} | ||
|
||
private: | ||
const ModelType model_; | ||
const Fit fit_; | ||
|
||
}; | ||
|
||
} | ||
#endif |
Oops, something went wrong.