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
This commit is contained in:
Carl Hetherington
2010-02-10 01:38:20 +00:00
parent c9d433d9b3
commit 3c00a7ca2a
30 changed files with 202 additions and 170 deletions

View File

@@ -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