use AudioEngine destructor to do necessary stuff when shutting it down, and remove...
[ardour.git] / libs / ardour / ardour / region_factory.h
index 337821e0eaa7f77d29ba5094ad248cfa6554b3e7..ed0c962d879a7adae199e410b830a56d574e6984 100644 (file)
 
 #include <map>
 #include <set>
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
 
 #include "pbd/id.h"
+#include "pbd/property_list.h"
 #include "pbd/signals.h"
 
 #include "ardour/types.h"
 
 class XMLNode;
+class RegionNamingTest;
 
 namespace ARDOUR {
 
@@ -84,7 +86,6 @@ public:
        static void remove_regions_using_source (boost::shared_ptr<Source>);
 
        static void map_remove (boost::weak_ptr<Region>);
-       static void map_remove_with_equivalents (boost::shared_ptr<Region>);
        static void delete_all_regions ();
        static const RegionMap& regions() { return region_map; }
        static uint32_t nregions ();
@@ -111,21 +112,33 @@ public:
 
        static void add_compound_association (boost::shared_ptr<Region>, boost::shared_ptr<Region>);
 
+       /* exposed because there may be cases where regions are created with
+        * announce=false but they still need to be in the map soon after
+        * creation.
+        */
+        
+       static void map_add (boost::shared_ptr<Region>);
+
   private:
+       friend class ::RegionNamingTest;
 
        static void region_changed (PBD::PropertyChange const &, boost::weak_ptr<Region>);
 
-       static Glib::StaticMutex region_map_lock;
+        static Glib::Threads::Mutex region_map_lock;
 
        static RegionMap region_map;
-       static void map_add (boost::shared_ptr<Region>);
-
-       static Glib::StaticMutex region_name_map_lock;
-
-       static std::map<std::string, uint32_t> region_name_map;
-       static void update_region_name_map (boost::shared_ptr<Region>);
 
-       static PBD::ScopedConnectionList region_list_connections;
+       static Glib::Threads::Mutex region_name_maps_mutex;
+       /** map of partial region names and suffix numbers */
+       static std::map<std::string, uint32_t> region_name_number_map;
+       /** map of complete region names with their region ID */
+       static std::map<std::string, PBD::ID> region_name_map;
+       static void add_to_region_name_maps (boost::shared_ptr<Region>);
+       static void rename_in_region_name_maps (boost::shared_ptr<Region>);
+       static void update_region_name_number_map (boost::shared_ptr<Region>);
+       static void remove_from_region_name_map (std::string);
+
+       static PBD::ScopedConnectionList* region_list_connections;
        static CompoundAssociations _compound_associations;
 };