fix visual focus indication in IOSelector; import pays attention to audio file embedd...
[ardour.git] / libs / ardour / ardour / automation_event.h
index 562a424cc794a7a2cfe3a58675ee599ec02eeb0f..459ec2b6cf881da727f1eabcbbcdfacc8bc06cac 100644 (file)
 #include <cmath>
 
 #include <sigc++/signal.h>
-#include <pbd/lockmonitor.h>
+#include <glibmm/thread.h>
+
 #include <pbd/undo.h>
 #include <pbd/xml++.h>
+#include <pbd/statefuldestructible.h> 
+
 #include <ardour/ardour.h>
-#include <ardour/state_manager.h>
 
 namespace ARDOUR {
        
@@ -51,14 +53,15 @@ struct ControlEvent {
 
 };
 
-class AutomationList : public StateManager
+class AutomationList : public PBD::StatefulDestructible
 {
   public:
        typedef std::list<ControlEvent*> AutomationEventList;
        typedef AutomationEventList::iterator iterator;
        typedef AutomationEventList::const_iterator const_iterator;
 
-       AutomationList(double default_value, bool no_state = false);
+       AutomationList (double default_value);
+       AutomationList (const XMLNode&);
        ~AutomationList();
 
        AutomationList (const AutomationList&);
@@ -82,9 +85,11 @@ class AutomationList : public StateManager
 
        void reposition_for_rt_add (double when);
        void rt_add (double when, double value);
-       iterator add (double when, double value, iterator, bool ignore_mode = false);
-       void add (double when, double value, bool for_loading = false);
+       void add (double when, double value);
+       /* this should be private but old-school automation loading needs it in IO/Redirect */
+       void fast_simple_add (double when, double value);
 
+       void reset_range (double start, double end);
        void erase_range (double start, double end);
        void erase (iterator);
        void erase (iterator, iterator);
@@ -143,26 +148,28 @@ class AutomationList : public StateManager
        std::pair<AutomationList::iterator,AutomationList::iterator> control_points_adjacent (double when);
 
        template<class T> void apply_to_points (T& obj, void (T::*method)(const AutomationList&)) {
-               LockMonitor lm (lock, __LINE__, __FILE__);
+               Glib::Mutex::Lock lm (lock);
                (obj.*method)(*this);
        }
 
-       UndoAction get_memento () const;
-       
-       virtual void store_state (XMLNode& node) const;
-       virtual void load_state (const XMLNode&);
+       sigc::signal<void,Change> StateChanged;
+
+       XMLNode& get_state(void); 
+       int set_state (const XMLNode &s);
+       XMLNode& state (bool full);
+       XMLNode& serialize_events ();
 
        void set_max_xval (double);
        double get_max_xval() const { return max_xval; }
 
        double eval (double where) {
-               LockMonitor lm (lock, __LINE__, __FILE__);
+               Glib::Mutex::Lock lm (lock);
                return unlocked_eval (where);
        }
 
        double rt_safe_eval (double where, bool& ok) {
 
-               TentativeLockMonitor lm (lock, __LINE__, __FILE__);
+               Glib::Mutex::Lock lm (lock, Glib::TRY_LOCK);
 
                if ((ok = lm.locked())) {
                        return unlocked_eval (where);
@@ -177,15 +184,12 @@ class AutomationList : public StateManager
                }
        };
 
-  protected:
-       struct State : public ARDOUR::StateManager::State {
-           AutomationEventList events;
+        static sigc::signal<void, AutomationList*> AutomationListCreated;
 
-           State (std::string why) : ARDOUR::StateManager::State (why) {}
-       };
+  protected:
 
        AutomationEventList events;
-       mutable PBD::NonBlockingLock lock;
+       mutable Glib::Mutex lock;
        bool   _frozen;
        bool    changed_when_thawed;
        bool   _dirty;
@@ -205,7 +209,6 @@ class AutomationList : public StateManager
        double min_yval;
        double max_yval;
        double default_value;
-       bool   no_state;
 
        iterator rt_insertion_point;
        double   rt_pos;
@@ -232,14 +235,12 @@ class AutomationList : public StateManager
 
        virtual double unlocked_eval (double where);
 
-       Change   restore_state (StateManager::State&);
-       StateManager::State* state_factory (std::string why) const;
-
        virtual ControlEvent* point_factory (double,double) const;
        virtual ControlEvent* point_factory (const ControlEvent&) const;
 
-
        AutomationList* cut_copy_clear (double, double, int op);
+
+       int deserialize_events (const XMLNode&);
 };
 
 } // namespace