add a const - just because.
[ardour.git] / libs / ardour / ardour / region_factory.h
index 4ba261f80c8c3a3981f2236a42237471f326b750..6971e772426f94c8d69a12202eed4cdb185b91cf 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/libardour_visibility.h"
 #include "ardour/types.h"
 
 class XMLNode;
+class RegionNamingTest;
 
 namespace ARDOUR {
 
 class Session;
 class AudioRegion;
 
-class RegionFactory {
+class LIBARDOUR_API RegionFactory {
 public:
        typedef std::map<PBD::ID,boost::shared_ptr<Region> > RegionMap;
 
@@ -57,7 +59,7 @@ public:
        static PBD::Signal1<void,boost::shared_ptr<Region> >  CheckNewRegion;
 
        /** create a "pure copy" of Region @param other */
-       static boost::shared_ptr<Region> create (boost::shared_ptr<const Region> other, bool announce = false);
+       static boost::shared_ptr<Region> create (boost::shared_ptr<const Region> other, bool announce = false, const int32_t sub_num = 0);
 
        /** create a region from a single Source */
        static boost::shared_ptr<Region> create (boost::shared_ptr<Source>,
@@ -71,7 +73,7 @@ public:
                                                 const PBD::PropertyList&, bool announce = true);
        /** create a copy of @param other starting at @param offset within @param other */
        static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other, frameoffset_t offset,
-                                                const PBD::PropertyList&, bool announce = true);
+                                                const PBD::PropertyList&, bool announce = true, const int32_t sub_num = 0);
        /** create a "copy" of @param other but using a different set of sources @param srcs */
        static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other, const SourceList& srcs,
                                                 const PBD::PropertyList&, bool announce = true);
@@ -115,21 +117,27 @@ public:
         * 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 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 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;