Commit 36a461ed by David Heitbrink

minor update, mostly fixed warnings

parent dbef1c96
cmake_minimum_required(VERSION 3.2)
project(NADS_DDSLIB CXX)
################################################################################
# Source groups
################################################################################
set(CMAKE_C_FLAGS "-Wall -g")
set (SRC
apex_memmove.cpp
DDSSimClient.cpp
NADSPlugin.cxx
NADS.cxx
stdafx.cpp
)
set (HEADERS
apex_memmove.h
stdafx.h
targetver.h
NADS.hpp
NADSPlugin.hpp
)
set (PUBLIC_INCLUDE
./include/NadsDDSLib/DDSSimClient.h
./include/NadsDDSLib/NadsDDSLib.h
)
set (LIB_SRC
./src/GenericSubscriber.cpp
./src/GenericSubscriber.h
./src/nadsddsimpl.cpp
./src/nadsddsimpl.h
./src/nadsddslib.cpp
./src/value_as_string.cpp
./src/value_as_string.h
)
source_group("Source Files" FILES ${SRC} )
source_group("Header Files" FILES ${HEADERS})
source_group("PUBLIC INCLUDE" FILES ${PUBLIC_INCLUDE} )
source_group("Lib Source" FILES ${LIB_SRC})
################################################################################
# Target
################################################################################
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS -DRTI_WIN32)
endif()
add_library(${PROJECT_NAME} STATIC ${SRC} ${HEADERS} ${PUBLIC_INCLUDE} ${LIB_SRC})
target_include_directories(${PROJECT_NAME}
PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/./include"
"${CMAKE_CURRENT_SOURCE_DIR}/../nads-boost;"
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/src"
"$ENV{NDDSHOME}/include"
"$ENV{NDDSHOME}/include/ndds"
"$ENV{NDDSHOME}/include/ndds/hpp"
)
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 17
CXX_EXCEPTIONS on
)
target_link_directories(${PROJECT_NAME}
PUBLIC
"$ENV{NDDSHOME}/lib/x64Win64VS2017"
)
################################################################################
# Output directory
################################################################################
set_target_properties(${PROJECT_NAME} PROPERTIES
OUTPUT_DIRECTORY_DEBUG "${CMAKE_SOURCE_DIR}//lib/"
OUTPUT_DIRECTORY_RELEASE "${CMAKE_SOURCE_DIR}//lib/"
)
...@@ -5,8 +5,24 @@ namespace NDDSClient { ...@@ -5,8 +5,24 @@ namespace NDDSClient {
using namespace std; using namespace std;
CCellInputMap::CCellInputMap() {} CCellInputMap::CCellInputMap() {}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// \fn void CCellInputMap::RegInpElem(std::string name, void *_pBuffer, size_t _BufferSize, char _BufferType)
///
/// \brief Registers the inp element
///
/// Saves a copy of the void* _pBuffer, the class saves a reference of the buffer. Its critical
/// the user does not delete the buffer, and the size is accurate.
///
/// \author D A Heitbrink
/// \date 10/7/2020
///
/// \param name The name.
/// \param [in,out] _pBuffer If non-null, the buffer.
/// \param _BufferSize Size of the buffer.
/// \param _BufferType Type of the buffer.
////////////////////////////////////////////////////////////////////////////////////////////////////
void CCellInputMap::RegInpElem(std::string name, void *_pBuffer, const unsigned int _BufferSize, char _BufferType) { void CCellInputMap::RegInpElem(std::string name, void *_pBuffer, size_t _BufferSize, char _BufferType) {
CCellInputMap::TCellRef ref = std::make_unique<CellInput>(); CCellInputMap::TCellRef ref = std::make_unique<CellInput>();
ref->_sub = NADSDDS::CSubscription::MakeSubscription(name, _BufferType); ref->_sub = NADSDDS::CSubscription::MakeSubscription(name, _BufferType);
ref->_size = _BufferSize; ref->_size = _BufferSize;
...@@ -53,7 +69,7 @@ namespace NDDSClient { ...@@ -53,7 +69,7 @@ namespace NDDSClient {
/// \param _BufferType Type of the buffer. /// \param _BufferType Type of the buffer.
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
void CCellOutputMap::RegInpElem(std::string name, void *_pBuffer, const unsigned int _BufferSize, char _BufferType) { void CCellOutputMap::RegInpElem(std::string name, void *_pBuffer, size_t _BufferSize, char _BufferType) {
TCellRef ref = std::make_unique<CellOutput>(); TCellRef ref = std::make_unique<CellOutput>();
size_t elementSize = 0; size_t elementSize = 0;
switch (_BufferType) { switch (_BufferType) {
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
namespace NDDSClient { namespace NDDSClient {
class CellInput { class CellInput {
public: public:
CellInput() :_size(0),_target(nullptr),_type(0) {}
size_t _size; size_t _size;
void* _target; void* _target;
char _type; char _type;
...@@ -31,7 +32,7 @@ namespace NDDSClient { ...@@ -31,7 +32,7 @@ namespace NDDSClient {
class CCellInputMap { class CCellInputMap {
public: public:
CCellInputMap(); CCellInputMap();
void RegInpElem(std::string name, void *_pBuffer, const unsigned int _BufferSize, char _BufferType); void RegInpElem(std::string name, void *_pBuffer, size_t _BufferSize, char _BufferType);
void ReadInputElements(); void ReadInputElements();
private: private:
typedef std::unique_ptr<CellInput> TCellRef; typedef std::unique_ptr<CellInput> TCellRef;
...@@ -57,7 +58,7 @@ namespace NDDSClient { ...@@ -57,7 +58,7 @@ namespace NDDSClient {
class CCellOutputMap { class CCellOutputMap {
public: public:
CCellOutputMap() {} CCellOutputMap() {}
void RegInpElem(std::string name, void *_pBuffer, const unsigned int _BufferSize, char _BufferType); void RegInpElem(std::string name, void *_pBuffer, size_t _BufferSize, char _BufferType);
void WriteOutputElements(); void WriteOutputElements();
private: private:
typedef std::unique_ptr<CellOutput> TCellRef; typedef std::unique_ptr<CellOutput> TCellRef;
......
...@@ -23,6 +23,32 @@ ...@@ -23,6 +23,32 @@
#ifdef _X86_ #ifdef _X86_
#ifndef NADSDDDS_DLL #ifndef NADSDDDS_DLL
#pragma comment(lib,"NadsDDSLib_32ds.lib") #pragma comment(lib,"NadsDDSLib_32ds.lib")
#endif
#else
#ifndef NADSDDDS_DLL
#pragma comment(lib,"NadsDDSLib_64ds.lib")
#endif
#endif // DEBUG
#else
#ifdef _X86_
#ifndef NADSDDDS_DLL
#pragma comment(lib,"NadsDDSLib_32s.lib")
#endif
#else
#ifndef NADSDDDS_DLL
#pragma comment(lib,"NadsDDSLib_64s.lib")
#endif
#endif // DEBUG
#endif
#endif
#endif
#ifndef NO_AUTOLINK_DDS_LIB
#ifdef _MSC_VER
#pragma comment(lib, "Ws2_32.lib")
#ifdef _DEBUG
#ifdef _X86_
#ifndef NADSDDDS_DLL
#pragma comment(lib,"nddscpp2zd.lib") #pragma comment(lib,"nddscpp2zd.lib")
#pragma comment(lib,"nddsczd.lib") #pragma comment(lib,"nddsczd.lib")
#pragma comment(lib,"nddscorezd.lib") #pragma comment(lib,"nddscorezd.lib")
...@@ -32,7 +58,6 @@ ...@@ -32,7 +58,6 @@
#endif #endif
#else #else
#ifndef NADSDDDS_DLL #ifndef NADSDDDS_DLL
#pragma comment(lib,"NadsDDSLib_64ds.lib")
#pragma comment(lib,"nddscpp2zd.lib") #pragma comment(lib,"nddscpp2zd.lib")
#pragma comment(lib,"nddsczd.lib") #pragma comment(lib,"nddsczd.lib")
#pragma comment(lib,"nddscorezd.lib") #pragma comment(lib,"nddscorezd.lib")
...@@ -44,7 +69,6 @@ ...@@ -44,7 +69,6 @@
#else #else
#ifdef _X86_ #ifdef _X86_
#ifndef NADSDDDS_DLL #ifndef NADSDDDS_DLL
#pragma comment(lib,"NadsDDSLib_32s.lib")
#pragma comment(lib,"nddscpp2z.lib") #pragma comment(lib,"nddscpp2z.lib")
#pragma comment(lib,"nddscz.lib") #pragma comment(lib,"nddscz.lib")
#pragma comment(lib,"nddscorez.lib") #pragma comment(lib,"nddscorez.lib")
...@@ -54,7 +78,6 @@ ...@@ -54,7 +78,6 @@
#endif #endif
#else #else
#ifndef NADSDDDS_DLL #ifndef NADSDDDS_DLL
#pragma comment(lib,"NadsDDSLib_64s.lib")
#pragma comment(lib,"nddscpp2z.lib") #pragma comment(lib,"nddscpp2z.lib")
#pragma comment(lib,"nddscz.lib") #pragma comment(lib,"nddscz.lib")
#pragma comment(lib,"nddscorez.lib") #pragma comment(lib,"nddscorez.lib")
...@@ -86,7 +109,7 @@ namespace NADSDDS { ...@@ -86,7 +109,7 @@ namespace NADSDDS {
class CellRoot { class CellRoot {
public: public:
CellRoot(int id) :_eid(id), _itemCount(0), _period(-1) { CellRoot(int id) :_eid(id), _itemCount(0), _period(-1),_sizeInBytes(0) {
} }
virtual void* Raw() = 0; virtual void* Raw() = 0;
virtual void Send() = 0; virtual void Send() = 0;
......
...@@ -110,7 +110,7 @@ namespace NADSDDS { ...@@ -110,7 +110,7 @@ namespace NADSDDS {
} }
CStatePriv::CStatePriv() { CStatePriv::CStatePriv():_frame(0) {
_newFrameCb = make_shared<CStatePriv::OnNewFrame>(this); _newFrameCb = make_shared<CStatePriv::OnNewFrame>(this);
_FrameSub = std::make_unique<DataStream<TypeInt>>("Frame", &DDSDomainRepo::GetDomain(0), _newFrameCb); _FrameSub = std::make_unique<DataStream<TypeInt>>("Frame", &DDSDomainRepo::GetDomain(0), _newFrameCb);
_StateSub = std::make_unique<TIntSubscription>("StateMode"); _StateSub = std::make_unique<TIntSubscription>("StateMode");
......
...@@ -134,7 +134,7 @@ namespace NADSDDS { ...@@ -134,7 +134,7 @@ namespace NADSDDS {
public: public:
typedef unique_ptr<CellPub<TypeFloat>> TRef; typedef unique_ptr<CellPub<TypeFloat>> TRef;
CFloatPub(TRef &&in) :_ref(std::move(in)) {}; CFloatPub(TRef &&in) :_ref(std::move(in)) {};
CFloatPub(CFloatPub &&in) :_ref(std::move(in._ref)) {} CFloatPub(CFloatPub &&in) noexcept :_ref(std::move(in._ref)){}
TRef _ref; TRef _ref;
CellPub<TypeFloat>* get() { return _ref.get(); } CellPub<TypeFloat>* get() { return _ref.get(); }
CellPub<TypeFloat>* operator->() { return _ref.get(); } CellPub<TypeFloat>* operator->() { return _ref.get(); }
...@@ -153,7 +153,7 @@ namespace NADSDDS { ...@@ -153,7 +153,7 @@ namespace NADSDDS {
public: public:
typedef unique_ptr<CellPub<TypeDouble>> TRef; typedef unique_ptr<CellPub<TypeDouble>> TRef;
CDoublePub(TRef &&in) :_ref(std::move(in)) {}; CDoublePub(TRef &&in) :_ref(std::move(in)) {};
CDoublePub(CDoublePub &&in) :_ref(std::move(in._ref)) {} CDoublePub(CDoublePub &&in) noexcept :_ref(std::move(in._ref)) {}
TRef _ref; TRef _ref;
CellPub<TypeDouble>* get() { return _ref.get(); } CellPub<TypeDouble>* get() { return _ref.get(); }
CellPub<TypeDouble>* operator->() { return _ref.get(); } CellPub<TypeDouble>* operator->() { return _ref.get(); }
...@@ -172,7 +172,7 @@ namespace NADSDDS { ...@@ -172,7 +172,7 @@ namespace NADSDDS {
public: public:
typedef unique_ptr<CellPub<TypeChar>> TRef; typedef unique_ptr<CellPub<TypeChar>> TRef;
CCharPub(TRef &&in) :_ref(std::move(in)) {}; CCharPub(TRef &&in) :_ref(std::move(in)) {};
CCharPub(CCharPub &&in) :_ref(std::move(in._ref)) {} CCharPub(CCharPub &&in) noexcept :_ref(std::move(in._ref)) {}
TRef _ref; TRef _ref;
CellPub<TypeChar>* get() { return _ref.get(); } CellPub<TypeChar>* get() { return _ref.get(); }
CellPub<TypeChar>* operator->() { return _ref.get(); } CellPub<TypeChar>* operator->() { return _ref.get(); }
...@@ -193,7 +193,7 @@ namespace NADSDDS { ...@@ -193,7 +193,7 @@ namespace NADSDDS {
public: public:
typedef unique_ptr<CellPub<TypeInt>> TRef; typedef unique_ptr<CellPub<TypeInt>> TRef;
CIntPub(TRef &&in):_ref(std::move(in)) {}; CIntPub(TRef &&in):_ref(std::move(in)) {};
CIntPub(CIntPub &&in ):_ref(std::move(in._ref)){} CIntPub(CIntPub &&in ) noexcept:_ref(std::move(in._ref)){}
TRef _ref; TRef _ref;
CellPub<TypeInt>* get() { return _ref.get(); } CellPub<TypeInt>* get() { return _ref.get(); }
CellPub<TypeInt>* operator->() { return _ref.get(); } CellPub<TypeInt>* operator->() { return _ref.get(); }
...@@ -212,7 +212,7 @@ namespace NADSDDS { ...@@ -212,7 +212,7 @@ namespace NADSDDS {
public: public:
typedef unique_ptr<CellPub<TypeShort>> TRef; typedef unique_ptr<CellPub<TypeShort>> TRef;
CShortPub(TRef &&in) :_ref(std::move(in)) {}; CShortPub(TRef &&in) :_ref(std::move(in)) {};
CShortPub(CShortPub &&in) :_ref(std::move(in._ref)) {} CShortPub(CShortPub &&in) noexcept:_ref(std::move(in._ref)) {}
operator CellPub<TypeShort>* () { return _ref.get(); } operator CellPub<TypeShort>* () { return _ref.get(); }
CellPub<TypeShort>* operator()() { return _ref.get(); } CellPub<TypeShort>* operator()() { return _ref.get(); }
TRef _ref; TRef _ref;
...@@ -249,7 +249,7 @@ namespace NADSDDS { ...@@ -249,7 +249,7 @@ namespace NADSDDS {
template < class T> class DataListener : public dds::sub::NoOpDataReaderListener<T> { template < class T> class DataListener : public dds::sub::NoOpDataReaderListener<T> {
public: public:
typedef std::shared_ptr<OnNewData<T>> TCbRef; typedef std::shared_ptr<OnNewData<T>> TCbRef;
DataListener(TCbRef ref) :_cb(ref) {}; DataListener(TCbRef ref) :_cb(ref),_hasData(false) {};
void on_data_available(dds::sub::DataReader<T>& reader) { void on_data_available(dds::sub::DataReader<T>& reader) {
dds::sub::LoanedSamples<T> samples = reader.take(); dds::sub::LoanedSamples<T> samples = reader.take();
rti::sub::SampleIterator<T> it;// = dds::sub::LoanedSamples<T>::iterator rti::sub::SampleIterator<T> it;// = dds::sub::LoanedSamples<T>::iterator
......
...@@ -73,7 +73,7 @@ void DoublePublication::Set(const std::string& str){ ...@@ -73,7 +73,7 @@ void DoublePublication::Set(const std::string& str){
stringstream converter(str); stringstream converter(str);
double val; double val;
converter >> val; converter >> val;
int size = Count(); size_t size = Count();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
converter >> val; converter >> val;
(*this)[i] = val; (*this)[i] = val;
...@@ -129,7 +129,7 @@ void FloatPublication::Set(const std::string& str) { ...@@ -129,7 +129,7 @@ void FloatPublication::Set(const std::string& str) {
stringstream converter(str); stringstream converter(str);
float val; float val;
converter >> val; converter >> val;
int size = Count(); size_t size = Count();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
converter >> val; converter >> val;
(*this)[i] = val; (*this)[i] = val;
...@@ -164,7 +164,7 @@ void ShortPublication::Set(const std::string& str) { ...@@ -164,7 +164,7 @@ void ShortPublication::Set(const std::string& str) {
stringstream converter(str); stringstream converter(str);
short val; short val;
converter >> val; converter >> val;
int size = Count(); size_t size = Count();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
converter >> val; converter >> val;
(*this)[i] = val; (*this)[i] = val;
...@@ -192,7 +192,7 @@ void IntPublication::Set(const std::string& str) { ...@@ -192,7 +192,7 @@ void IntPublication::Set(const std::string& str) {
stringstream converter(str); stringstream converter(str);
int val; int val;
converter >> val; converter >> val;
int size = Count(); size_t size = Count();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
converter >> val; converter >> val;
(*this)[i] = val; (*this)[i] = val;
...@@ -227,7 +227,7 @@ char& CharPublication::operator[] (size_t index) { ...@@ -227,7 +227,7 @@ char& CharPublication::operator[] (size_t index) {
} }
void CharPublication::Set(const std::string& str) {; void CharPublication::Set(const std::string& str) {;
int size = min(Count(), str.size()); size_t size = min(Count(), str.size());
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
(*this)[i] = str[i]; (*this)[i] = str[i];
} }
......
No preview for this file type
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment