VR-Exchange 2.5 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
rprTranslator.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 // Disable warning about missing operators.
13 // Comparison and assignment operators are declared but not defined
14 // to prevent their usage, but this causes a warning in template classes.
15 #pragma warning( disable : 4661 )
16 
17 #include <rprBroker/dllExport.h>
19 
22 
25 
26 // All RPR Translators must have the following template arguments:
27 // The integer define of the DtPortalMessageKind,
28 // The PortalObject this message translates,
29 // The Reflected Portal Object class the message translates
30 // The Reflected RPR Object class
31 // The reflected list of objects
32 // The state repository class of the RPR Object
33 // The publisher class of the RPR Object
34 #define RPR_TEMPLATE_LIST \
35  template \
36  < class T_PortalObject \
37  , class T_PortalReflectedObject \
38  , class T_RprReflectedObject \
39  , class T_RprReflectedObjectList \
40  , class T_RprObjectStateRepository \
41  , class T_RprObjectPublisher>
42 
43 #define RPR_TEMPLATE_FUNCTION \
44  T_PortalObject, T_PortalReflectedObject, \
45  T_RprReflectedObject, T_RprReflectedObjectList, \
46  T_RprObjectStateRepository, T_RprObjectPublisher
47 
49 #define DtVrxCATCH_AND_WARN( exception ) \
50  catch ( exception ) \
51  { \
52  DtWarn << this->name() << " Translator caught " << #exception \
53  << " when sending interaction." << std::endl; \
54  }
55 
56 class DtInteraction;
57 class DtReflectedObject;
58 class DtStateRepository;
59 
60 namespace MAKVrExchange
61 {
62 
63  class DtRequestTranslationDiagnosticMessage;
64 
65  namespace DtRprBroker
66  {
67 
68  class DtRprBroker;
69 
94  : public DtBaseObjectTranslator<T_PortalObject,T_PortalReflectedObject>
95  {
96  public:
97 
99  typedef enum
100  {
101  none = 0,
102  discover = 1,
103  update = 2,
104  remove = 3
105  } UpdateType;
106 
109 
110  public:
111 
114  const DtString& name, DtPortalMessageKind kind );
115 
117  virtual ~DtRprObjectTranslator();
118 
120  virtual void enableReflectTranslator( bool enabled );
121 
124  virtual void forceUpdateAll();
125 
127  virtual void tick();
128 
129  virtual DtRprBroker* rprBroker();
130  virtual const DtRprBroker* rprBroker() const;
131 
133  virtual void shutdown();
134 
135  protected:
136 
139 
140  virtual void initializeRprCallbacks();
141  virtual void removeRprCallbacks();
142 
144 
147 
149  virtual DtBrokerObject* createBrokerObject( const DtReflectedObject* refObj );
151 
154  virtual DtBrokerObject* findBrokerObject( const DtReflectedObject* refObj );
155  virtual DtBrokerObject* findBrokerObject( const DtPortalReflectedObject* refObj );
156 
159  virtual DtBrokerObject* findBrokerObject( const DtString& objectName );
160 
164  virtual DtBrokerObject* releaseBrokerObject( const DtReflectedObject* refObj );
166 
168 
171 
174  static bool rprDiscoveryCriteria( DtReflectedObject* refObj, void* usr );
175 
177  static void rprObjectAddedCb( T_RprReflectedObject* refObj, void* usr );
178 
180  static void rprObjectUpdatedCb( T_RprReflectedObject* refObj, void* usr );
181 
183  static void rprObjectDeletedCb( T_RprReflectedObject* refObj, void* usr );
184 
186 
189 
192  virtual bool isPortalDiscoverable( const DtPortalReflectedObject* refObj );
193 
196  virtual bool isRprPublishable( DtBrokerObject* brokerObj,
197  const T_PortalReflectedObject* refObj );
198 
200 
203 
206  virtual bool isRprDiscoverable( const DtReflectedObject* refObj );
207 
209 
218 
219  virtual void discoverRprObject( T_RprReflectedObject& obj );
220  virtual void discoverPortalObject( const T_PortalReflectedObject& obj );
221 
223 
231 
232  virtual void createRprPublisher( DtBrokerObject* brokerObj );
233 
239  virtual DtString rprObjectName( const T_PortalReflectedObject* refObj ) const;
240 
249  virtual T_RprObjectPublisher* instantiateRprPublisher(
250  const T_PortalReflectedObject* refObj, const DtString& name );
251 
257  virtual void fillOutgoingIds( T_RprObjectPublisher* publisher,
258  const DtString& name );
259 
260  virtual void createPortalPublisher( DtBrokerObject* brokerObj );
261 
263 
272 
273  virtual void receiveRprUpdate( T_RprReflectedObject& obj );
274  virtual void receivePortalUpdate( const T_PortalReflectedObject& obj );
275 
277 
286 
287  virtual void updateRprBrokerObject( DtBrokerObject* brokerObj,
288  const T_RprObjectStateRepository& sr );
289  virtual void updatePortalBrokerObject( DtBrokerObject* brokerObj,
290  const T_PortalObject& sr );
291 
300  virtual void updateFilteredState( DtBrokerObject* brokerObj,
302  T_RprReflectedObject* refObj );
303 
308  virtual bool filterLocation( const DtReflectedObject& refObj,
309  const DtVector& location );
310 
312 
316 
317  virtual void removeRprObject( const DtReflectedObject& refObj );
318  virtual void removePortalObject( const T_PortalReflectedObject& refObj );
319 
321 
326 
327  virtual void deleteRprPublisher( DtBrokerObject* brokerObj );
328  virtual void deletePortalPublisher( DtBrokerObject* brokerObj );
329 
331 
333  static void requestTransDiagCb( const DtRequestTranslationDiagnosticMessage& msg, void* usr );
334 
337 
339  virtual void printIncomingOutgoingStateReps(
340  const DtPortalObject& incoming, const DtStateRepository& outgoing ) const;
341 
343  virtual void printIncomingOutgoingStateReps(
344  const DtStateRepository& incoming, const DtPortalObject& outgoing ) const;
345 
349  virtual void performPortalDebugging( const DtString& objectName );
350 
352  virtual void performPortalDebugging( const DtPortalObject& incoming,
353  const DtStateRepository& outgoing );
354 
356  virtual void performPortalDebugging( const DtStateRepository& incoming,
357  const DtPortalObject& outgoing );
358 
360  virtual unsigned int numObjects() const;
361 
362  public:
363 
366  virtual T_PortalObject* translate( T_PortalObject* destination,
367  const T_RprObjectStateRepository& source,
368  const T_RprReflectedObject& refObj ) = 0;
369 
372  virtual T_RprObjectStateRepository* translate(
373  T_RprObjectStateRepository* destination, const T_PortalObject& source,
374  const T_PortalReflectedObject& refObj ) = 0;
375 
376  private:
377 
380 
383 
385  bool operator == ( const DtRprObjectTranslator& rightOperand ) const;
386 
388  bool operator != ( const DtRprObjectTranslator& rightOperand ) const;
389 
390  protected:
391 
392  T_RprReflectedObjectList* myRprReflectedList;
393 
394  typedef std::pair<DtTime,bool> LocationFilteringInfo;
395  typedef std::map<const DtReflectedObject*,LocationFilteringInfo> LocationFilteringMap;
397 
398  typedef std::map<const DtReflectedObject*,DtBrokerObject*> RprToPortalReflectedMap;
399  typedef std::map<const DtPortalReflectedObject*,DtBrokerObject*> PortalToRprReflectedMap;
400 
403 
404  typedef std::set<DtString> TransDebugObjectNamesSet;
406 
408 
409  };
410 
411 
428  template <class PortalInterType,class RprInterType>
430  : public DtBaseInteractionTranslator<PortalInterType>
431  {
432  public:
433 
436 
437  public:
438 
441  const DtString& name, DtPortalMessageKind kind );
442 
444  virtual ~DtRprInteractionTranslator();
445 
447  virtual void enableReflectTranslator( bool enabled );
448 
449  virtual DtRprBroker* rprBroker();
450  virtual const DtRprBroker* rprBroker() const;
451 
453  virtual void shutdown();
454 
455  protected:
456 
459 
460  virtual void initializeRprCallbacks();
461  virtual void removeRprCallbacks();
462 
464 
468 
469  static void receiveRprInteraction( RprInterType* inter, void* usr );
470 
472 
480 
481  virtual void createInteraction( const PortalInterType& inter );
482  virtual void createPortalInteraction( const RprInterType& inter );
483 
485 
488  virtual PortalInterType* translate( PortalInterType* destination,
489  const RprInterType& source ) = 0;
490 
493  virtual RprInterType* translate( RprInterType* destination,
494  const PortalInterType& source ) = 0;
495 
497  virtual void printIncomingOutgoingInteractions( const DtPortalInteraction& incoming,
498  const DtInteraction& outgoing ) const;
499 
501  virtual void printIncomingOutgoingInteractions( const DtInteraction& incoming,
502  const DtPortalInteraction& outgoing ) const;
503 
504  private:
505 
508 
511 
513  bool operator == ( const DtRprInteractionTranslator& rightOperand ) const;
514 
516  bool operator != ( const DtRprInteractionTranslator& rightOperand ) const;
517 
518  };
519 
520  }
521 }
522 
523 #define _rprTranslator_INL_
524 #include <rprBroker/rprTranslator.inl>
525 #undef _rprTranslator_INL_

Document ID: Generated on Wed Dec 21 15:05:11 EST 2016 from SVN revision 171891
Copyright © 2005-2016 VT MÄK. All Rights Reserved (www.mak.com)