Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check individual version #332

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,7 @@ fast_weighted_sample <- function(size, probs) {
.Call(`_malariasimulation_fast_weighted_sample`, size, probs)
}

individual_headers_version <- function() {
.Call(`_malariasimulation_individual_headers_version`)
}

13 changes: 13 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.onLoad <- function(libname, pkgname){
headers_version <- individual_headers_version()
package_version <- as.character(packageVersion("individual"))
if (!identical(package_version, headers_version)) {
warning(sprintf(paste(
"malariasimulation was compiled against version '%s' of the individual,",
"but version '%s' is currently loaded. This is likely to cause,",
"malariasimulation to misbehave. You should re-install",
"malariasimulation. If using devtools, run `devtools::clean_dll` and",
"then load malariasimulation again."
), headers_version, package_version))
}
}
11 changes: 11 additions & 0 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,16 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
// individual_headers_version
std::string individual_headers_version();
RcppExport SEXP _malariasimulation_individual_headers_version() {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = Rcpp::wrap(individual_headers_version());
return rcpp_result_gen;
END_RCPP
}

RcppExport SEXP run_testthat_tests(void);

Expand Down Expand Up @@ -377,6 +387,7 @@ static const R_CallMethodDef CallEntries[] = {
{"_malariasimulation_bernoulli_multi_p_cpp", (DL_FUNC) &_malariasimulation_bernoulli_multi_p_cpp, 1},
{"_malariasimulation_bitset_index_cpp", (DL_FUNC) &_malariasimulation_bitset_index_cpp, 2},
{"_malariasimulation_fast_weighted_sample", (DL_FUNC) &_malariasimulation_fast_weighted_sample, 2},
{"_malariasimulation_individual_headers_version", (DL_FUNC) &_malariasimulation_individual_headers_version, 0},
{"run_testthat_tests", (DL_FUNC) &run_testthat_tests, 0},
{NULL, NULL, 0}
};
Expand Down
5 changes: 5 additions & 0 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,8 @@ Rcpp::IntegerVector fast_weighted_sample(
values = values + 1;
return values;
}

//[[Rcpp::export]]
std::string individual_headers_version() {
return INDIVIDUAL_VERSION;
}
Loading