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