ADD: added source to track
This commit is contained in:
@@ -29,9 +29,10 @@ namespace SimCore {
|
||||
const SimCore::Identifier ID_;
|
||||
|
||||
const SimCore::TrackKind TrackKind_ = UNKNOWN_TRACK;
|
||||
|
||||
|
||||
const WHISPER::SourceType SourceType_;
|
||||
|
||||
const WHISPER::SourceType SourceType_;
|
||||
|
||||
const SimCore::ObjectSource ObjectSource_;
|
||||
|
||||
|
||||
|
||||
@@ -44,7 +45,7 @@ namespace SimCore {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Track( WHISPER::SourceType src,SimCore::Identifier id, SimCore::TrackKind trackkind);
|
||||
Track( WHISPER::SourceType src,SimCore::Identifier id, SimCore::TrackKind trackkind,SimCore::ObjectSource ObjectSource = EXTERNAL);
|
||||
|
||||
|
||||
|
||||
@@ -54,6 +55,9 @@ namespace SimCore {
|
||||
|
||||
const WHISPER::SourceType getSourceType();
|
||||
|
||||
const SimCore::ObjectSource getObjectSource();
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -37,7 +37,14 @@ namespace SimCore {
|
||||
|
||||
bool isValid();
|
||||
|
||||
double distanceToPosition(Position &p2);
|
||||
/**
|
||||
* @brief calculates the disatance and the bearing from this->position to the other position
|
||||
*
|
||||
* @param Position
|
||||
*
|
||||
* @return std::tuple<double distance, double bearing>
|
||||
*/
|
||||
std::tuple<double, double> distanceBearingToPosition(Position &p2);
|
||||
|
||||
|
||||
bool operator== ( Position &lhs);
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace SimCore {
|
||||
|
||||
private:
|
||||
std::map<K, V> store;
|
||||
mutable std::mutex mx;
|
||||
std::condition_variable c;
|
||||
mutable std::mutex mx_;
|
||||
std::condition_variable c_;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -26,31 +26,31 @@ namespace SimCore {
|
||||
|
||||
void addValue(K key, V value )
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mx);
|
||||
std::lock_guard<std::mutex> lock(mx_);
|
||||
store.emplace(key,value);
|
||||
c.notify_one();
|
||||
c_.notify_one();
|
||||
|
||||
}
|
||||
|
||||
void removePair(K key)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mx);
|
||||
std::lock_guard<std::mutex> lock(mx_);
|
||||
auto search = store.find(key);
|
||||
if (search != store.end()) {
|
||||
search = store.erase(search);
|
||||
}
|
||||
c.notify_one();
|
||||
c_.notify_one();
|
||||
|
||||
}
|
||||
|
||||
void overRideValue(K key, V newValue)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mx);
|
||||
std::lock_guard<std::mutex> lock(mx_);
|
||||
auto search = store.find(key);
|
||||
if (search != store.end()) {
|
||||
store[key] = newValue;
|
||||
}
|
||||
c.notify_one();
|
||||
c_.notify_one();
|
||||
|
||||
|
||||
}
|
||||
@@ -58,7 +58,7 @@ namespace SimCore {
|
||||
|
||||
V getValue(K key)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mx);
|
||||
std::lock_guard<std::mutex> lock(mx_);
|
||||
V value;
|
||||
auto search = store.find(key);
|
||||
if (search != store.end()) {
|
||||
@@ -70,7 +70,7 @@ namespace SimCore {
|
||||
|
||||
bool hasKey(K key)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mx);
|
||||
std::lock_guard<std::mutex> lock(mx_);
|
||||
auto search = store.find(key);
|
||||
if (search != store.end()) {
|
||||
return true;
|
||||
@@ -84,10 +84,24 @@ namespace SimCore {
|
||||
long size()
|
||||
{
|
||||
|
||||
std::lock_guard<std::mutex> lock(std::mutex);
|
||||
std::lock_guard<std::mutex> lock(mx_);
|
||||
|
||||
return store.size();
|
||||
}
|
||||
|
||||
|
||||
const V& operator[](const K& key) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mx_);
|
||||
return store.at(key);
|
||||
}
|
||||
|
||||
V& operator[](const K& key)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mx_);
|
||||
return store[key];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user