8 #include "modulemanager.h"
9 #include "resourcemanager.h"
11 #include "coreextension.h"
12 #include "projectinfo.h"
16 #include <rtti/factory.h>
17 #include <rtti/rtti.h>
18 #include <rtti/deserializeresult.h>
19 #include <unordered_set>
20 #include <utility/dllexport.h>
21 #include <unordered_map>
25 inline constexpr
char DEFAULT_SERVICE_CONFIG_FILENAME[] =
"config.json";
26 inline constexpr
char PROJECT_INFO_FILENAME[] =
"app.json";
29 #define STRINGIZE(x) #x
30 #define STRINGIZE_VALUE_OF(x) STRINGIZE(x)
31 inline constexpr
char sBuildConf[] = STRINGIZE_VALUE_OF(NAP_BUILD_CONF);
32 inline constexpr
char sBuildType[] = STRINGIZE_VALUE_OF(NAP_BUILD_TYPE);
33 inline constexpr
char sBuildArch[] = STRINGIZE_VALUE_OF(NAP_BUILD_ARCH);
102 Core(std::unique_ptr<CoreExtension> coreExtension);
161 bool isInitialized()
const;
181 double update(std::function<
void(
double)>& updateFunction);
202 double getElapsedTime()
const;
233 Service* getService(
const std::string& type);
244 template <
typename T>
256 template <
typename T>
257 const T* getService()
const;
265 template <
typename T>
266 const T& getExtension()
const;
271 template <
typename T>
272 bool hasExtension()
const;
281 bool findProjectFilePath(
const std::string& filename, std::string& foundFilePath)
const;
296 bool writeConfigFile(
const std::string& path,
utility::ErrorState& errorState,
bool linkToProjectInfo =
true);
302 std::vector<const ServiceConfiguration*> getServiceConfigs()
const;
307 void setupPlatformSpecificEnvironment();
344 bool mInitialized =
false;
353 bool findProjectInfoFile(std::string& foundFilePath)
const;
400 void preResourcesLoaded();
407 void postResourcesLoaded();
412 void calculateFramerate(
double deltaTime);
418 void setupPythonEnvironment();
442 bool addServiceConfig(std::unique_ptr<nap::ServiceConfiguration> serviceConfig);
445 std::unique_ptr<ModuleManager> mModuleManager =
nullptr;
448 std::unique_ptr<ResourceManager> mResourceManager =
nullptr;
451 std::unique_ptr<nap::ProjectInfo> mProjectInfo =
nullptr;
454 std::vector<std::unique_ptr<Service>> mServices;
457 std::unordered_map<rtti::TypeInfo, std::unique_ptr<ServiceConfiguration>> mServiceConfigs;
460 std::unique_ptr<CoreExtension> mExtension =
nullptr;
469 float mFramerate = 0.0f;
472 std::array<double, 20> mTicks = { 0 };
477 bool mInitialized =
false;
480 nap::Slot<> mPreResourcesLoadedSlot = { [&]() ->
void { preResourcesLoaded(); } };
483 nap::Slot<> mPostResourcesLoadedSlot = { [&]() ->
void { postResourcesLoaded(); } };
494 template <
typename T>
497 return static_cast<T*
>(
getService(RTTI_OF(T)));
504 template <
typename T>
507 return static_cast<const T*
>(getService(RTTI_OF(T)));
514 template <
typename T>
517 T* core_ext = rtti_cast<T>(mExtension.get());
518 assert(core_ext !=
nullptr);
526 template <
typename T>
529 return rtti_cast<T>(mExtension.get()) !=
nullptr;