9 #include "signalslot.h"
10 #include "corefactory.h"
11 #include "directorywatcher.h"
14 #include <rtti/rtti.h>
15 #include <rtti/objectptr.h>
16 #include <utility/dllexport.h>
17 #include <rtti/unresolvedpointer.h>
18 #include <rtti/factory.h>
19 #include <rtti/deserializeresult.h>
28 class RTTIObjectGraphItem;
29 template<
typename ITEM>
class ObjectGraph;
66 bool loadFile(const std::
string& filename, utility::ErrorState& errorState);
92 bool loadFile(const std::
string& filename, const std::
string& externalChangedFile, utility::ErrorState& errorState);
122 std::vector<rtti::ObjectPtr<T>> getObjects()
const;
142 void checkForFileChanges();
155 void watchDirectory(
const std::string& directory);
168 using InstanceByIDMap = std::unordered_map<std::string, rtti::Object*>;
169 using ObjectByIDMap = std::unordered_map<std::string, std::unique_ptr<rtti::Object>>;
170 using FileLinkMap = std::unordered_map<std::string, std::vector<std::string>>;
172 class OverlayLinkResolver;
174 enum class EFileModified : uint8_t
181 void addObject(
const std::string&
id, std::unique_ptr<rtti::Object>
object);
182 void removeObject(
const std::string&
id);
183 void addFileLink(
const std::string& sourceFile,
const std::string& targetFile);
190 void determineObjectsToInit(
const RTTIObjectGraph& objectGraph,
const ObjectByIDMap& objectsToUpdate,
const std::string& externalChangedFile, std::vector<std::string>& objectsToInit);
191 void buildObjectGraph(
const ObjectByIDMap& objectsToUpdate,
RTTIObjectGraph& objectGraph);
192 EFileModified isFileModified(
const std::string& modifiedFile);
193 void stopAndDestroyAllObjects();
194 void destroyObjects(
const std::unordered_set<std::string>& objectIDsToDelete,
const RTTIObjectGraph& object_graph);
201 struct RollbackHelper final
208 void addExistingDevice(
Device& device);
209 void addNewDevice(
Device& device);
212 ObjectByIDMap& getObjectsToUpdate() {
return mObjectsToUpdate; }
215 void destroyObjects();
218 ResourceManager& mService;
219 ObjectByIDMap mObjectsToUpdate;
220 std::vector<Device*> mExistingDevices;
221 std::vector<Device*> mNewDevices;
222 std::vector<rtti::Object*> mInitializedObjects;
223 bool mRollbackObjects =
true;
226 using ModifiedTimeMap = std::unordered_map<std::string, uint64>;
228 ObjectByIDMap mObjects;
229 std::set<std::string> mFilesToWatch;
230 FileLinkMap mFileLinkMap;
231 std::unique_ptr<DirectoryWatcher> mDirectoryWatcher =
nullptr;
232 ModifiedTimeMap mFileModTimes;
233 std::unique_ptr<CoreFactory> mFactory =
nullptr;
241 std::vector<rtti::ObjectPtr<T>> result;
242 for (
auto& kvp : mObjects)
244 T*
object = rtti_cast<T>(kvp.second.get());
245 if (
object !=
nullptr)
246 result.push_back(
object);