VR-Exchange 2.7 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pMessageFactory.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2016 VT MAK
3  * All rights reserved.
4  ****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <portal/pMessage.h>
13 
14 namespace MAKVrExchange
15 {
16 
23  {
24  public:
25 
28 
30  virtual ~DtPortalMessageFactory();
31 
35  DtPortalMessage* create( const void* message, unsigned int messageSize ) const;
36 
45  template <typename T_Message>
46  void registerCreator( const T_Message& msg );
47 
48  typedef DtPortalMessage *(*ShmMessageCreator)();
49  void registerCreator( const DtPortalMessageKind& kind, const ShmMessageCreator& creator );
50 
51  private:
52 
55 
57  DtPortalMessageFactory& operator = ( const DtPortalMessageFactory& );
58 
59  protected:
60 
61  typedef std::map<DtPortalMessageKind,ShmMessageCreator> KindCreateFunctionMap;
63 
64  };
65 
66 
67  template <typename T_Message>
68  inline void DtPortalMessageFactory::registerCreator( const T_Message& )
69  {
70  myCreatorFunctionMap[T_Message::theKind] = T_Message::create;
71  }
72 
74  const DtPortalMessageKind& kind, const ShmMessageCreator& creator )
75  {
76  myCreatorFunctionMap[kind] = creator;
77  }
78 
79 }
#define DT_DLL_LIBPORTAL
Definition: include/portal/dllExport.h:20
Contains the DtPortalMessage class declaration.
The base class for all messages passed through the portal.
Definition: pMessage.h:65
std::map< DtPortalMessageKind, ShmMessageCreator > KindCreateFunctionMap
Definition: pMessageFactory.h:61
This factory creates DtPortalMessage instances from a byte array.
Definition: pMessageFactory.h:22
KindCreateFunctionMap myCreatorFunctionMap
Definition: pMessageFactory.h:62
void registerCreator(const T_Message &msg)
registers a message creator function with the factory.
Definition: pMessageFactory.h:68
DtPortalMessageKind
A List of message kinds distributed with the Portal.
Definition: pMessageKinds.h:23

Document ID: Generated on Mon Apr 19 15:55:22 EDT 2021 from SVN revision 227909
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)