FIMS  v0.9.3
Loading...
Searching...
No Matches
model_object.hpp
Go to the documentation of this file.
1
9#ifndef FIMS_COMMON_MODEL_OBJECT_HPP
10#define FIMS_COMMON_MODEL_OBJECT_HPP
11
12#include <stdint.h>
13#include <vector>
14
15#include "fims_vector.hpp"
16
17namespace fims_model_object {
18
24 static inline int total_active_objects = 0;
25
35 void register_self(const uint32_t id) {
36 std::string key = " [id=" + std::to_string(id) + "]";
38 tracker_key_ = key; // store for destructor
39 }
40
41 virtual ~FIMSMemoryTracker() {
42 if (!tracker_key_.empty()) {
44 }
45 }
46
47 private:
48 std::string tracker_key_;
49};
50
54template <typename Type>
56 uint32_t id;
57 std::vector<Type*> parameters;
58 std::vector<Type*>
60 std::vector<Type*>
63 FIMSObject() {}
64
65 virtual ~FIMSObject() {}
66
70 uint32_t GetId() const { return id; }
71
80 inline bool CheckDimensions(size_t actual, size_t expected) {
81 if (actual != expected) {
82 return false;
83 }
84
85 return true;
86 }
87};
88
89} // namespace fims_model_object
90
91#endif /* FIMS_COMMON_MODEL_OBJECT_HPP */
Establishes the FIMS Vector class.
FIMS struct that tracks object memory for leak detection.
Definition model_object.hpp:22
static int total_active_objects
Total number of active FIMSObject instances currently in memory.
Definition model_object.hpp:24
void register_self(const uint32_t id)
Registers a FIMSObject instance with the memory tracker.
Definition model_object.hpp:35
FIMSObject struct that defines member types and returns the unique id.
Definition model_object.hpp:55
uint32_t id
Definition model_object.hpp:56
uint32_t GetId() const
Getter that returns the unique id for parameters in the model.
Definition model_object.hpp:70
bool CheckDimensions(size_t actual, size_t expected)
Check the dimensions of an object.
Definition model_object.hpp:80
std::vector< Type * > random_effects_parameters
Definition model_object.hpp:59
std::vector< Type * > parameters
Definition model_object.hpp:57
std::vector< Type * > fixed_effects_parameters
Definition model_object.hpp:61