diff options
author | Carl Hetherington <carl@carlh.net> | 2010-02-10 01:38:20 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2010-02-10 01:38:20 +0000 |
commit | 3c00a7ca2ae34cb65c8d3394d9a012f20c69ee77 (patch) | |
tree | 54257f7655152fab7fbe97a75ce24faf15485d49 /libs/pbd/stateful.cc | |
parent | c9d433d9b3f166e761bfc1b4765cc51b0a521e7d (diff) |
Move ARDOUR::Change into PBD so that Stateful can be aware of
what Change a State reflects. Hence allow Stateful to do some
of the work of set/get_state in Region.
git-svn-id: svn://localhost/ardour2/branches/3.0@6671 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd/stateful.cc')
-rw-r--r-- | libs/pbd/stateful.cc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/libs/pbd/stateful.cc b/libs/pbd/stateful.cc index 52b80c95ae..a50c54d7f5 100644 --- a/libs/pbd/stateful.cc +++ b/libs/pbd/stateful.cc @@ -35,6 +35,27 @@ namespace PBD { int Stateful::current_state_version = 0; int Stateful::loading_state_version = 0; +PBD::Change +new_change () +{ + Change c; + static uint32_t change_bit = 1; + + /* catch out-of-range */ + if (!change_bit) + { + fatal << _("programming error: ") + << "change_bit out of range in ARDOUR::new_change()" + << endmsg; + /*NOTREACHED*/ + } + + c = Change (change_bit); + change_bit <<= 1; // if it shifts too far, change_bit == 0 + + return c; +} + Stateful::Stateful () { _extra_xml = 0; @@ -175,5 +196,32 @@ Stateful::diff () return make_pair (old, current); } + +/** Set state of _states from an XML node. + * @param node Node. + * @return Changes made. + */ +Change +Stateful::set_state_using_states (XMLNode const & node) +{ + Change c = Change (0); + + for (list<StateBase*>::iterator i = _states.begin(); i != _states.end(); ++i) { + c = Change (c | (*i)->set_state (node)); + } + + return c; +} + +/** Add state of _states to an XML node. + * @param node Node. + */ +void +Stateful::add_states (XMLNode & node) +{ + for (list<StateBase*>::iterator i = _states.begin(); i != _states.end(); ++i) { + (*i)->add_state (node); + } +} } // namespace PBD |