diff --git a/inst/include/interface/rcpp/rcpp_objects/rcpp_data.hpp b/inst/include/interface/rcpp/rcpp_objects/rcpp_data.hpp index 3f25e3f7e..13df67d96 100644 --- a/inst/include/interface/rcpp/rcpp_objects/rcpp_data.hpp +++ b/inst/include/interface/rcpp/rcpp_objects/rcpp_data.hpp @@ -120,6 +120,73 @@ class AgeCompDataInterface : public DataInterfaceBase { #endif }; +/** + * @brief Rcpp interface for length comp data as an S4 object. To instantiate + * from R: + * acomp <- new(LengthComp) + */ +class LengthCompDataInterface : public DataInterfaceBase { + public: + int lmax; /**< first dimension of the data */ + int ymax; /**< second dimension of the data */ + Rcpp::NumericVector length_comp_data; /**lmax = lmax; + this->ymax = ymax; + } + + /** + * @brief destructor + */ + virtual ~LengthCompDataInterface() {} + + /** @brief get the ID of the interface base object + */ + virtual uint32_t get_id() { return this->id; } + +#ifdef TMB_MODEL + + template + bool add_to_fims_tmb_internal() { + std::shared_ptr> length_comp_data = + std::make_shared>(this->ymax, + this->lmax); + + length_comp_data->id = this->id; + for (int y = 0; y < ymax; y++) { + for (int l = 0; l < lmax; l++) { + int i_length_year = y * lmax + l; + length_comp_data->at(y, a) = this->length_comp_data[i_length_year]; + } + } + + std::shared_ptr> info = + fims_info::Information::GetInstance(); + + info->data_objects[this->id] = length_comp_data; + + return true; + } + + /** + * @brief adds parameters to the model + */ + virtual bool add_to_fims_tmb() { + this->add_to_fims_tmb_internal(); + this->add_to_fims_tmb_internal(); + this->add_to_fims_tmb_internal(); + this->add_to_fims_tmb_internal(); + + return true; + } + +#endif +}; + /** * @brief Rcpp interface for data as an S4 object. To instantiate * from R: