WSF
usmtf::USMTF_Factory< T, U > Class Template Reference

Uses of this is highly documented in pretty much every tests Suite. More...

#include <USMTF_Factory.hpp>

Public Types

using ConstructorCb = std::function<std::unique_ptr<T>(const std::string& aType, U aContents)>
 Constructor Callback specifies the expected format of the function needed to instantiate objects.

Public Member Functions

template<class V>
const V * CastIfRegistered (const T &aEntity) noexcept
void RegisterEntity (const std::string &aType, ConstructorCb aCb) noexcept
void UnregisterEntity (const std::string &aType) noexcept
 Unregister a previously registers derived type.
std::unique_ptr< T > CreateInstance (const std::string &aType, U aContents)
 Instantiate an instance of the Set or Message. Used Only by parser.

Static Public Member Functions

static USMTF_Factory< T, U > * GetFactory ()
 Return the singleton instance of the factory.
template<class V>
static std::unique_ptr< V > Construct (const std::string &aType, U &&aContents)

Detailed Description

template<class T, class U>
class usmtf::USMTF_Factory< T, U >

Uses of this is highly documented in pretty much every tests Suite.

Parser uses the factory to construct Sets and Messages uniformly. If Set/Message Types have a constructor registered (ie, opting in to caring about it) then the parser will use it, otherwise it will make the base class for it and move on. This ensures that parsing always succeeds if the file is valid USMTF, but the interpretation of a generic set/message is always left to the custom types to validate, interpret, transform or otherwise use. Its an opt in system, register things you care to validate and use, ignore validating the rest. This allows an immense flexibility where class authors can always use the Abstractions provided by the lib, yet isolate the things they actually care about. This flexibility is important because there may be discrepancies between what the USMTF defines as correct and what an AFSIM idea can use. We don't want to follow the USMTF standard letter by letter if we can only use some of the sets/segments/message/fields defined to create AFSIM entities.

Member Typedef Documentation

◆ ConstructorCb

template<class T, class U>
using usmtf::USMTF_Factory< T, U >::ConstructorCb = std::function<std::unique_ptr<T>(const std::string& aType, U aContents)>

Constructor Callback specifies the expected format of the function needed to instantiate objects.

Member Function Documentation

◆ CastIfRegistered()

template<class T, class U>
template<class V>
const V * usmtf::USMTF_Factory< T, U >::CastIfRegistered ( const T & aEntity)
noexcept

Cast base pointer to derived. Intended for use by Set and Message Authors. It will verify both at run time with dynamic_cast that the relationship is valid. It also verifies at runtime when used that the derived class is registered.

Referenced by usmtf::USMTF_Transformer::ExtractSet().

◆ Construct()

template<class T, class U>
template<class V>
std::unique_ptr< V > usmtf::USMTF_Factory< T, U >::Construct ( const std::string & aType,
U && aContents )
static

Template Function for telling the factory about a derived Message and Set type. Used in conjunction with RegisterEntity. See unit tests for example.

◆ CreateInstance()

template<class T, class U>
std::unique_ptr< T > usmtf::USMTF_Factory< T, U >::CreateInstance ( const std::string & aType,
U aContents )

Instantiate an instance of the Set or Message. Used Only by parser.

◆ GetFactory()

template<class T, class U>
USMTF_Factory< T, U > * usmtf::USMTF_Factory< T, U >::GetFactory ( )
static

Return the singleton instance of the factory.

Export across DLL boundary, ensures singleton functionality.

◆ RegisterEntity()

template<class T, class U>
void usmtf::USMTF_Factory< T, U >::RegisterEntity ( const std::string & aType,
ConstructorCb aCb )
noexcept

Register the type string and constructor functions with the factory. Without registering a derived Message or Set the factory will instantiate the base classes. See unit tests for example.

◆ UnregisterEntity()

template<class T, class U>
void usmtf::USMTF_Factory< T, U >::UnregisterEntity ( const std::string & aType)
noexcept

Unregister a previously registers derived type.


The documentation for this class was generated from the following file:
Copyrights Multiple, All Rights Reserved