#include "pbd/undo.h"
#include "pbd/stateful.h"
-#include "pbd/stateful_owner.h"
#include "pbd/statefuldestructible.h"
#include "pbd/sequence_property.h"
Playlist& _playlist;
};
-class Playlist : public SessionObject
- , public PBD::StatefulOwner
- , public boost::enable_shared_from_this<Playlist> {
- public:
- typedef std::list<boost::shared_ptr<Region> > RegionList;
+class Playlist : public SessionObject , public boost::enable_shared_from_this<Playlist>
+{
+public:
+ typedef std::list<boost::shared_ptr<Region> > RegionList;
static void make_property_quarks ();
Playlist (Session&, const XMLNode&, DataType type, bool hidden = false);
virtual ~Playlist ();
- bool set_property (const PBD::PropertyBase&);
void update (const RegionListProperty::ChangeRecord&);
void clear_owned_history ();
void rdiff (std::vector<PBD::StatefulDiffCommand*>&) const;
- PBD::PropertyList* property_factory (const XMLNode&) const;
-
boost::shared_ptr<Region> region_by_id (const PBD::ID&);
void set_region_ownership ();
static PBD::Signal2<void,boost::shared_ptr<ARDOUR::Region>, const PBD::PropertyChange&> RegionPropertyChanged;
- PBD::PropertyList* property_factory (const XMLNode&) const;
-
virtual ~Region();
/** Note: changing the name of a Region does not constitute an edit */
}
}
-bool
-Playlist::set_property (const PropertyBase& prop)
-{
- if (prop == Properties::regions.property_id) {
- const RegionListProperty::ChangeRecord& change (dynamic_cast<const RegionListProperty*>(&prop)->change());
- regions.update (change);
- return (!change.added.empty() && !change.removed.empty());
- }
- return false;
-}
-
void
Playlist::rdiff (vector<StatefulDiffCommand*>& cmds) const
{
RegionLock rlock (const_cast<Playlist *> (this));
-
- for (RegionList::const_iterator i = regions.begin(); i != regions.end(); ++i) {
- if ((*i)->changed ()) {
- StatefulDiffCommand* sdc = new StatefulDiffCommand (*i);
- cmds.push_back (sdc);
- }
- }
+ Stateful::rdiff (cmds);
}
void
Playlist::clear_owned_history ()
{
RegionLock rlock (this);
-
- for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
- (*i)->clear_history ();
- }
+ Stateful::clear_owned_history ();
}
void
thaw ();
}
-PropertyList*
-Playlist::property_factory (const XMLNode& history_node) const
-{
- const XMLNodeList& children (history_node.children());
- PropertyList* prop_list = 0;
-
- for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
-
- if ((*i)->name() == capitalize (regions.property_name())) {
-
- RegionListProperty* rlp = new RegionListProperty (*const_cast<Playlist*> (this));
-
- if (rlp->set_change (**i)) {
- if (!prop_list) {
- prop_list = new PropertyList();
- }
- prop_list->add (rlp);
- } else {
- delete rlp;
- }
- }
- }
-
- return prop_list;
-}
-
int
Playlist::set_state (const XMLNode& node, int version)
{
}
}
}
-
-PropertyList*
-Region::property_factory (const XMLNode& history_node) const
-{
- PropertyList* prop_list = new PropertyList;
-
- for (OwnedPropertyList::const_iterator i = _properties->begin(); i != _properties->end(); ++i) {
- PropertyBase* prop = i->second->maybe_clone_self_if_found_in_history_node (history_node);
-
- if (prop) {
- prop_list->add (prop);
- }
- }
-
- return prop_list;
-}
#include <glib.h>
#include <set>
+#include <vector>
#include "pbd/xml++.h"
namespace PBD {
class PropertyList;
+class StatefulDiffCommand;
/** A unique identifier for a property of a Stateful object */
typedef GQuark PropertyID;
/** Forget about any old value for this state */
virtual void clear_history () = 0;
+ /** Tell any things we own to forget about their old values */
+ virtual void clear_owned_history () {}
+
/** Get any change in this property as XML and add it to a node */
virtual void get_change (XMLNode *) const = 0;
* of those changes.
*/
virtual void diff (PropertyList& undo, PropertyList& redo, Command*) const = 0;
-
+
+ /** Collect StatefulDiffCommands for changes to anything that we own */
+ virtual void rdiff (std::vector<StatefulDiffCommand*> &) const {}
+
virtual PropertyBase* maybe_clone_self_if_found_in_history_node (const XMLNode&) const { return 0; }
/** Set our value from an XML node.
}
}
+ SequenceProperty<Container>* maybe_clone_self_if_found_in_history_node (XMLNode const & node) const {
+
+ XMLNodeList const children = node.children ();
+
+ for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
+
+ if ((*i)->name() == capitalize (property_name())) {
+
+ SequenceProperty<Container>* p = create ();
+
+ if (p->set_change (**i)) {
+ return p;
+ } else {
+ delete p;
+ }
+ }
+ }
+
+ return 0;
+ }
+
+ void clear_owned_history () {
+ for (typename Container::iterator i = begin(); i != end(); ++i) {
+ (*i)->clear_history ();
+ }
+ }
+
+ void rdiff (std::vector<StatefulDiffCommand*>& cmds) const {
+ for (typename Container::const_iterator i = begin(); i != end(); ++i) {
+ if ((*i)->changed ()) {
+ StatefulDiffCommand* sdc = new StatefulDiffCommand (*i);
+ cmds.push_back (sdc);
+ }
+ }
+ }
+
+
+
Container rlist() { return _val; }
-
+
/* Wrap salient methods of Sequence
*/
/* history management */
void clear_history ();
+ virtual void clear_owned_history ();
void diff (PropertyList&, PropertyList&, Command*) const;
+ virtual void rdiff (std::vector<StatefulDiffCommand*> &) const;
bool changed() const;
/* create a property list from an XMLNode
*/
- virtual PropertyList* property_factory(const XMLNode&) const { return 0; }
+ virtual PropertyList* property_factory (const XMLNode&) const;
/* How stateful's notify of changes to their properties
*/
return true;
}
+PropertyList*
+Stateful::property_factory (const XMLNode& history_node) const
+{
+ PropertyList* prop_list = new PropertyList;
+
+ for (OwnedPropertyList::const_iterator i = _properties->begin(); i != _properties->end(); ++i) {
+ PropertyBase* prop = i->second->maybe_clone_self_if_found_in_history_node (history_node);
+
+ if (prop) {
+ prop_list->add (prop);
+ }
+ }
+
+ return prop_list;
+}
+
+void
+Stateful::rdiff (vector<StatefulDiffCommand*>& cmds) const
+{
+ for (OwnedPropertyList::const_iterator i = _properties->begin(); i != _properties->end(); ++i) {
+ i->second->rdiff (cmds);
+ }
+}
+
+void
+Stateful::clear_owned_history ()
+{
+ for (OwnedPropertyList::iterator i = _properties->begin(); i != _properties->end(); ++i) {
+ i->second->clear_owned_history ();
+ }
+}
+
+
} // namespace PBD