20 #ifndef __libpbd_sequence_property_h__
21 #define __libpbd_sequence_property_h__
28 #include <boost/function.hpp>
46 template<
typename Container>
55 void add (
typename Container::value_type
const & r) {
56 typename ChangeContainer::iterator i =
removed.find (r);
67 void remove (
typename Container::value_type
const & r) {
68 typename ChangeContainer::iterator i =
added.find (r);
69 if (i !=
added.end()) {
127 for (
typename Container::const_iterator i =
_val.begin(); i !=
_val.end(); ++i) {
142 const ChangeRecord& change (dynamic_cast<const SequenceProperty*> (p)->
changes ());
187 XMLNodeList::const_iterator i = children.begin();
188 while (i != children.end() && (*i)->name() != c) {
192 if (i == children.end()) {
200 XMLNodeList const & grandchildren = (*i)->children ();
201 for (XMLNodeList::const_iterator j = grandchildren.begin(); j != grandchildren.end(); ++j) {
206 warning <<
"undo transaction references an unknown object" <<
endmsg;
207 }
else if ((*j)->name() ==
"Add") {
209 }
else if ((*j)->name() ==
"Remove") {
221 for (
typename Container::iterator i =
begin(); i !=
end(); ++i) {
222 (*i)->clear_changes ();
226 void rdiff (std::vector<Command*>& cmds)
const {
227 for (
typename Container::const_iterator i =
begin(); i !=
end(); ++i) {
228 if ((*i)->changed ()) {
230 cmds.push_back (sdc);
240 typename Container::iterator
begin() {
return _val.begin(); }
241 typename Container::iterator
end() {
return _val.end(); }
242 typename Container::const_iterator
begin()
const {
return _val.begin(); }
243 typename Container::const_iterator
end()
const {
return _val.end(); }
245 typename Container::reverse_iterator
rbegin() {
return _val.rbegin(); }
246 typename Container::reverse_iterator
rend() {
return _val.rend(); }
247 typename Container::const_reverse_iterator
rbegin()
const {
return _val.rbegin(); }
248 typename Container::const_reverse_iterator
rend()
const {
return _val.rend(); }
250 typename Container::iterator
insert (
typename Container::iterator i,
const typename Container::value_type& v) {
252 return _val.insert (i, v);
255 typename Container::iterator
erase (
typename Container::iterator i) {
256 if (i !=
_val.end()) {
259 return _val.erase (i);
262 typename Container::iterator
erase (
typename Container::iterator
f,
typename Container::iterator l) {
263 for (
typename Container::const_iterator i = f; i != l; ++i) {
266 return _val.erase (f, l);
269 void remove (
const typename Container::value_type& v) {
274 void push_back (
const typename Container::value_type& v) {
299 for (
typename Container::iterator i =
_val.begin(); i !=
_val.end(); ++i) {
305 typename Container::size_type
size()
const {
314 for (
typename Container::const_iterator i =
_val.begin(); i !=
_val.end(); ++i) {
317 for (
typename Container::const_iterator i = other.begin(); i != other.end(); ++i) {
323 typename Container::reference
front() {
324 return _val.front ();
327 typename Container::const_reference
front()
const {
328 return _val.front ();
331 typename Container::reference
back() {
335 typename Container::const_reference
back()
const {
343 template<
class BinaryPredicate>
void sort(BinaryPredicate comp) {
void push_back(const typename Container::value_type &v)
void remove(typename Container::value_type const &r)
string capitalize(const string &str)
Container::const_iterator end() const
virtual Container::value_type get_content_from_xml(XMLNode const &node) const =0
void add(typename Container::value_type const &r)
Container::reverse_iterator rend()
Container::iterator begin()
void clear_owned_changes()
void push_front(const typename Container::value_type &v)
void update(const ChangeRecord &cr)
LIBPBD_API Transmitter warning
const XMLNodeList & children(const std::string &str=std::string()) const
std::set< typename Container::value_type > ChangeContainer
std::ostream & endmsg(std::ostream &ostr)
void sort(BinaryPredicate comp)
Container::iterator insert(typename Container::iterator i, const typename Container::value_type &v)
Container::const_reverse_iterator rbegin() const
std::list< XMLNode * > XMLNodeList
class LIBPBD_API StatefulDiffCommand
void remove_node(GraphNode *node)
bool set_value(XMLNode const &)
Container::iterator end()
Container::iterator erase(typename Container::iterator i)
ChangeRecord _changes
changes to the container (adds/removes) that have happened since clear_changes() was last called ...
void apply_changes(PropertyBase const *p)
void get_value(XMLNode &node) const
SequenceProperty(SequenceProperty< Container > const &p)
Container::reverse_iterator rbegin()
Container::const_iterator begin() const
void get_changes_as_properties(PBD::PropertyList &changes, Command *cmd) const
Container::size_type size() const
const ChangeRecord & changes() const
void add_child_nocopy(XMLNode &)
void get_changes_as_xml(XMLNode *history_node) const
const gchar * property_name() const
Container _val
our actual container of things
Container::reference back()
SequenceProperty(PropertyID id, const boost::function< void(const ChangeRecord &)> &update)
virtual SequenceProperty< Container > * create() const =0
void rdiff(std::vector< Command * > &cmds) const
Container::iterator erase(typename Container::iterator f, typename Container::iterator l)
Container::const_reference back() const
boost::function< void(const ChangeRecord &)> _update_callback
Container::const_reverse_iterator rend() const
Container::const_reference front() const
SequenceProperty< Container > * clone_from_xml(XMLNode const &node) const
bool add(PropertyBase *prop)
virtual void get_content_as_xml(typename ChangeContainer::value_type, XMLNode &) const =0
Container & operator=(const Container &other)
Container::reference front()