ReUseX  0.0.1
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
IModel.hpp
Go to the documentation of this file.
1#pragma once
4#include <filesystem>
5#include <span>
6#include <vector>
7
8namespace ReUseX::vision {
9class IModel {
10 public:
11 // virtual IModel(const std::filesystem::path &path) = 0;
12
13 /* The destructor is declared as virtual to ensure that when an object of a
14 * derived class is deleted through a pointer to the base class (IModel), the
15 * destructor of the derived class is called, allowing for proper cleanup of
16 * resources. This is important in C++ to prevent memory leaks and ensure that
17 * any resources allocated by the derived class are released correctly when
18 * the object is destroyed. */
19 virtual ~IModel() = default;
20
21 /* The create function is a static member function that serves as a factory
22 * method for creating instances of classes that implement the IModel
23 * interface. It takes a file path as an argument, which is likely used to
24 * load a model from a file. The function returns a unique pointer to an
25 * IModel instance, allowing for dynamic memory management and ensuring that
26 * the created model is properly destroyed when it goes out of scope. This
27 * design allows for flexibility in creating different types of models based
28 * on the provided file path, while adhering to the IModel interface.
29 * @param model_path The file path to the model that needs to be created.
30 * @return A unique pointer to an instance of a class that implements the
31 * IModel interface.
32 */
33 static std::unique_ptr<IModel>
34 create(const std::filesystem::path &model_path);
35
36 /* The forward function is a pure virtual function that must be implemented by
37 * any class that inherits from the IModel interface. It takes a span of
38 * IDataset::Pair objects as input and returns a vector of IDataset::Pair
39 * objects as output. This function is likely responsible for performing the
40 * forward pass of the model, processing the input data and producing the
41 * corresponding output. The use of std::span allows for efficient handling of
42 * contiguous sequences of data without the overhead of copying, while the
43 * return type of std::vector provides flexibility in managing the output
44 * data.
45 * @param input A span of IDataset::Pair objects representing the input data
46 * to be processed by the model.
47 * @return A vector of IDataset::Pair objects representing the output produced
48 * by the model after processing the input data.
49 */
50 virtual std::vector<IDataset::Pair>
51 forward(const std::span<IDataset::Pair> &input) = 0;
52
53 // virtual void save(const std::string &path) const = 0;
54 // virtual std::vector<float> predict(const std::vector<float> &input) = 0;
55};
56} // namespace ReUseX::vision
virtual std::vector< IDataset::Pair > forward(const std::span< IDataset::Pair > &input)=0
static std::unique_ptr< IModel > create(const std::filesystem::path &model_path)
virtual ~IModel()=default