// // Created by Marc Rousavy on 22.02.24. // #pragma once #include "HybridObject.hpp" #include #include #include namespace margelo::nitro { class TestHybridObject : public HybridObject { public: explicit TestHybridObject() : HybridObject("TestHybridObject") {} public: int getInt() { return _int; } void setInt(int newValue) { _int = newValue; } std::string getString() { return _string; } void setString(const std::string& newValue) { _string = newValue; } std::optional getNullableString() { return _nullableString; } void setNullableString(std::optional string) { _nullableString = string; } std::unordered_map multipleArguments(int first, bool second, std::string third) { return std::unordered_map{{"first", 5312}, {"second", 532233}, {"third", 2786}}; } std::function getIntGetter() { return [this]() -> int { return this->_int; }; } void sayHelloCallback(std::function callback) { callback("Test Hybrid"); } std::shared_ptr createNewHybridObject() { return std::make_shared(); } void throwError() { throw std::runtime_error("This is an error!"); } uint64_t calculateFibonacci(int count) { if (count <= 0) return 0; if (count == 1) return 1; return calculateFibonacci(count - 1) + calculateFibonacci(count - 2); } std::future calculateFibonacciAsync(int count) { return std::async(std::launch::async, [count, this]() { return this->calculateFibonacci(count); }); } void syncVoidFunc() { // this function does nothing } std::future asyncVoidFunc() { return std::async(std::launch::async, []() { // this function does nothing }); } private: int _int; std::string _string; std::optional _nullableString; void loadHybridMethods() override; }; } // namespace margelo::nitro