16 template <
typename RESOURCE,
typename FACTORY>
20 typedef std::function<TTV_ErrorCode(const std::shared_ptr<FACTORY>& factory, std::shared_ptr<RESOURCE>& result)>
CreateFunc;
21 typedef std::function<bool(const std::shared_ptr<FACTORY>& factory)>
QueryFunc;
36 if (factory ==
nullptr)
40 return TTV_EC_INVALID_ARG;
43 auto iter = std::find(
mChain.begin(),
mChain.end(), factory);
48 return TTV_EC_INVALID_ARG;
53 return TTV_EC_SUCCESS;
58 if (factory ==
nullptr)
62 return TTV_EC_INVALID_ARG;
65 auto iter = std::find(
mChain.begin(),
mChain.end(), factory);
70 return TTV_EC_INVALID_ARG;
75 return TTV_EC_SUCCESS;
85 return TTV_EC_NO_FACTORIES_REGISTERED;
90 for (
const auto& factory : copy)
99 if (result !=
nullptr)
101 return TTV_EC_SUCCESS;
105 return TTV_EC_UNIMPLEMENTED;
113 for (
const auto& factory : copy)
115 if (queryFunc(factory))
141 std::vector<std::shared_ptr<FACTORY>>
mChain;
virtual TTV_ErrorCode Register(const std::shared_ptr< FACTORY > &factory)
Definition: resourcefactorychain.h:34
ResourceFactoryChain(const std::string &name)
Definition: resourcefactorychain.h:24
std::function< bool(const std::shared_ptr< FACTORY > &factory)> QueryFunc
Definition: resourcefactorychain.h:21
Definition: tracingtypes.h:19
JSON (JavaScript Object Notation).
Definition: adsapi.h:16
#define TTV_SUCCEEDED(ec)
Definition: errortypes.h:230
void Message(const char *component, const TTV_MessageLevel messageLevel, const char *format,...)
virtual TTV_ErrorCode Unregister(const std::shared_ptr< FACTORY > &factory)
Definition: resourcefactorychain.h:56
virtual ~ResourceFactoryChain()
Definition: resourcefactorychain.h:30
std::vector< std::shared_ptr< FACTORY > > mChain
Definition: resourcefactorychain.h:141
void SetRegisteredDefaults()
Definition: resourcefactorychain.h:124
uint32_t TTV_ErrorCode
Definition: errortypes.h:30
Definition: resourcefactorychain.h:17
bool RegisteredDefaults() const
Definition: resourcefactorychain.h:129
bool Empty() const
Definition: resourcefactorychain.h:134
bool BoolQuery(const QueryFunc &queryFunc) const
Definition: resourcefactorychain.h:109
bool mRegisteredDefaults
Definition: resourcefactorychain.h:142
virtual TTV_ErrorCode Create(const CreateFunc &createFunc, std::shared_ptr< RESOURCE > &result) const
Definition: resourcefactorychain.h:78
std::function< TTV_ErrorCode(const std::shared_ptr< FACTORY > &factory, std::shared_ptr< RESOURCE > &result)> CreateFunc
Definition: resourcefactorychain.h:20
std::string mName
Definition: resourcefactorychain.h:140