↰ Return to documentation for file (include/networkit/base/Algorithm.hpp
)
#ifndef NETWORKIT_BASE_ALGORITHM_HPP_
#define NETWORKIT_BASE_ALGORITHM_HPP_
#include <stdexcept>
#include <string>
namespace NetworKit {
class Algorithm {
protected:
bool hasRun = false;
public:
virtual ~Algorithm() = default;
virtual void run() = 0;
bool hasFinished() const noexcept { return hasRun; }
void assureFinished() const {
if (!hasRun)
throw std::runtime_error("Error, run must be called first");
}
};
} // namespace NetworKit
#endif // NETWORKIT_BASE_ALGORITHM_HPP_