VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtVirtualBaseClassCustomCreator.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (c) 2021 MAK Technologies, Inc.
3  * All rights reserved.
4  ******************************************************************************/
5 
6 #pragma once
7 
8 #include <vrvCore/vrvCore.h>
9 #include <vrvCore/DtDe.h>
10 
11 namespace makVrv
12 {
24  template<class CustomClassToCreate, class BaseCreatorClass, class ...ConstructorArgs>
26  {
27  //std::remove_reference_t is C++14
28  //This defines the class that the original creator created. DtSilverliningGroup would be class from the example above
29  typedef std::remove_reference_t<decltype((*BaseCreatorClass::classToCreateType))> BaseOfClassToCreate;
30 
31  public:
32 
36  {
37  //nop
38  }
39 
46 
47  protected:
51  : BaseCreatorClass(de)
52  {
53  //nop
54  }
55 
56  public:
59  static void registerInstance(DtDe& de)
60  {
61  std::string creatorType = creatorTypeName< BaseOfClassToCreate >();
62  BaseCreatorClass* inst = new DtVirtualBaseClassCustomCreator<CustomClassToCreate, BaseCreatorClass, ConstructorArgs...>(de);
63  de.registerInstance(creatorType, inst);
64  }
65 
66  public:
67 
71  virtual BaseOfClassToCreate* create(ConstructorArgs&&... constructorArgs) override
72  {
73  //Perfect forwarding of the ConstructorArgs
74  //Make sure to use this->myDe to access myDe from the base class in this class. See MAK coding standard for explaination.
75  return new CustomClassToCreate(this->myDe, std::forward<ConstructorArgs>(constructorArgs)...);
76  }
77 
78  };
79 
80 }
static void registerInstance(DtDe &de)
Register an instance of this class with the DtDe, should be called before any DtVirtualBaseClassCreat...
Definition: DtVirtualBaseClassCustomCreator.h:59
Variadic templated creator class for creating a custom version of a DtVirtualBaseClassCreator This cl...
Definition: DtVirtualBaseClassCustomCreator.h:25
Contains makVrv::DtDe class.
DtVirtualBaseClassCustomCreator & operator=(const DtVirtualBaseClassCustomCreator &other)=delete
Assignment Operator Not implemented – Assignment Not Allowed.
DtVirtualBaseClassCustomCreator()=delete
not allowed
std::remove_reference_t< decltype((*BaseCreatorClass::classToCreateType))> BaseOfClassToCreate
Definition: DtVirtualBaseClassCustomCreator.h:29
DtVirtualBaseClassCustomCreator(DtDe &de)
CTOR calls the base creator class constructor Defining functions in the class declaration since it is...
Definition: DtVirtualBaseClassCustomCreator.h:50
virtual void registerInstance(const std::string &instanceName, DtVirtualBaseClass *instance)
Register an instance with a given name for later retrieval.
virtual BaseOfClassToCreate * create(ConstructorArgs &&...constructorArgs) override
Create a DtVirtualBaseClassCustomCreator object, calls CustomClassToCreate constructor with myDe and ...
Definition: DtVirtualBaseClassCustomCreator.h:71
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
virtual ~DtVirtualBaseClassCustomCreator()
DTOR Defining functions in the class declaration since it is more clear than the inline templated cod...
Definition: DtVirtualBaseClassCustomCreator.h:35
Contains DLL export macros.

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)