summaryrefslogtreecommitdiff
path: root/libs/pbd/pbd
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-10-21 19:01:50 +0000
committerDavid Robillard <d@drobilla.net>2006-10-21 19:01:50 +0000
commitfedf3d34f32264ac57c6a222b678dc90f2bb1a88 (patch)
treee816c676d12ccc32b7e666792b9a01ab5b5a0367 /libs/pbd/pbd
parent7bd41538d951c3e476655df741adfbebbb990bde (diff)
Merged with trunk R992.
Completely untested other than it compiles, runs, and records somewhat (need to merge again). git-svn-id: svn://localhost/ardour2/branches/midi@999 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd/pbd')
-rw-r--r--libs/pbd/pbd/controllable.h14
-rw-r--r--libs/pbd/pbd/destructible.h2
-rw-r--r--libs/pbd/pbd/id.h2
-rw-r--r--libs/pbd/pbd/memento_command.h17
-rw-r--r--libs/pbd/pbd/restartable_rw.h7
-rw-r--r--libs/pbd/pbd/shiva.h51
-rw-r--r--libs/pbd/pbd/stacktrace.h2
-rw-r--r--libs/pbd/pbd/undo.h8
8 files changed, 78 insertions, 25 deletions
diff --git a/libs/pbd/pbd/controllable.h b/libs/pbd/pbd/controllable.h
index c46e477b6e..ff8f8a9b52 100644
--- a/libs/pbd/pbd/controllable.h
+++ b/libs/pbd/pbd/controllable.h
@@ -1,6 +1,8 @@
#ifndef __pbd_controllable_h__
#define __pbd_controllable_h__
+#include <string>
+
#include <sigc++/trackable.h>
#include <sigc++/signal.h>
@@ -13,7 +15,7 @@ namespace PBD {
class Controllable : public virtual sigc::trackable, public Stateful {
public:
- Controllable ();
+ Controllable (std::string name);
virtual ~Controllable() { GoingAway (this); }
virtual void set_value (float) = 0;
@@ -23,22 +25,20 @@ class Controllable : public virtual sigc::trackable, public Stateful {
sigc::signal<void> LearningFinished;
- static sigc::signal<void,Controllable*> Created;
static sigc::signal<void,Controllable*> GoingAway;
-
static sigc::signal<bool,PBD::Controllable*> StartLearning;
static sigc::signal<void,PBD::Controllable*> StopLearning;
sigc::signal<void> Changed;
- const PBD::ID& id() const { return _id; }
-
- int set_state (const XMLNode&) { return 0; }
+ int set_state (const XMLNode&);
XMLNode& get_state ();
+ std::string name() const { return _name; }
+
private:
- PBD::ID _id;
+ std::string _name;
};
}
diff --git a/libs/pbd/pbd/destructible.h b/libs/pbd/pbd/destructible.h
index 126bd04bba..6692ff564c 100644
--- a/libs/pbd/pbd/destructible.h
+++ b/libs/pbd/pbd/destructible.h
@@ -5,7 +5,7 @@
namespace PBD {
-class Destructible {
+class Destructible : public virtual sigc::trackable {
public:
Destructible() {}
virtual ~Destructible () {}
diff --git a/libs/pbd/pbd/id.h b/libs/pbd/pbd/id.h
index c110362734..eb3691d99e 100644
--- a/libs/pbd/pbd/id.h
+++ b/libs/pbd/pbd/id.h
@@ -27,7 +27,7 @@ class ID {
return _id < other._id;
}
- void print (char* buf) const;
+ void print (char* buf, uint32_t bufsize) const;
std::string to_s() const;
static uint64_t counter() { return _counter; }
diff --git a/libs/pbd/pbd/memento_command.h b/libs/pbd/pbd/memento_command.h
index f257e63233..715e9d33e3 100644
--- a/libs/pbd/pbd/memento_command.h
+++ b/libs/pbd/pbd/memento_command.h
@@ -30,10 +30,20 @@ using std::endl;
#include <sigc++/slot.h>
#include <typeinfo>
+/* grrr, strict C++ says that static member functions are not C functions, but we also want
+ to be able to pack this into a sigc::ptr_fun and not sigc::mem_fun, so we have to make
+ it a genuine function rather than a member.
+*/
+
+static void object_death (Command* mc) {
+ delete mc;
+}
+
/** This command class is initialized with before and after mementos
* (from Stateful::get_state()), so undo becomes restoring the before
* memento, and redo is restoring the after memento.
*/
+
template <class obj_T>
class MementoCommand : public Command
{
@@ -43,8 +53,9 @@ class MementoCommand : public Command
XMLNode *after
)
: obj(object), before(before), after(after) {
- obj.GoingAway.connect (sigc::mem_fun (*this, &MementoCommand<obj_T>::object_death));
+ obj.GoingAway.connect (sigc::bind (sigc::ptr_fun (object_death), static_cast<Command*>(this)));
}
+
~MementoCommand () {
GoingAway();
if (before) {
@@ -91,10 +102,6 @@ class MementoCommand : public Command
protected:
obj_T &obj;
XMLNode *before, *after;
-
- void object_death () {
- delete this;
- }
};
#endif // __lib_pbd_memento_h__
diff --git a/libs/pbd/pbd/restartable_rw.h b/libs/pbd/pbd/restartable_rw.h
deleted file mode 100644
index ee84e4e295..0000000000
--- a/libs/pbd/pbd/restartable_rw.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef __libmisc_restartable_rw__h__
-#define __libmisc_restartable_rw__h__
-
-extern int restartable_write (int fd, unsigned char *buf, size_t cnt);
-extern int restartable_read (int fd, unsigned char *buf, size_t cnt);
-
-#endif // __libmisc_restartable_rw__h__
diff --git a/libs/pbd/pbd/shiva.h b/libs/pbd/pbd/shiva.h
new file mode 100644
index 0000000000..5110f48332
--- /dev/null
+++ b/libs/pbd/pbd/shiva.h
@@ -0,0 +1,51 @@
+#ifndef __pbd_shiva_h__
+#define __pbd_shiva_h__
+
+#include <sigc++/sigc++.h>
+
+namespace PBD {
+
+template<typename ObjectWithGoingAway, typename ObjectToBeDestroyed>
+
+/* named after the Hindu god Shiva, The Destroyer */
+
+class Shiva {
+ public:
+ Shiva (ObjectWithGoingAway& emitter, ObjectToBeDestroyed& receiver) {
+
+ /* if the emitter goes away, destroy the receiver */
+
+ _connection1 = emitter.GoingAway.connect
+ (sigc::bind (sigc::mem_fun
+ (*this, &Shiva<ObjectWithGoingAway,ObjectToBeDestroyed>::destroy),
+ &receiver));
+
+ /* if the receiver goes away, forget all this nonsense */
+
+ _connection2 = receiver.GoingAway.connect
+ (sigc::mem_fun (*this, &Shiva<ObjectWithGoingAway,ObjectToBeDestroyed>::forget));
+ }
+
+ ~Shiva() {
+ forget ();
+ }
+
+ private:
+ sigc::connection _connection1;
+ sigc::connection _connection2;
+
+ void destroy (ObjectToBeDestroyed* obj) {
+ delete obj;
+ forget ();
+ }
+
+ void forget () {
+ _connection1.disconnect ();
+ _connection2.disconnect ();
+ }
+
+};
+
+}
+
+#endif /* __pbd_shiva_h__ */
diff --git a/libs/pbd/pbd/stacktrace.h b/libs/pbd/pbd/stacktrace.h
index d7278bd35a..fa90a07355 100644
--- a/libs/pbd/pbd/stacktrace.h
+++ b/libs/pbd/pbd/stacktrace.h
@@ -4,7 +4,7 @@
#include <ostream>
namespace PBD {
- void stacktrace (std::ostream& out);
+ void stacktrace (std::ostream& out, int levels = 0);
}
#endif /* __libpbd_stacktrace_h__ */
diff --git a/libs/pbd/pbd/undo.h b/libs/pbd/pbd/undo.h
index eecd8ae49d..943c115af2 100644
--- a/libs/pbd/pbd/undo.h
+++ b/libs/pbd/pbd/undo.h
@@ -40,8 +40,11 @@ class UndoTransaction : public Command
~UndoTransaction ();
void clear ();
+ bool empty() const;
+ bool clearing () const { return _clearing; }
void add_command (Command* const);
+ void remove_command (Command* const);
void operator() ();
void undo();
@@ -66,8 +69,7 @@ class UndoTransaction : public Command
std::list<Command*> actions;
struct timeval _timestamp;
std::string _name;
- bool clearing;
- void remove_command (Command* const);
+ bool _clearing;
};
class UndoHistory
@@ -94,7 +96,7 @@ class UndoHistory
void save_state();
private:
- bool clearing;
+ bool _clearing;
std::list<UndoTransaction*> UndoList;
std::list<UndoTransaction*> RedoList;