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;
176 double update(std::function<
void(
double)>& updateFunction);
197 double getElapsedTime()
const;
228 Service* getService(
const std::string& type);
239 template <
typename T>
251 template <
typename T>
252 const T* getService()
const;
260 template <
typename T>
261 const T& getExtension()
const;
269 template <
typename T>
275 template <
typename T>
276 bool hasExtension()
const;
285 bool findProjectFilePath(
const std::string& filename, std::string& foundFilePath)
const;
300 bool writeConfigFile(
const std::string& path,
utility::ErrorState& errorState,
bool linkToProjectInfo =
true);
306 std::vector<const ServiceConfiguration*> getServiceConfigs()
const;
311 void setupPlatformSpecificEnvironment();
348 bool mInitialized =
false;
357 bool findProjectInfoFile(std::string& foundFilePath)
const;
404 void preResourcesLoaded();
411 void postResourcesLoaded();
416 void calculateFramerate(
double deltaTime);
440 bool addServiceConfig(std::unique_ptr<nap::ServiceConfiguration> serviceConfig,
utility::ErrorState& error);
443 std::unique_ptr<ModuleManager> mModuleManager =
nullptr;
446 std::unique_ptr<ResourceManager> mResourceManager =
nullptr;
449 std::unique_ptr<nap::ProjectInfo> mProjectInfo =
nullptr;
452 std::vector<std::unique_ptr<Service>> mServices;
455 std::unordered_map<rtti::TypeInfo, std::unique_ptr<ServiceConfiguration>> mServiceConfigs;
458 std::unique_ptr<CoreExtension> mExtension =
nullptr;
467 float mFramerate = 0.0f;
470 std::array<double, 20> mTicks = { 0 };
475 bool mInitialized =
false;
478 nap::Slot<> mPreResourcesLoadedSlot = { [&]() ->
void { preResourcesLoaded(); } };
481 nap::Slot<> mPostResourcesLoadedSlot = { [&]() ->
void { postResourcesLoaded(); } };
492 template <
typename T>
495 return static_cast<T*
>(
getService(RTTI_OF(T)));
502 template <
typename T>
505 return static_cast<const T*
>(getService(RTTI_OF(T)));
512 template <
typename T>
515 T* core_ext = rtti_cast<T>(mExtension.get());
516 assert(core_ext !=
nullptr);
524 template <
typename T>
527 T* core_ext = rtti_cast<T>(mExtension.get());
528 assert(core_ext !=
nullptr);
536 template <
typename T>
539 return rtti_cast<T>(mExtension.get()) !=
nullptr;