Loading ccsrc/Protocols/GeoNetworking/LocationTable.cc 0 → 100644 +36 −0 Original line number Diff line number Diff line #include "LocationTable.hh" #include "GeoNetworkingTypes.hh" #include "loggers.hh" using namespace LibItsGeoNetworking__TypesAndValues; void LocationTable::add_entry(const LibItsGeoNetworking__TypesAndValues::LongPosVector& p_long_pos_vector) { loggers::get_instance().log_msg(">>> LocationTable::add_entry:", p_long_pos_vector); std::map<OCTETSTRING, std::shared_ptr<LibItsGeoNetworking__TypesAndValues::LongPosVector>>::const_iterator it = _entries_by_mids.find(p_long_pos_vector.gnAddr().mid()); if (it == _entries_by_mids.cend()) { // Not found // Add it loggers::get_instance().log("LocationTable::add_entry: Create new entry"); std::shared_ptr<LibItsGeoNetworking__TypesAndValues::LongPosVector> lpv(new LibItsGeoNetworking__TypesAndValues::LongPosVector(p_long_pos_vector)); _entries_by_mids.insert(std::pair<OCTETSTRING, std::shared_ptr<LibItsGeoNetworking__TypesAndValues::LongPosVector>>(p_long_pos_vector.gnAddr().mid(), lpv)); _entries_by_times.insert(std::pair<unsigned long, std::shared_ptr<LibItsGeoNetworking__TypesAndValues::LongPosVector>>(static_cast<unsigned long>(p_long_pos_vector.timestamp__().get_long_long_val()), lpv)); } else { // TODO Update the timestamp } } // End of add_entry method const LibItsGeoNetworking__TypesAndValues::LongPosVector* LocationTable::get_entry(const OCTETSTRING & p_mid) const { // Sanity check if (_entries_by_times.empty() || (p_mid.lengthof() != 8)) { return nullptr; } std::map<OCTETSTRING, std::shared_ptr<LibItsGeoNetworking__TypesAndValues::LongPosVector>>::const_iterator it = _entries_by_mids.find(p_mid); if (it == _entries_by_mids.cend()) { // Not found return nullptr; } return it->second.get(); } // End of get_entry method ccsrc/Protocols/GeoNetworking/LocationTable.hh 0 → 100644 +26 −0 Original line number Diff line number Diff line #ifndef LOCATION_TABLE_H #define LOCATION_TABLE_H #include <map> #include <memory> class OCTETSTRING; namespace LibItsGeoNetworking__TypesAndValues { class LongPosVector; } class LocationTable { std::map<unsigned long, std::shared_ptr<LibItsGeoNetworking__TypesAndValues::LongPosVector>> _entries_by_times; std::map<OCTETSTRING, std::shared_ptr<LibItsGeoNetworking__TypesAndValues::LongPosVector>> _entries_by_mids; public: LocationTable() : _entries_by_times(), _entries_by_mids() { }; virtual ~LocationTable() { _entries_by_times.clear(); _entries_by_mids.clear(); }; // std::shared_ptr provides memory free process bool has_entry(const OCTETSTRING& p_mid) const { return false; }; void add_entry(const LibItsGeoNetworking__TypesAndValues::LongPosVector& p_long_pos_vector); const LibItsGeoNetworking__TypesAndValues::LongPosVector* get_entry(const OCTETSTRING & p_mid) const; }; #endif ccsrc/Protocols/GeoNetworking/Makefiledeleted 100644 → 0 +0 −15 Original line number Diff line number Diff line PROJECTROOT = .. BUILDROOT = ../../bin PROJECT = its-framework DEBUG = yes testdir = tests srcdir = . ccflags += -O0 -ggdb -std=c++11 -DTITAN_RUNTIME_2 -DWIN32 alibs = $(PROJECT) sources := ../../Framework/src/LayerFactory.cc GeoNetworkingCodec.cc GeoNetworkingLayer.cc headers := Codec.hh Layer.hh GeoNetworkingTypes.hh GeoNetworkingCodec.hh GeoNetworkingLayer.hh includes := . .. ../../Framework ../../loggers ../../../../bin $(TTCN3_DIR)/include include ../../common.mk Loading
ccsrc/Protocols/GeoNetworking/LocationTable.cc 0 → 100644 +36 −0 Original line number Diff line number Diff line #include "LocationTable.hh" #include "GeoNetworkingTypes.hh" #include "loggers.hh" using namespace LibItsGeoNetworking__TypesAndValues; void LocationTable::add_entry(const LibItsGeoNetworking__TypesAndValues::LongPosVector& p_long_pos_vector) { loggers::get_instance().log_msg(">>> LocationTable::add_entry:", p_long_pos_vector); std::map<OCTETSTRING, std::shared_ptr<LibItsGeoNetworking__TypesAndValues::LongPosVector>>::const_iterator it = _entries_by_mids.find(p_long_pos_vector.gnAddr().mid()); if (it == _entries_by_mids.cend()) { // Not found // Add it loggers::get_instance().log("LocationTable::add_entry: Create new entry"); std::shared_ptr<LibItsGeoNetworking__TypesAndValues::LongPosVector> lpv(new LibItsGeoNetworking__TypesAndValues::LongPosVector(p_long_pos_vector)); _entries_by_mids.insert(std::pair<OCTETSTRING, std::shared_ptr<LibItsGeoNetworking__TypesAndValues::LongPosVector>>(p_long_pos_vector.gnAddr().mid(), lpv)); _entries_by_times.insert(std::pair<unsigned long, std::shared_ptr<LibItsGeoNetworking__TypesAndValues::LongPosVector>>(static_cast<unsigned long>(p_long_pos_vector.timestamp__().get_long_long_val()), lpv)); } else { // TODO Update the timestamp } } // End of add_entry method const LibItsGeoNetworking__TypesAndValues::LongPosVector* LocationTable::get_entry(const OCTETSTRING & p_mid) const { // Sanity check if (_entries_by_times.empty() || (p_mid.lengthof() != 8)) { return nullptr; } std::map<OCTETSTRING, std::shared_ptr<LibItsGeoNetworking__TypesAndValues::LongPosVector>>::const_iterator it = _entries_by_mids.find(p_mid); if (it == _entries_by_mids.cend()) { // Not found return nullptr; } return it->second.get(); } // End of get_entry method
ccsrc/Protocols/GeoNetworking/LocationTable.hh 0 → 100644 +26 −0 Original line number Diff line number Diff line #ifndef LOCATION_TABLE_H #define LOCATION_TABLE_H #include <map> #include <memory> class OCTETSTRING; namespace LibItsGeoNetworking__TypesAndValues { class LongPosVector; } class LocationTable { std::map<unsigned long, std::shared_ptr<LibItsGeoNetworking__TypesAndValues::LongPosVector>> _entries_by_times; std::map<OCTETSTRING, std::shared_ptr<LibItsGeoNetworking__TypesAndValues::LongPosVector>> _entries_by_mids; public: LocationTable() : _entries_by_times(), _entries_by_mids() { }; virtual ~LocationTable() { _entries_by_times.clear(); _entries_by_mids.clear(); }; // std::shared_ptr provides memory free process bool has_entry(const OCTETSTRING& p_mid) const { return false; }; void add_entry(const LibItsGeoNetworking__TypesAndValues::LongPosVector& p_long_pos_vector); const LibItsGeoNetworking__TypesAndValues::LongPosVector* get_entry(const OCTETSTRING & p_mid) const; }; #endif
ccsrc/Protocols/GeoNetworking/Makefiledeleted 100644 → 0 +0 −15 Original line number Diff line number Diff line PROJECTROOT = .. BUILDROOT = ../../bin PROJECT = its-framework DEBUG = yes testdir = tests srcdir = . ccflags += -O0 -ggdb -std=c++11 -DTITAN_RUNTIME_2 -DWIN32 alibs = $(PROJECT) sources := ../../Framework/src/LayerFactory.cc GeoNetworkingCodec.cc GeoNetworkingLayer.cc headers := Codec.hh Layer.hh GeoNetworkingTypes.hh GeoNetworkingCodec.hh GeoNetworkingLayer.hh includes := . .. ../../Framework ../../loggers ../../../../bin $(TTCN3_DIR)/include include ../../common.mk