Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 19d25ecd0466aae79a2cf54ca9c06abf58d9230a 1 parent 5732804
Martin Roth authored
6  src/MessageAdd.cpp
@@ -34,8 +34,10 @@ MessageAdd::~MessageAdd() {
34 34
   // nothing to do
35 35
 }
36 36
 
37  
-const char *MessageAdd::getObjectLabel() {
38  
-  return "+";
  37
+string MessageAdd::toString() {
  38
+  char str[snprintf(NULL, 0, "+ %g", constant)+1];
  39
+  snprintf(str, sizeof(str), "+ %g", constant);
  40
+  return string(str);
39 41
 }
40 42
 
41 43
 void MessageAdd::processMessage(int inletIndex, PdMessage *message) {
3  src/MessageAdd.h
@@ -33,7 +33,8 @@ class MessageAdd : public MessageObject {
33 33
     MessageAdd(PdMessage *initMessage, PdGraph *graph);
34 34
     ~MessageAdd();
35 35
 
36  
-    static const char *getObjectLabel();
  36
+    static const char *getObjectLabel() { return "+"; }
  37
+    string toString();
37 38
 
38 39
   private:
39 40
     void processMessage(int inletIndex, PdMessage *message);
6  src/MessageDivide.cpp
@@ -34,8 +34,10 @@ MessageDivide::~MessageDivide() {
34 34
   // nothing to do
35 35
 }
36 36
 
37  
-const char *MessageDivide::getObjectLabel() {
38  
-  return "/";
  37
+string MessageDivide::toString() {
  38
+  char str[snprintf(NULL, 0, "/ %g", constant)+1];
  39
+  snprintf(str, sizeof(str), "/ %g", constant);
  40
+  return string(str);
39 41
 }
40 42
 
41 43
 void MessageDivide::processMessage(int inletIndex, PdMessage *message) {
3  src/MessageDivide.h
@@ -33,7 +33,8 @@ class MessageDivide : public MessageObject {
33 33
     MessageDivide(PdMessage *initMessage, PdGraph *graph);
34 34
     ~MessageDivide();
35 35
 
36  
-    static const char *getObjectLabel();
  36
+    static const char *getObjectLabel() { return "/"; }
  37
+    string toString();
37 38
 
38 39
   private:
39 40
     void processMessage(int inletIndex, PdMessage *message);
6  src/MessageSubtract.cpp
@@ -34,8 +34,10 @@ MessageSubtract::~MessageSubtract() {
34 34
   // nothing to do
35 35
 }
36 36
 
37  
-const char *MessageSubtract::getObjectLabel() {
38  
-  return "-";
  37
+string MessageSubtract::toString() {
  38
+  char str[snprintf(NULL, 0, "- %g", constant)+1];
  39
+  snprintf(str, sizeof(str), "- %g", constant);
  40
+  return string(str);
39 41
 }
40 42
 
41 43
 void MessageSubtract::processMessage(int inletIndex, PdMessage *message) {
3  src/MessageSubtract.h
@@ -33,7 +33,8 @@ class MessageSubtract : public MessageObject {
33 33
     MessageSubtract(PdMessage *initMessage, PdGraph *graph);
34 34
     ~MessageSubtract();
35 35
 
36  
-    static const char *getObjectLabel();
  36
+    static const char *getObjectLabel() { return "-"; }
  37
+    string toString();
37 38
 
38 39
   private:
39 40
     void processMessage(int inletIndex, PdMessage *message);

0 notes on commit 19d25ec

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