mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
Uncrustify. Sorry. :)
git-svn-id: svn://localhost/ardour2/branches/3.0@6704 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
29015dc5df
commit
5fe37dbc53
1 changed files with 130 additions and 127 deletions
|
|
@ -42,7 +42,10 @@ class PropertyChange : public std::set<PropertyID>
|
|||
{
|
||||
public:
|
||||
PropertyChange() {}
|
||||
template<typename T> PropertyChange(PropertyDescriptor<T> p) { insert (p.id); }
|
||||
|
||||
template<typename T>
|
||||
PropertyChange(PropertyDescriptor<T> p) { insert (p.id); }
|
||||
|
||||
PropertyChange(const PropertyChange& other) : std::set<PropertyID> (other) {}
|
||||
|
||||
PropertyChange operator=(const PropertyChange& other) {
|
||||
|
|
@ -51,13 +54,15 @@ class PropertyChange : public std::set<PropertyID>
|
|||
return *this;
|
||||
}
|
||||
|
||||
template<typename T> PropertyChange operator= (PropertyDescriptor<T> p) {
|
||||
template<typename T>
|
||||
PropertyChange operator=(PropertyDescriptor<T> p) {
|
||||
clear ();
|
||||
insert (p.id);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T> bool contains (PropertyDescriptor<T> p) const { return find (p.id) != end(); }
|
||||
template<typename T>
|
||||
bool contains (PropertyDescriptor<T> p) const { return find (p.id) != end (); }
|
||||
|
||||
bool contains (const PropertyChange& other) const {
|
||||
for (const_iterator x = other.begin (); x != other.end (); ++x) {
|
||||
|
|
@ -70,7 +75,8 @@ class PropertyChange : public std::set<PropertyID>
|
|||
|
||||
void add (PropertyID id) { (void) insert (id); }
|
||||
void add (const PropertyChange& other) { (void) insert (other.begin (), other.end ()); }
|
||||
template<typename T> void add (PropertyDescriptor<T> p) { (void) insert (p.id); }
|
||||
template<typename T>
|
||||
void add (PropertyDescriptor<T> p) { (void)insert (p.id); }
|
||||
};
|
||||
|
||||
/** Base (non template) part of Property */
|
||||
|
|
@ -78,11 +84,9 @@ class PropertyBase
|
|||
{
|
||||
public:
|
||||
PropertyBase (PropertyID pid)
|
||||
: _have_old (false)
|
||||
, _property_id (pid)
|
||||
{
|
||||
|
||||
}
|
||||
: _property_id (pid)
|
||||
, _have_old (false)
|
||||
{}
|
||||
|
||||
/** Forget about any old value for this state */
|
||||
void clear_history () {
|
||||
|
|
@ -102,8 +106,8 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
bool _have_old;
|
||||
PropertyID _property_id;
|
||||
bool _have_old;
|
||||
};
|
||||
|
||||
/** Parent class for classes which represent a single property in a Stateful object */
|
||||
|
|
@ -114,9 +118,8 @@ public:
|
|||
PropertyTemplate (PropertyDescriptor<T> p, T const& v)
|
||||
: PropertyBase (p.id)
|
||||
, _current (v)
|
||||
{
|
||||
{}
|
||||
|
||||
}
|
||||
PropertyTemplate<T>& operator=(PropertyTemplate<T> const& s) {
|
||||
/* XXX: isn't there a nicer place to do this? */
|
||||
_have_old = s._have_old;
|
||||
|
|
@ -218,9 +221,7 @@ class Property : public PropertyTemplate<T>
|
|||
public:
|
||||
Property (PropertyDescriptor<T> q, T const& v)
|
||||
: PropertyTemplate<T> (q, v)
|
||||
{
|
||||
|
||||
}
|
||||
{}
|
||||
|
||||
T & operator=(T const& v) {
|
||||
this->set (v);
|
||||
|
|
@ -228,12 +229,12 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
/* note that we do not set a locale for the streams used
|
||||
in to_string() or from_string(), because we want the
|
||||
format to be portable across locales (i.e. C or
|
||||
POSIX). Also, there is the small matter of
|
||||
std::locale aborting on OS X if used with anything
|
||||
other than C or POSIX locales.
|
||||
/* Note that we do not set a locale for the streams used
|
||||
* in to_string() or from_string(), because we want the
|
||||
* format to be portable across locales (i.e. C or
|
||||
* POSIX). Also, there is the small matter of
|
||||
* std::locale aborting on OS X if used with anything
|
||||
* other than C or POSIX locales.
|
||||
*/
|
||||
std::string to_string (T const& v) const {
|
||||
std::stringstream s;
|
||||
|
|
@ -248,11 +249,12 @@ private:
|
|||
t >> v;
|
||||
return v;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/** Specialization, for std::string which is common and special (see to_string() and from_string()
|
||||
Using stringstream to read from a std::string is easy to get wrong because of whitespace
|
||||
delineation, etc.
|
||||
* Using stringstream to read from a std::string is easy to get wrong because of whitespace
|
||||
* delineation, etc.
|
||||
*/
|
||||
template<>
|
||||
class Property<std::string> : public PropertyTemplate<std::string>
|
||||
|
|
@ -260,9 +262,7 @@ class Property<std::string> : public PropertyTemplate<std::string>
|
|||
public:
|
||||
Property (PropertyDescriptor<std::string> q, std::string const& v)
|
||||
: PropertyTemplate<std::string> (q, v)
|
||||
{
|
||||
|
||||
}
|
||||
{}
|
||||
|
||||
std::string & operator=(std::string const& v) {
|
||||
this->set (v);
|
||||
|
|
@ -277,46 +277,49 @@ private:
|
|||
std::string from_string (std::string const& s) const {
|
||||
return s;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class PropertyList : public std::map<PropertyID, PropertyBase*>
|
||||
{
|
||||
public:
|
||||
PropertyList() : property_owner (true) {}
|
||||
PropertyList() : _property_owner (true) {}
|
||||
virtual ~PropertyList() {
|
||||
if (property_owner)
|
||||
if (_property_owner) {
|
||||
for (std::map<PropertyID, PropertyBase*>::iterator i = begin (); i != end (); ++i) {
|
||||
delete i->second;
|
||||
}
|
||||
}
|
||||
/* classes that own property lists use this to add their
|
||||
property members to their plists.
|
||||
}
|
||||
|
||||
/* Classes that own property lists use this to add their
|
||||
* property members to their plists.
|
||||
*/
|
||||
bool add (PropertyBase& p) {
|
||||
return insert (value_type (p.id (), &p)).second;
|
||||
}
|
||||
|
||||
/* code that is constructing a property list for use
|
||||
in setting the state of an object uses this.
|
||||
/* Code that is constructing a property list for use
|
||||
* in setting the state of an object uses this.
|
||||
*/
|
||||
template<typename T, typename V> bool add (PropertyDescriptor<T> pid, const V& v) {
|
||||
template<typename T, typename V>
|
||||
bool add (PropertyDescriptor<T> pid, const V& v) {
|
||||
return insert (value_type (pid.id, new Property<T> (pid, (T)v))).second;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool property_owner;
|
||||
bool _property_owner;
|
||||
};
|
||||
|
||||
/** A variant of PropertyList that does not delete its
|
||||
property list in its destructor. Objects with their
|
||||
own Properties store them in an OwnedPropertyList
|
||||
to avoid having them deleted at the wrong time.
|
||||
* property list in its destructor. Objects with their
|
||||
* own Properties store them in an OwnedPropertyList
|
||||
* to avoid having them deleted at the wrong time.
|
||||
*/
|
||||
|
||||
class OwnedPropertyList : public PropertyList
|
||||
{
|
||||
public:
|
||||
OwnedPropertyList() { property_owner = false; }
|
||||
OwnedPropertyList() { _property_owner = false; }
|
||||
};
|
||||
|
||||
} /* namespace PBD */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue