VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtExampleThreadedDriver.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2019 MAK Technologies, Inc.
3  * All rights reserved.
4  *****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvCore/DtDriver.h>
13 
15 
18 
19 #include <vlutil/vlRunnable.h>
20 
21 #include <boost/function.hpp>
22 #include <boost/signal.hpp>
23 #include <vlutil/vlThread.h>
24 
25 #include <string>
26 
27 namespace makVrv
28 {
29  class DtAsynchronousAgentManager;
30  class DtAsynchronousEventQueue;
31 }
32 
33 class DtThread;
34 class DtThreadStart;
36 
37 // This driver creates and owns the example driver.
40 {
41 public:
44 
46  virtual ~DtExampleThreadedDriver();
47 
49  virtual const std::string& className() const;
50 
52  virtual void queueDriverFunction(const boost::function<void ()>& function);
53 
55  virtual void queueConnectionFunction(const boost::function<void ()>& function);
56 
59  bool useThreadFlag() const;
60 
64 
66  boost::signal<void (DtExampleSimulationConnection*)> signal_simulationCreated;
67 
69  boost::signal<void (DtExampleSimulationConnection*)> signal_simulationAboutToBeDestroyed;
70 
71 protected:
72 
75  virtual bool onStart();
76 
79  virtual bool onStop();
80 
83  virtual bool onTick();
84 
89  virtual void attachObserverToEntity( const std::string& entityName );
90 
93  virtual void slot_displayEngineAdded( const makVrv::DtDeRecord& igRecord );
94 
97 
99  virtual void run();
100 
103  void startThread();
104 
107  void stopThread();
108 
110  void setSimulationConnectionState( bool state );
111 
113  virtual void connectToDynamicSignals();
114 
117  virtual void disconnectFromDynamicSignals();
118 
120  virtual void slot_togglePinnedLabel(
122 
124  typedef std::vector<boost::function<void ()> > FunctionCallList;
125 
127  virtual void runFunctionQueue(FunctionCallQueue& queue);
128 
129 protected:
130  //Main thread variables.
131  std::string myClassName;
132 
134  bool myUseThreadFlag;
137  DtThreadStartSP myStart;
138  DtThread* myThread;
143 
147 
149 };
DtThreadStartSP myStart
Definition: DtExampleThreadedDriver.h:137
An asynchronous interface to the scene manager.
Definition: DtAsynchronousAgentManager.h:27
virtual void attachObserverToEntity(const std::string &entityName)
Tells the current observer to attach to the named entity.
virtual bool onStart()
Performs startup logic for the driver.
DtExampleSimulationConnection * mySimulationConnection
Definition: DtExampleThreadedDriver.h:144
A Record of an IG instance.
Definition: DtDeRecord.h:24
void stopThread()
Attempt to stop the thread, blocking until the thread stops.
Contains makVrv:DtSelectionManager class.
DtThread * myThread
Definition: DtExampleThreadedDriver.h:138
virtual ~DtExampleThreadedDriver()
Virtual DTOR.
bool useThreadFlag() const
See if this driver is running connection methods in a separate thread.
Contains makVrv::DtLockedBufferedQueue class.
virtual void queueConnectionFunction(const boost::function< void()> &function)
Put a function in the sim function queue, for threadsafe calling.
virtual void queueDriverFunction(const boost::function< void()> &function)
Put a function in the sim function queue, for threadsafe calling.
void startThread()
Attempt to start the thread.
makVrv::DtAsynchronousEventQueue * myAsynchronousEventQueue
Definition: DtExampleThreadedDriver.h:145
boost::signal< void(DtExampleSimulationConnection *)> signal_simulationAboutToBeDestroyed
This signal is emitted when the simulation connection is about to be destroyed.
Definition: DtExampleThreadedDriver.h:69
virtual const std::string & className() const
Get this instance&#39;s class name.
Definition: DtExampleThreadedDriver.h:39
virtual void run()
Function that will be called when the thread is started.
A locked buffered queue which allows multiple writers and a single reader.
Definition: DtLockedBufferedQueue.h:27
bool mySimulationConnectionState
Definition: DtExampleThreadedDriver.h:146
The DtDriver is an abstract class.
Definition: DtDriver.h:34
std::vector< boost::function< void()> > FunctionCallList
Definition: DtExampleThreadedDriver.h:124
virtual bool onTick()
Performs update logic for the driver.
DtExampleThreadedDriver(makVrv::DtAgentManager &am)
CTOR.
FunctionCallQueue myDriverThreadFunctions
Definition: DtExampleThreadedDriver.h:140
The asynchronous event queue.
Definition: DtAsynchronousEventQueue.h:27
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:24
virtual void connectToDynamicSignals()
Connect to signals.
virtual void runFunctionQueue(FunctionCallQueue &queue)
Execute a function queue.
virtual void disconnectFromDynamicSignals()
Disconnect to any signals connected to in connectToDynamicSignals()
DtExampleSimulationConnection * simulationConnection()
Get the simulation connection.
The DtAgentManager manages the distributed scene object framework.
Definition: DtAgentManager.h:38
Contains makVrv:DtDriver class.
virtual void slot_togglePinnedLabel(const makVrv::DtSelectionManager::IdSet &sel)
Listens for entity labels being pinned / unpinned.
void setSimulationConnectionState(bool state)
Set the connection state of the driver.
std::string myClassName
Definition: DtExampleThreadedDriver.h:131
Base class to provide boost signal/slot management.
DtExampleSimulationConnection.
Definition: DtExampleSimulationConnection.h:35
virtual DtExampleSimulationConnection * createSimulationConnection()
Abstract create simulation function called onStart.
boost::signal< void(DtExampleSimulationConnection *)> signal_simulationCreated
This signal is emitted when the simulation connection is created.
Definition: DtExampleThreadedDriver.h:66
makVrv::DtSignalConnectionManager myDynamicSignals
Definition: DtExampleThreadedDriver.h:148
FunctionCallQueue myConnectionThreadFunctions
Definition: DtExampleThreadedDriver.h:139
makVrv::DtLockedBufferedQueue< boost::function< void()> > FunctionCallQueue
Definition: DtExampleThreadedDriver.h:123
makVrv::DtAsynchronousAgentManager * myAsynchronousInterface
Definition: DtExampleThreadedDriver.h:141
bool myUseThreadFlag
Cross thread variables.
Definition: DtExampleThreadedDriver.h:136
std::set< DtUniqueID > IdSet
Definition: DtSelectionManager.h:32
virtual void slot_displayEngineAdded(const makVrv::DtDeRecord &igRecord)
Ensures the driver is properly restarted when a de is connected.
virtual bool onStop()
Performs shutdown logic for the driver.

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)