Code: Select all
'winrt::Simply_Sense::implementation::SensorPage': cannot instantiate abstract class.
Code: Select all
//this object gives me the error
winrt::Simply_Sense::implementation::SensorPage sensorPage;
//this is the header file with the class
namespace winrt::Simply_Sense::implementation
{
struct SensorPage : SensorPageT
{
public:
SensorPage();
int32_t MyProperty();
void MyProperty(int32_t value);
void initialize();
void LoadHtmlFile(const std::string& sensordata);
void OnPageLoaded(winrt::Windows::Foundation::IInspectable const&, winrt::Microsoft::UI::Xaml::RoutedEventArgs const&);
void Back_Button_View(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::RoutedEventArgs const& e);
private:
Token_model tokenModel;
int32_t m_myProperty;
};
}
namespace winrt::Simply_Sense::factory_implementation
{
struct SensorPage : SensorPageT
{
};
}
//This is the code for getting the api response
std::string Token_model::getSensorMap(const std::string& refreshToken)
{
std::string sensorMapData;
try
{
std::string device_id = "8de6f55e-dbe6-4a5b-ba7e-93e12c114972";
OutputDebugStringA(("Device id = " + device_id + "\n").c_str());
sensorMapData = performGetWebView("https://beta.simplysense.nl/api/device-groups/view/" + device_id, refreshToken);
OutputDebugStringA(("Sensordata: " + sensorMapData + "\n").c_str());
winrt::Simply_Sense::implementation::SensorPage sensorPage;
writeHtmlToFile(sensorMapData, "C:/xampp/htdocs/sensorpage.html");
}
catch (const std::exception& e)
{
OutputDebugStringA(e.what());
throw;
}
if (!sensorMapData.empty())
{
return sensorMapData;
}
else
{
throw std::runtime_error("Het is niet gelukt om de response te decoderen! sensormap\n");
}
}
//function for loading the api response in webview
void SensorPage::LoadHtmlFile(const std::string& sensordata)
{
try {
std::string htmlContent = "Hello world!!!";
std::string dataUri = "data:text/html;charset=utf-8, " + htmlContent;
if (MyWebView())
{
MyWebView().Source(winrt::Windows::Foundation::Uri(winrt::to_hstring(dataUri)));
}
else
{
throw std::runtime_error("MyWebView is not initialized.");
}
}
catch (const std::exception& e)
{
OutputDebugStringA(e.what());
}
}