Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 19d25ecd0466aae79a2cf54ca9c06abf58d9230a 1 parent 5732804
@mhroth authored
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);
Please sign in to comment.
Something went wrong with that request. Please try again.