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[] =
"project.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;
304 bool writeConfigFile(
const std::string& path,
utility::ErrorState& errorState,
bool linkToProjectInfo =
true);
310 std::vector<const ServiceConfiguration*> getServiceConfigs()
const;
315 void setupPlatformSpecificEnvironment();
352 bool mInitialized =
false;
361 bool findProjectInfoFile(std::string& foundFilePath)
const;
408 void preResourcesLoaded();
415 void postResourcesLoaded();
420 void calculateFramerate(
double deltaTime);
426 void setupPythonEnvironment();
450 bool addServiceConfig(std::unique_ptr<nap::ServiceConfiguration> serviceConfig);
453 std::unique_ptr<ModuleManager> mModuleManager =
nullptr;
456 std::unique_ptr<ResourceManager> mResourceManager =
nullptr;
459 std::unique_ptr<nap::ProjectInfo> mProjectInfo =
nullptr;
462 std::vector<std::unique_ptr<Service>> mServices;
465 std::unordered_map<rtti::TypeInfo, std::unique_ptr<ServiceConfiguration>> mServiceConfigs;
468 std::unique_ptr<CoreExtension> mExtension =
nullptr;
477 float mFramerate = 0.0f;
480 std::array<double, 20> mTicks = { 0 };
485 bool mInitialized =
false;
488 nap::Slot<> mPreResourcesLoadedSlot = { [&]() ->
void { preResourcesLoaded(); } };
491 nap::Slot<> mPostResourcesLoadedSlot = { [&]() ->
void { postResourcesLoaded(); } };
502 template <
typename T>
505 return static_cast<T*
>(
getService(RTTI_OF(T)));
512 template <
typename T>
515 return static_cast<const T*
>(getService(RTTI_OF(T)));
522 template <
typename T>
525 T* core_ext = rtti_cast<T>(mExtension.get());
526 assert(core_ext !=
nullptr);
534 template <
typename T>
537 return rtti_cast<T>(mExtension.get()) !=
nullptr;