SLProject  4.3.020
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SENSDummyGps Class Reference

#include <SENSGps.h>

Inheritance diagram for SENSDummyGps:
[legend]

Public Member Functions

 SENSDummyGps ()
 
 ~SENSDummyGps ()
 
bool start () override
 
void stop () override
 
void addDummyPos (SENSGps::Location loc)
 
- Public Member Functions inherited from SENSGps
virtual ~SENSGps ()
 
Location getLocation () const
 
bool isRunning ()
 
bool permissionGranted () const
 
void registerListener (SENSGpsListener *listener)
 
void unregisterListener (SENSGpsListener *listener)
 
void registerPermissionListener (std::function< void(void)> listener)
 
void updatePermission (bool granted)
 

Private Member Functions

void startSimulation ()
 
void stopSimulation ()
 
void run ()
 

Private Attributes

std::thread _thread
 
std::atomic_bool _stop {false}
 
std::vector< SENSGps::Location_dummyLocs
 

Additional Inherited Members

- Protected Member Functions inherited from SENSGps
void setLocation (SENSGps::Location location)
 
void informPermissionListeners ()
 
- Protected Attributes inherited from SENSGps
bool _running = false
 
std::atomic_bool _permissionGranted {false}
 

Detailed Description

Definition at line 68 of file SENSGps.h.

Constructor & Destructor Documentation

◆ SENSDummyGps()

SENSDummyGps::SENSDummyGps ( )
inline

Definition at line 71 of file SENSGps.h.

72  {
73  _permissionGranted = true;
74  }
std::atomic_bool _permissionGranted
Definition: SENSGps.h:47

◆ ~SENSDummyGps()

SENSDummyGps::~SENSDummyGps ( )

Definition at line 79 of file SENSGps.cpp.

80 {
82 }
void stopSimulation()
Definition: SENSGps.cpp:108

Member Function Documentation

◆ addDummyPos()

void SENSDummyGps::addDummyPos ( SENSGps::Location  loc)
inline

Definition at line 80 of file SENSGps.h.

81  {
82  _dummyLocs.push_back(loc);
83  }
std::vector< SENSGps::Location > _dummyLocs
Definition: SENSGps.h:93

◆ run()

void SENSDummyGps::run ( )
private

Definition at line 115 of file SENSGps.cpp.

116 {
117  int i = 0;
118  while (true)
119  {
120  std::this_thread::sleep_for(std::chrono::seconds(1));
121  if (_stop)
122  break;
123 
124  i++;
125  i = i % _dummyLocs.size();
126 
128  }
129 }
std::atomic_bool _stop
Definition: SENSGps.h:91
void setLocation(SENSGps::Location location)
Definition: SENSGps.cpp:11

◆ start()

bool SENSDummyGps::start ( )
overridevirtual

Implements SENSGps.

Definition at line 84 of file SENSGps.cpp.

85 {
86  if (_running)
87  return false;
88 
89  Utils::log("SENSDummyGps", "start");
91  _running = true;
92  return true;
93 }
void startSimulation()
Definition: SENSGps.cpp:102
bool _running
Definition: SENSGps.h:46
void log(const char *tag, const char *format,...)
logs a formatted string platform independently
Definition: Utils.cpp:1100

◆ startSimulation()

void SENSDummyGps::startSimulation ( )
private

Definition at line 102 of file SENSGps.cpp.

103 {
104  _stop = false;
105  _thread = std::thread(&SENSDummyGps::run, this);
106 }
void run()
Definition: SENSGps.cpp:115
std::thread _thread
Definition: SENSGps.h:90

◆ stop()

void SENSDummyGps::stop ( )
overridevirtual

Implements SENSGps.

Definition at line 95 of file SENSGps.cpp.

96 {
97  Utils::log("SENSDummyGps", "stop");
99  _running = false;
100 }

◆ stopSimulation()

void SENSDummyGps::stopSimulation ( )
private

Definition at line 108 of file SENSGps.cpp.

109 {
110  _stop = true;
111  if (_thread.joinable())
112  _thread.join();
113 }

Member Data Documentation

◆ _dummyLocs

std::vector<SENSGps::Location> SENSDummyGps::_dummyLocs
private

Definition at line 93 of file SENSGps.h.

◆ _stop

std::atomic_bool SENSDummyGps::_stop {false}
private

Definition at line 91 of file SENSGps.h.

◆ _thread

std::thread SENSDummyGps::_thread
private

Definition at line 90 of file SENSGps.h.


The documentation for this class was generated from the following files: