049ad0aa213543677b907de12146e34e8bd509c8
[ardour.git] / libs / pbd / controllable.cc
1 #include <pbd/controllable.h>
2 #include <pbd/xml++.h>
3 #include <pbd/error.h>
4
5 #include "i18n.h"
6
7 using namespace PBD;
8
9 sigc::signal<void,Controllable*> Controllable::Destroyed;
10 sigc::signal<bool,Controllable*> Controllable::StartLearning;
11 sigc::signal<void,Controllable*> Controllable::StopLearning;
12
13 Controllable::Controllable (std::string name)
14         : _name (name)
15 {
16 }
17
18 XMLNode&
19 Controllable::get_state ()
20 {
21         XMLNode* node = new XMLNode (X_("controllable"));
22         char buf[64];
23
24         node->add_property (X_("name"), _name); // not reloaded from XML state, just there to look at
25         _id.print (buf, sizeof (buf));
26         node->add_property (X_("id"), buf);
27         return *node;
28 }
29
30 int
31 Controllable::set_state (const XMLNode& node)
32 {
33         const XMLProperty* prop = node.property (X_("id"));
34
35         if (prop) {
36                 _id = prop->value();
37                 return 0;
38         } else {
39                 error << _("Controllable state node has no ID property") << endmsg;
40                 return -1;
41         }
42 }