Skip to content
Browse files

Add toString() to MessageAdd, MessageSubtract, and MessageDivide.

  • Loading branch information...
1 parent 5732804 commit 19d25ecd0466aae79a2cf54ca9c06abf58d9230a @mhroth committed
Showing with 18 additions and 9 deletions.
  1. +4 −2 src/MessageAdd.cpp
  2. +2 −1 src/MessageAdd.h
  3. +4 −2 src/MessageDivide.cpp
  4. +2 −1 src/MessageDivide.h
  5. +4 −2 src/MessageSubtract.cpp
  6. +2 −1 src/MessageSubtract.h
View
6 src/MessageAdd.cpp
@@ -34,8 +34,10 @@ MessageAdd::~MessageAdd() {
// nothing to do
}
-const char *MessageAdd::getObjectLabel() {
- return "+";
+string MessageAdd::toString() {
+ char str[snprintf(NULL, 0, "+ %g", constant)+1];
+ snprintf(str, sizeof(str), "+ %g", constant);
+ return string(str);
}
void MessageAdd::processMessage(int inletIndex, PdMessage *message) {
View
3 src/MessageAdd.h
@@ -33,7 +33,8 @@ class MessageAdd : public MessageObject {
MessageAdd(PdMessage *initMessage, PdGraph *graph);
~MessageAdd();
- static const char *getObjectLabel();
+ static const char *getObjectLabel() { return "+"; }
+ string toString();
private:
void processMessage(int inletIndex, PdMessage *message);
View
6 src/MessageDivide.cpp
@@ -34,8 +34,10 @@ MessageDivide::~MessageDivide() {
// nothing to do
}
-const char *MessageDivide::getObjectLabel() {
- return "/";
+string MessageDivide::toString() {
+ char str[snprintf(NULL, 0, "/ %g", constant)+1];
+ snprintf(str, sizeof(str), "/ %g", constant);
+ return string(str);
}
void MessageDivide::processMessage(int inletIndex, PdMessage *message) {
View
3 src/MessageDivide.h
@@ -33,7 +33,8 @@ class MessageDivide : public MessageObject {
MessageDivide(PdMessage *initMessage, PdGraph *graph);
~MessageDivide();
- static const char *getObjectLabel();
+ static const char *getObjectLabel() { return "/"; }
+ string toString();
private:
void processMessage(int inletIndex, PdMessage *message);
View
6 src/MessageSubtract.cpp
@@ -34,8 +34,10 @@ MessageSubtract::~MessageSubtract() {
// nothing to do
}
-const char *MessageSubtract::getObjectLabel() {
- return "-";
+string MessageSubtract::toString() {
+ char str[snprintf(NULL, 0, "- %g", constant)+1];
+ snprintf(str, sizeof(str), "- %g", constant);
+ return string(str);
}
void MessageSubtract::processMessage(int inletIndex, PdMessage *message) {
View
3 src/MessageSubtract.h
@@ -33,7 +33,8 @@ class MessageSubtract : public MessageObject {
MessageSubtract(PdMessage *initMessage, PdGraph *graph);
~MessageSubtract();
- static const char *getObjectLabel();
+ static const char *getObjectLabel() { return "-"; }
+ string toString();
private:
void processMessage(int inletIndex, PdMessage *message);

0 comments on commit 19d25ec

Please sign in to comment.
Something went wrong with that request. Please try again.