NAP
defaultlinkresolver.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 #include "rttiutilities.h"
8 #include "linkresolver.h"
9 #include "deserializeresult.h"
10 #include <unordered_map>
11 
12 namespace nap
13 {
14  namespace rtti
15  {
19  class NAPAPI DefaultLinkResolver : public LinkResolver
20  {
21  public:
22  DefaultLinkResolver(const OwnedObjectList& objects);
23 
27  static bool sResolveLinks(const OwnedObjectList& objects, const UnresolvedPointerList& unresolvedPointers, utility::ErrorState& errorState);
28 
29  private:
30  virtual Object* findTarget(const std::string& targetID) override;
31  virtual EInvalidLinkBehaviour onInvalidLink(const UnresolvedPointer& unresolvedPointer) override;
32 
33  private:
34  using ObjectsByIDMap = std::unordered_map<std::string, rtti::Object*>;
35  ObjectsByIDMap mObjectsByID; // Objects stored by ID, used for lookup
36  };
37  }
38 }
nap::rtti::Object
Definition: object.h:30
nap::utility::ErrorState
Definition: errorstate.h:19
nap::rtti::UnresolvedPointer
Definition: unresolvedpointer.h:28
nap
Definition: templateapp.h:17
nap::rtti::UnresolvedPointerList
std::vector< UnresolvedPointer > UnresolvedPointerList
Definition: unresolvedpointer.h:51
nap::rtti::OwnedObjectList
std::vector< std::unique_ptr< rtti::Object > > OwnedObjectList
Definition: deserializeresult.h:33