Commit dbef1c96 by IOWA\dheitbri

Added set by string, assumes space delimited. fixed issue with order of op for short->getPub.

parent ef6cd13e
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
/// ///
#ifndef NO_AUTOLINK_NADS_DDS_LIB #ifndef NO_AUTOLINK_NADS_DDS_LIB
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma comment(lib, "Ws2_32.lib")
#ifdef _DEBUG #ifdef _DEBUG
#ifdef _X86_ #ifdef _X86_
#ifndef NADSDDDS_DLL #ifndef NADSDDDS_DLL
...@@ -284,6 +285,7 @@ namespace NADSDDS { ...@@ -284,6 +285,7 @@ namespace NADSDDS {
size_t SizeInBytes(); size_t SizeInBytes();
size_t Count(); size_t Count();
virtual void Publish() = 0 ; virtual void Publish() = 0 ;
virtual void Set(const std::string&) =0;
protected: protected:
virtual CellRoot* GetPub() = 0; virtual CellRoot* GetPub() = 0;
CPublication() {}; CPublication() {};
...@@ -296,6 +298,7 @@ namespace NADSDDS { ...@@ -296,6 +298,7 @@ namespace NADSDDS {
DoublePublication& operator= (double); DoublePublication& operator= (double);
double& operator[] (size_t); double& operator[] (size_t);
virtual void Publish() override; virtual void Publish() override;
virtual void Set(const std::string&) override;
private: private:
virtual CellRoot* GetPub() override; virtual CellRoot* GetPub() override;
TDoublePubPtr _ref; TDoublePubPtr _ref;
...@@ -308,6 +311,7 @@ namespace NADSDDS { ...@@ -308,6 +311,7 @@ namespace NADSDDS {
FloatPublication& operator= (float); FloatPublication& operator= (float);
float& operator[] (size_t); float& operator[] (size_t);
virtual void Publish() override; virtual void Publish() override;
virtual void Set(const std::string&) override;
private: private:
virtual CellRoot* GetPub() override; virtual CellRoot* GetPub() override;
TFloatPubPtr _ref; TFloatPubPtr _ref;
...@@ -320,6 +324,7 @@ namespace NADSDDS { ...@@ -320,6 +324,7 @@ namespace NADSDDS {
ShortPublication& operator= (short); ShortPublication& operator= (short);
short& operator[] (size_t); short& operator[] (size_t);
virtual void Publish() override; virtual void Publish() override;
virtual void Set(const std::string&) override;
private: private:
virtual CellRoot* GetPub() override; virtual CellRoot* GetPub() override;
TShortPubPtr _ref; TShortPubPtr _ref;
...@@ -332,6 +337,7 @@ namespace NADSDDS { ...@@ -332,6 +337,7 @@ namespace NADSDDS {
IntPublication& operator= (int); IntPublication& operator= (int);
int& operator[] (size_t); int& operator[] (size_t);
virtual void Publish() override; virtual void Publish() override;
virtual void Set(const std::string&) override;
private: private:
virtual CellRoot* GetPub() override; virtual CellRoot* GetPub() override;
TIntPubPtr _ref; TIntPubPtr _ref;
...@@ -344,6 +350,7 @@ namespace NADSDDS { ...@@ -344,6 +350,7 @@ namespace NADSDDS {
CharPublication& operator= (const std::string&); CharPublication& operator= (const std::string&);
char& operator[] (size_t); char& operator[] (size_t);
virtual void Publish() override; virtual void Publish() override;
virtual void Set(const std::string&) override;
private: private:
virtual CellRoot* GetPub() override; virtual CellRoot* GetPub() override;
TCharPubPtr _ref; TCharPubPtr _ref;
......
...@@ -69,6 +69,17 @@ double* DoublePublication::asDouble() { ...@@ -69,6 +69,17 @@ double* DoublePublication::asDouble() {
void DoublePublication::Publish() { void DoublePublication::Publish() {
(_ref)->get()->Send(); (_ref)->get()->Send();
} }
void DoublePublication::Set(const std::string& str){
stringstream converter(str);
double val;
converter >> val;
int size = Count();
for (int i = 0; i < size; i++) {
converter >> val;
(*this)[i] = val;
}
}
DoublePublication& DoublePublication::operator= (double val) { DoublePublication& DoublePublication::operator= (double val) {
TypeDouble &dval = _ref->get()->data; TypeDouble &dval = _ref->get()->data;
dval.data()[0] = val; dval.data()[0] = val;
...@@ -114,7 +125,16 @@ void FloatPublication::Publish() { ...@@ -114,7 +125,16 @@ void FloatPublication::Publish() {
(_ref)->get()->Send(); (_ref)->get()->Send();
} }
void FloatPublication::Set(const std::string& str) {
stringstream converter(str);
float val;
converter >> val;
int size = Count();
for (int i = 0; i < size; i++) {
converter >> val;
(*this)[i] = val;
}
}
ShortPublication::ShortPublication(TShortPubPtr&& ptr) :_ref(std::move(ptr)) {} ShortPublication::ShortPublication(TShortPubPtr&& ptr) :_ref(std::move(ptr)) {}
short* ShortPublication::asShort() { short* ShortPublication::asShort() {
...@@ -135,12 +155,21 @@ short& ShortPublication::operator[] (size_t index) { ...@@ -135,12 +155,21 @@ short& ShortPublication::operator[] (size_t index) {
} }
CellRoot* ShortPublication::GetPub() { CellRoot* ShortPublication::GetPub() {
return (CellPub<TypeShort>*)_ref.get(); return _ref->get();
} }
void ShortPublication::Publish() { void ShortPublication::Publish() {
(_ref)->get()->Send(); (_ref)->get()->Send();
} }
void ShortPublication::Set(const std::string& str) {
stringstream converter(str);
short val;
converter >> val;
int size = Count();
for (int i = 0; i < size; i++) {
converter >> val;
(*this)[i] = val;
}
}
IntPublication::IntPublication(TIntPubPtr&& ptr) :_ref(std::move(ptr)) {} IntPublication::IntPublication(TIntPubPtr&& ptr) :_ref(std::move(ptr)) {}
int* IntPublication::asInt() { int* IntPublication::asInt() {
...@@ -159,6 +188,16 @@ int& IntPublication::operator[] (size_t index) { ...@@ -159,6 +188,16 @@ int& IntPublication::operator[] (size_t index) {
} }
return nothing; return nothing;
} }
void IntPublication::Set(const std::string& str) {
stringstream converter(str);
int val;
converter >> val;
int size = Count();
for (int i = 0; i < size; i++) {
converter >> val;
(*this)[i] = val;
}
}
CellRoot* IntPublication::GetPub() { CellRoot* IntPublication::GetPub() {
return _ref->get(); return _ref->get();
...@@ -187,6 +226,13 @@ char& CharPublication::operator[] (size_t index) { ...@@ -187,6 +226,13 @@ char& CharPublication::operator[] (size_t index) {
return nothing; return nothing;
} }
void CharPublication::Set(const std::string& str) {;
int size = min(Count(), str.size());
for (int i = 0; i < size; i++) {
(*this)[i] = str[i];
}
}
CellRoot* CharPublication::GetPub() { CellRoot* CharPublication::GetPub() {
return _ref->_ref.get(); return _ref->_ref.get();
} }
......
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