13
0

NO-OP: clang-format

This commit is contained in:
Robin Gareus 2021-05-01 14:52:35 +02:00
parent 3e04e30e9e
commit 747a3d4a7b
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 156 additions and 170 deletions

View File

@ -24,16 +24,15 @@
#ifndef __ardour_region_factory_h__
#define __ardour_region_factory_h__
#include <glibmm/threads.h>
#include <map>
#include <set>
#include <glibmm/threads.h>
#include "pbd/id.h"
#include "pbd/property_list.h"
#include "pbd/signals.h"
#include "ardour/libardour_visibility.h"
#include "ardour/thawlist.h"
#include "ardour/types.h"
class XMLNode;
@ -41,52 +40,52 @@ class RegionNamingTest;
namespace ARDOUR {
class Session;
class AudioRegion;
class Session;
class ThawList;
class LIBARDOUR_API RegionFactory {
class LIBARDOUR_API RegionFactory
{
public:
typedef std::map<PBD::ID,boost::shared_ptr<Region> > RegionMap;
typedef std::map<PBD::ID, boost::shared_ptr<Region> > RegionMap;
static boost::shared_ptr<Region> wholefile_region_by_name (const std::string& name);
static boost::shared_ptr<Region> region_by_id (const PBD::ID&);
static boost::shared_ptr<Region> region_by_name (const std::string& name);
static const RegionMap all_regions() { return region_map; }
static void clear_map ();
static void clear_map ();
static const RegionMap all_regions ()
{
return region_map;
}
/** This is emitted only when a new id is assigned. Therefore,
in a pure Region copy, it will not be emitted.
It must be emitted using a derived instance of Region, not Region
itself, to permit dynamic_cast<> to be used to
infer the type of Region.
*/
static PBD::Signal1<void,boost::shared_ptr<Region> > CheckNewRegion;
* in a pure Region copy, it will not be emitted.
*
* It must be emitted using a derived instance of Region, not Region
* itself, to permit dynamic_cast<> to be used to
* infer the type of Region.
*/
static PBD::Signal1<void, boost::shared_ptr<Region> > CheckNewRegion;
/** create a "pure copy" of Region \p other */
static boost::shared_ptr<Region> create (boost::shared_ptr<const Region> other, bool announce, bool fork = false, ThawList* tl = 0);
/** Lua binding to create a "pure copy" of Region \p other */
static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other, bool announce, bool fork) {
return create (boost::shared_ptr<const Region>(other), announce, fork, 0);
static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other, bool announce, bool fork)
{
return create (boost::shared_ptr<const Region> (other), announce, fork, 0);
}
/** create a region from a single Source */
static boost::shared_ptr<Region> create (boost::shared_ptr<Source>,
const PBD::PropertyList&, bool announce = true, ThawList* tl = 0);
static boost::shared_ptr<Region> create (boost::shared_ptr<Source>, const PBD::PropertyList&, bool announce = true, ThawList* tl = 0);
/** create a region from a multiple sources */
static boost::shared_ptr<Region> create (const SourceList &,
const PBD::PropertyList&, bool announce = true, ThawList* tl = 0);
static boost::shared_ptr<Region> create (const SourceList&, const PBD::PropertyList&, bool announce = true, ThawList* tl = 0);
/** create a copy of \p other starting at zero within \p other's sources */
static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other,
const PBD::PropertyList&, bool announce = true, ThawList* tl = 0);
static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other, const PBD::PropertyList&, bool announce = true, ThawList* tl = 0);
/** create a copy of \p other starting at \p offset within \p other */
static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other, ARDOUR::MusicSample offset,
const PBD::PropertyList&, bool announce = true, ThawList* tl = 0);
static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other, ARDOUR::MusicSample offset, const PBD::PropertyList&, bool announce = true, ThawList* tl = 0);
/** create a "copy" of \p other but using a different set of sources \p srcs */
static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other, const SourceList& srcs,
const PBD::PropertyList&, bool announce = true, ThawList* tl = 0);
static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other, const SourceList& srcs, const PBD::PropertyList&, bool announce = true, ThawList* tl = 0);
/** create a region with no sources, using XML state */
static boost::shared_ptr<Region> create (Session&, XMLNode&, bool);
@ -94,25 +93,29 @@ public:
static boost::shared_ptr<Region> create (SourceList& srcs, const XMLNode&);
static boost::shared_ptr<Region> get_whole_region_for_source (boost::shared_ptr<ARDOUR::Source>);
static void get_regions_using_source (boost::shared_ptr<Source>, std::set<boost::shared_ptr<Region> >& );
static void get_regions_using_source (boost::shared_ptr<Source>, std::set<boost::shared_ptr<Region> >&);
static void remove_regions_using_source (boost::shared_ptr<Source>);
static void map_remove (boost::weak_ptr<Region>);
static void delete_all_regions ();
static const RegionMap& regions() { return region_map; }
static const RegionMap& regions ()
{
return region_map;
}
static uint32_t nregions ();
static void foreach_region (boost::function<void( boost::shared_ptr<Region> )> f) {
static void foreach_region (boost::function<void (boost::shared_ptr<Region>)> f)
{
Glib::Threads::Mutex::Lock ls (region_map_lock);
for (RegionMap::const_iterator i = region_map.begin(); i != region_map.end(); ++i) {
f ( (*i).second );
for (RegionMap::const_iterator i = region_map.begin (); i != region_map.end (); ++i) {
f ((*i).second);
}
}
static int region_name (std::string &, std::string, bool new_level = false);
static int region_name (std::string&, std::string, bool new_level = false);
static std::string new_region_name (std::string);
static std::string compound_region_name (const std::string& playlist, uint32_t compound_ops, uint32_t depth, bool whole_source);
@ -130,7 +133,11 @@ public:
*/
typedef std::map<boost::shared_ptr<Region>, boost::shared_ptr<Region> > CompoundAssociations;
static CompoundAssociations& compound_associations() { return _compound_associations; }
static CompoundAssociations& compound_associations ()
{
return _compound_associations;
}
static void add_compound_association (boost::shared_ptr<Region>, boost::shared_ptr<Region>);
@ -141,29 +148,28 @@ public:
static void map_add (boost::shared_ptr<Region>);
private:
private:
friend class ::RegionNamingTest;
static void region_changed (PBD::PropertyChange const &, boost::weak_ptr<Region>);
static void region_changed (PBD::PropertyChange const&, boost::weak_ptr<Region>);
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 Glib::Threads::Mutex region_map_lock;
static RegionMap region_map;
static Glib::Threads::Mutex region_map_lock;
static RegionMap region_map;
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;
static CompoundAssociations _compound_associations;
};
}
} // namespace ARDOUR
#endif /* __ardour_region_factory_h__ */

View File

@ -34,6 +34,7 @@
#include "ardour/region.h"
#include "ardour/region_factory.h"
#include "ardour/session.h"
#include "ardour/thawlist.h"
#include "pbd/i18n.h"
@ -41,40 +42,38 @@ using namespace ARDOUR;
using namespace PBD;
using namespace std;
PBD::Signal1<void,boost::shared_ptr<Region> > RegionFactory::CheckNewRegion;
Glib::Threads::Mutex RegionFactory::region_map_lock;
RegionFactory::RegionMap RegionFactory::region_map;
PBD::ScopedConnectionList* RegionFactory::region_list_connections = 0;
Glib::Threads::Mutex RegionFactory::region_name_maps_mutex;
std::map<std::string, uint32_t> RegionFactory::region_name_number_map;
std::map<std::string, PBD::ID> RegionFactory::region_name_map;
RegionFactory::CompoundAssociations RegionFactory::_compound_associations;
PBD::Signal1<void, boost::shared_ptr<Region> > RegionFactory::CheckNewRegion;
Glib::Threads::Mutex RegionFactory::region_map_lock;
RegionFactory::RegionMap RegionFactory::region_map;
PBD::ScopedConnectionList* RegionFactory::region_list_connections = 0;
Glib::Threads::Mutex RegionFactory::region_name_maps_mutex;
std::map<std::string, uint32_t> RegionFactory::region_name_number_map;
std::map<std::string, PBD::ID> RegionFactory::region_name_map;
RegionFactory::CompoundAssociations RegionFactory::_compound_associations;
boost::shared_ptr<Region>
RegionFactory::create (boost::shared_ptr<const Region> region, bool announce, bool fork, ThawList* tl)
{
boost::shared_ptr<Region> ret;
boost::shared_ptr<Region> ret;
boost::shared_ptr<const AudioRegion> ar;
boost::shared_ptr<const MidiRegion> mr;
if ((ar = boost::dynamic_pointer_cast<const AudioRegion>(region)) != 0) {
boost::shared_ptr<const MidiRegion> mr;
if ((ar = boost::dynamic_pointer_cast<const AudioRegion> (region)) != 0) {
ret = boost::shared_ptr<Region> (new AudioRegion (ar, MusicSample (0, 0)));
} else if ((mr = boost::dynamic_pointer_cast<const MidiRegion>(region)) != 0) {
if (mr->session().config.get_midi_copy_is_fork() || fork) {
} else if ((mr = boost::dynamic_pointer_cast<const MidiRegion> (region)) != 0) {
if (mr->session ().config.get_midi_copy_is_fork () || fork) {
/* What we really want to do here is what Editor::fork_region()
does via Session::create_midi_source_by_stealing_name(), but we
don't have a Track. We'll just live with the skipped number,
and store the ancestral name of sources so multiple clones
generates reasonable names that don't have too many suffixes. */
const std::string ancestor_name = mr->sources().front()->ancestor_name();
const std::string base = PBD::basename_nosuffix(ancestor_name);
const std::string ancestor_name = mr->sources ().front ()->ancestor_name ();
const std::string base = PBD::basename_nosuffix (ancestor_name);
boost::shared_ptr<MidiSource> source = mr->session().create_midi_source_for_session(base);
source->set_ancestor_name(mr->sources().front()->name());
ret = mr->clone(source);
boost::shared_ptr<MidiSource> source = mr->session ().create_midi_source_for_session (base);
source->set_ancestor_name (mr->sources ().front ()->name ());
ret = mr->clone (source);
} else {
ret = boost::shared_ptr<Region> (new MidiRegion (mr, MusicSample (0, 0)));
}
@ -82,7 +81,7 @@ RegionFactory::create (boost::shared_ptr<const Region> region, bool announce, bo
} else {
fatal << _("programming error: RegionFactory::create() called with unknown Region type")
<< endmsg;
abort(); /*NOTREACHED*/
abort (); /*NOTREACHED*/
}
if (ret) {
@ -91,9 +90,9 @@ RegionFactory::create (boost::shared_ptr<const Region> region, bool announce, bo
tl->add (ret);
}
ret->set_name (new_region_name(ret->name()));
ret->set_name (new_region_name (ret->name ()));
if (ret->session().config.get_glue_new_regions_to_bars_and_beats() && ret->position_lock_style() != MusicTime) {
if (ret->session ().config.get_glue_new_regions_to_bars_and_beats () && ret->position_lock_style () != MusicTime) {
ret->set_position_lock_style (MusicTime);
}
@ -111,23 +110,21 @@ RegionFactory::create (boost::shared_ptr<const Region> region, bool announce, bo
boost::shared_ptr<Region>
RegionFactory::create (boost::shared_ptr<Region> region, const PropertyList& plist, bool announce, ThawList* tl)
{
boost::shared_ptr<Region> ret;
boost::shared_ptr<Region> ret;
boost::shared_ptr<const AudioRegion> other_a;
boost::shared_ptr<const MidiRegion> other_m;
if ((other_a = boost::dynamic_pointer_cast<AudioRegion>(region)) != 0) {
boost::shared_ptr<const MidiRegion> other_m;
if ((other_a = boost::dynamic_pointer_cast<AudioRegion> (region)) != 0) {
ret = boost::shared_ptr<Region> (new AudioRegion (other_a));
} else if ((other_m = boost::dynamic_pointer_cast<MidiRegion>(region)) != 0) {
} else if ((other_m = boost::dynamic_pointer_cast<MidiRegion> (region)) != 0) {
ret = boost::shared_ptr<Region> (new MidiRegion (other_m));
} else {
fatal << _("programming error: RegionFactory::create() called with unknown Region type")
<< endmsg;
abort(); /*NOTREACHED*/
return boost::shared_ptr<Region>();
abort (); /*NOTREACHED*/
return boost::shared_ptr<Region> ();
}
if (ret) {
@ -138,8 +135,8 @@ RegionFactory::create (boost::shared_ptr<Region> region, const PropertyList& pli
ret->apply_changes (plist);
if (ret->session().config.get_glue_new_regions_to_bars_and_beats() && ret->position_lock_style() != MusicTime) {
ret->set_position_lock_style (MusicTime);
if (ret->session ().config.get_glue_new_regions_to_bars_and_beats () && ret->position_lock_style () != MusicTime) {
ret->set_position_lock_style (MusicTime);
}
if (announce) {
@ -155,23 +152,21 @@ RegionFactory::create (boost::shared_ptr<Region> region, const PropertyList& pli
boost::shared_ptr<Region>
RegionFactory::create (boost::shared_ptr<Region> region, MusicSample offset, const PropertyList& plist, bool announce, ThawList* tl)
{
boost::shared_ptr<Region> ret;
boost::shared_ptr<Region> ret;
boost::shared_ptr<const AudioRegion> other_a;
boost::shared_ptr<const MidiRegion> other_m;
if ((other_a = boost::dynamic_pointer_cast<AudioRegion>(region)) != 0) {
boost::shared_ptr<const MidiRegion> other_m;
if ((other_a = boost::dynamic_pointer_cast<AudioRegion> (region)) != 0) {
ret = boost::shared_ptr<Region> (new AudioRegion (other_a, offset));
} else if ((other_m = boost::dynamic_pointer_cast<MidiRegion>(region)) != 0) {
} else if ((other_m = boost::dynamic_pointer_cast<MidiRegion> (region)) != 0) {
ret = boost::shared_ptr<Region> (new MidiRegion (other_m, offset));
} else {
fatal << _("programming error: RegionFactory::create() called with unknown Region type")
<< endmsg;
abort(); /*NOTREACHED*/
return boost::shared_ptr<Region>();
abort (); /*NOTREACHED*/
return boost::shared_ptr<Region> ();
}
if (ret) {
@ -181,7 +176,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, MusicSample offset, con
}
ret->apply_changes (plist);
if (ret->session().config.get_glue_new_regions_to_bars_and_beats() && ret->position_lock_style() != MusicTime) {
if (ret->session ().config.get_glue_new_regions_to_bars_and_beats () && ret->position_lock_style () != MusicTime) {
ret->set_position_lock_style (MusicTime);
}
@ -198,15 +193,14 @@ RegionFactory::create (boost::shared_ptr<Region> region, MusicSample offset, con
boost::shared_ptr<Region>
RegionFactory::create (boost::shared_ptr<Region> region, const SourceList& srcs, const PropertyList& plist, bool announce, ThawList* tl)
{
boost::shared_ptr<Region> ret;
boost::shared_ptr<Region> ret;
boost::shared_ptr<const AudioRegion> other;
/* used by AudioFilter when constructing a new region that is intended to have nearly
identical settings to an original, but using different sources.
*/
if ((other = boost::dynamic_pointer_cast<AudioRegion>(region)) != 0) {
if ((other = boost::dynamic_pointer_cast<AudioRegion> (region)) != 0) {
// XXX use me in caller where plist is setup, this is start i think srcs.front()->length (srcs.front()->natural_position())
ret = boost::shared_ptr<Region> (new AudioRegion (other, srcs));
@ -214,7 +208,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, const SourceList& srcs,
} else {
fatal << _("programming error: RegionFactory::create() called with unknown Region type")
<< endmsg;
abort(); /*NOTREACHED*/
abort (); /*NOTREACHED*/
}
if (ret) {
@ -225,7 +219,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, const SourceList& srcs,
ret->apply_changes (plist);
if (ret->session().config.get_glue_new_regions_to_bars_and_beats() && ret->position_lock_style() != MusicTime) {
if (ret->session ().config.get_glue_new_regions_to_bars_and_beats () && ret->position_lock_style () != MusicTime) {
ret->set_position_lock_style (MusicTime);
}
@ -250,18 +244,15 @@ RegionFactory::create (boost::shared_ptr<Source> src, const PropertyList& plist,
boost::shared_ptr<Region>
RegionFactory::create (const SourceList& srcs, const PropertyList& plist, bool announce, ThawList* tl)
{
boost::shared_ptr<Region> ret;
boost::shared_ptr<Region> ret;
boost::shared_ptr<AudioSource> as;
boost::shared_ptr<MidiSource> ms;
if ((as = boost::dynamic_pointer_cast<AudioSource>(srcs[0])) != 0) {
boost::shared_ptr<MidiSource> ms;
if ((as = boost::dynamic_pointer_cast<AudioSource> (srcs[0])) != 0) {
ret = boost::shared_ptr<Region> (new AudioRegion (srcs));
} else if ((ms = boost::dynamic_pointer_cast<MidiSource>(srcs[0])) != 0) {
} else if ((ms = boost::dynamic_pointer_cast<MidiSource> (srcs[0])) != 0) {
ret = boost::shared_ptr<Region> (new MidiRegion (srcs));
}
if (ret) {
@ -272,7 +263,7 @@ RegionFactory::create (const SourceList& srcs, const PropertyList& plist, bool a
ret->apply_changes (plist);
if (ret->session().config.get_glue_new_regions_to_bars_and_beats() && ret->position_lock_style() != MusicTime) {
if (ret->session ().config.get_glue_new_regions_to_bars_and_beats () && ret->position_lock_style () != MusicTime) {
ret->set_position_lock_style (MusicTime);
}
@ -297,18 +288,15 @@ RegionFactory::create (SourceList& srcs, const XMLNode& node)
{
boost::shared_ptr<Region> ret;
if (srcs.empty()) {
if (srcs.empty ()) {
return ret;
}
if (srcs[0]->type() == DataType::AUDIO) {
if (srcs[0]->type () == DataType::AUDIO) {
ret = boost::shared_ptr<Region> (new AudioRegion (srcs));
} else if (srcs[0]->type() == DataType::MIDI) {
} else if (srcs[0]->type () == DataType::MIDI) {
ret = boost::shared_ptr<Region> (new MidiRegion (srcs));
}
if (ret) {
@ -332,8 +320,8 @@ RegionFactory::create (SourceList& srcs, const XMLNode& node)
void
RegionFactory::map_add (boost::shared_ptr<Region> r)
{
pair<ID,boost::shared_ptr<Region> > p;
p.first = r->id();
pair<ID, boost::shared_ptr<Region> > p;
p.first = r->id ();
p.second = r;
{
@ -360,9 +348,9 @@ RegionFactory::map_remove (boost::weak_ptr<Region> w)
}
Glib::Threads::Mutex::Lock lm (region_map_lock);
RegionMap::iterator i = region_map.find (r->id());
RegionMap::iterator i = region_map.find (r->id ());
if (i != region_map.end()) {
if (i != region_map.end ()) {
remove_from_region_name_map (i->second->name ());
region_map.erase (i);
}
@ -373,8 +361,8 @@ RegionFactory::region_by_id (const PBD::ID& id)
{
RegionMap::iterator i = region_map.find (id);
if (i == region_map.end()) {
return boost::shared_ptr<Region>();
if (i == region_map.end ()) {
return boost::shared_ptr<Region> ();
}
return i->second;
@ -383,23 +371,23 @@ RegionFactory::region_by_id (const PBD::ID& id)
boost::shared_ptr<Region>
RegionFactory::wholefile_region_by_name (const std::string& name)
{
for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ++i) {
if (i->second->whole_file() && i->second->name() == name) {
for (RegionMap::iterator i = region_map.begin (); i != region_map.end (); ++i) {
if (i->second->whole_file () && i->second->name () == name) {
return i->second;
}
}
return boost::shared_ptr<Region>();
return boost::shared_ptr<Region> ();
}
boost::shared_ptr<Region>
RegionFactory::region_by_name (const std::string& name)
{
for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ++i) {
if (i->second->name() == name) {
for (RegionMap::iterator i = region_map.begin (); i != region_map.end (); ++i) {
if (i->second->name () == name) {
return i->second;
}
}
return boost::shared_ptr<Region>();
return boost::shared_ptr<Region> ();
}
void
@ -432,7 +420,7 @@ RegionFactory::delete_all_regions ()
clear_map ();
/* tell everyone to drop references */
for (RegionMap::iterator i = copy.begin(); i != copy.end(); ++i) {
for (RegionMap::iterator i = copy.begin (); i != copy.end (); ++i) {
i->second->drop_references ();
}
@ -455,7 +443,7 @@ RegionFactory::add_to_region_name_maps (boost::shared_ptr<Region> region)
update_region_name_number_map (region);
Glib::Threads::Mutex::Lock lm (region_name_maps_mutex);
region_name_map[region->name()] = region->id ();
region_name_map[region->name ()] = region->id ();
}
/** Account for a region rename in the two region name maps */
@ -466,15 +454,15 @@ RegionFactory::rename_in_region_name_maps (boost::shared_ptr<Region> region)
Glib::Threads::Mutex::Lock lm (region_name_maps_mutex);
map<string, PBD::ID>::iterator i = region_name_map.begin();
while (i != region_name_map.end() && i->second != region->id ()) {
map<string, PBD::ID>::iterator i = region_name_map.begin ();
while (i != region_name_map.end () && i->second != region->id ()) {
++i;
}
/* Erase the entry for the old name and put in a new one */
if (i != region_name_map.end()) {
if (i != region_name_map.end ()) {
region_name_map.erase (i);
region_name_map[region->name()] = region->id ();
region_name_map[region->name ()] = region->id ();
}
}
@ -492,12 +480,11 @@ RegionFactory::remove_from_region_name_map (string n)
void
RegionFactory::update_region_name_number_map (boost::shared_ptr<Region> region)
{
string::size_type const last_period = region->name().find_last_of ('.');
string::size_type const last_period = region->name ().find_last_of ('.');
if (last_period != string::npos && last_period < region->name().length() - 1) {
string const base = region->name().substr (0, last_period);
string const number = region->name().substr (last_period + 1);
if (last_period != string::npos && last_period < region->name ().length () - 1) {
string const base = region->name ().substr (0, last_period);
string const number = region->name ().substr (last_period + 1);
/* note that if there is no number, we get zero from atoi,
which is just fine
@ -509,7 +496,7 @@ RegionFactory::update_region_name_number_map (boost::shared_ptr<Region> region)
}
void
RegionFactory::region_changed (PropertyChange const & what_changed, boost::weak_ptr<Region> w)
RegionFactory::region_changed (PropertyChange const& what_changed, boost::weak_ptr<Region> w)
{
boost::shared_ptr<Region> r = w.lock ();
if (!r) {
@ -524,21 +511,19 @@ RegionFactory::region_changed (PropertyChange const & what_changed, boost::weak_
int
RegionFactory::region_name (string& result, string base, bool newlevel)
{
char buf[16];
char buf[16];
string subbase;
if (base.find("/") != string::npos) {
base = base.substr(base.find_last_of("/") + 1);
if (base.find ("/") != string::npos) {
base = base.substr (base.find_last_of ("/") + 1);
}
if (base == "") {
snprintf (buf, sizeof (buf), "%d", RegionFactory::nregions() + 1);
snprintf (buf, sizeof (buf), "%d", RegionFactory::nregions () + 1);
result = "region.";
result += buf;
} else {
if (newlevel) {
subbase = base;
} else {
@ -549,17 +534,16 @@ RegionFactory::region_name (string& result, string base, bool newlevel)
/* pos may be npos, but then we just use entire base */
subbase = base.substr (0, pos);
}
{
Glib::Threads::Mutex::Lock lm (region_name_maps_mutex);
map<string,uint32_t>::iterator x;
map<string, uint32_t>::iterator x;
result = subbase;
if ((x = region_name_number_map.find (subbase)) == region_name_number_map.end()) {
if ((x = region_name_number_map.find (subbase)) == region_name_number_map.end ()) {
result += ".1";
region_name_number_map[subbase] = 1;
} else {
@ -578,9 +562,9 @@ string
RegionFactory::compound_region_name (const string& playlist, uint32_t compound_ops, uint32_t depth, bool whole_source)
{
if (whole_source) {
return string_compose (_("%1 compound-%2 (%3)"), playlist, compound_ops+1, depth+1);
return string_compose (_("%1 compound-%2 (%3)"), playlist, compound_ops + 1, depth + 1);
} else {
return string_compose (_("%1 compound-%2.1 (%3)"), playlist, compound_ops+1, depth+1);
return string_compose (_("%1 compound-%2.1 (%3)"), playlist, compound_ops + 1, depth + 1);
}
}
@ -588,24 +572,21 @@ string
RegionFactory::new_region_name (string old)
{
string::size_type last_period;
uint32_t number;
string::size_type len = old.length() + 64;
string remainder;
std::vector<char> buf(len);
uint32_t number;
string::size_type len = old.length () + 64;
string remainder;
std::vector<char> buf (len);
if ((last_period = old.find_last_of ('.')) == string::npos) {
/* no period present - add one explicitly */
old += '.';
last_period = old.length() - 1;
number = 0;
last_period = old.length () - 1;
number = 0;
} else {
if (last_period < old.length() - 1) {
string period_to_end = old.substr (last_period+1);
if (last_period < old.length () - 1) {
string period_to_end = old.substr (last_period + 1);
/* extra material after the period */
@ -613,24 +594,23 @@ RegionFactory::new_region_name (string old)
number = atoi (period_to_end);
if (numerals_end < period_to_end.length() - 1) {
if (numerals_end < period_to_end.length () - 1) {
/* extra material after the end of the digits */
remainder = period_to_end.substr (numerals_end);
}
} else {
last_period = old.length();
number = 0;
last_period = old.length ();
number = 0;
}
}
while (number < (UINT_MAX-1)) {
while (number < (UINT_MAX - 1)) {
string sbuf;
number++;
snprintf (&buf[0], len, "%s%" PRIu32 "%s", old.substr (0, last_period + 1).c_str(), number, remainder.c_str());
snprintf (&buf[0], len, "%s%" PRIu32 "%s", old.substr (0, last_period + 1).c_str (), number, remainder.c_str ());
sbuf = &buf[0];
if (region_name_map.find (sbuf) == region_name_map.end ()) {
@ -638,7 +618,7 @@ RegionFactory::new_region_name (string old)
}
}
if (number != (UINT_MAX-1)) {
if (number != (UINT_MAX - 1)) {
return &buf[0];
}
@ -651,13 +631,13 @@ RegionFactory::get_whole_region_for_source (boost::shared_ptr<Source> s)
{
Glib::Threads::Mutex::Lock lm (region_map_lock);
for (RegionMap::const_iterator i = region_map.begin(); i != region_map.end(); ++i) {
if (i->second->uses_source (s) && i->second->whole_file()) {
for (RegionMap::const_iterator i = region_map.begin (); i != region_map.end (); ++i) {
if (i->second->uses_source (s) && i->second->whole_file ()) {
return (i->second);
}
}
return boost::shared_ptr<Region>();
return boost::shared_ptr<Region> ();
}
void
@ -665,7 +645,7 @@ RegionFactory::get_regions_using_source (boost::shared_ptr<Source> s, std::set<b
{
Glib::Threads::Mutex::Lock lm (region_map_lock);
for (RegionMap::const_iterator i = region_map.begin(); i != region_map.end(); ++i) {
for (RegionMap::const_iterator i = region_map.begin (); i != region_map.end (); ++i) {
if (i->second->uses_source (s)) {
r.insert (i->second);
}
@ -676,8 +656,8 @@ void
RegionFactory::remove_regions_using_source (boost::shared_ptr<Source> src)
{
Glib::Threads::Mutex::Lock lm (region_map_lock);
RegionList remove_regions;
for (RegionMap::const_iterator i = region_map.begin(); i != region_map.end(); ++i) {
RegionList remove_regions;
for (RegionMap::const_iterator i = region_map.begin (); i != region_map.end (); ++i) {
if (i->second->uses_source (src)) {
remove_regions.push_back (i->second);
}
@ -685,7 +665,7 @@ RegionFactory::remove_regions_using_source (boost::shared_ptr<Source> src)
lm.release ();
/* this will call RegionFactory::map_remove () */
for (RegionList::iterator i = remove_regions.begin(); i != remove_regions.end(); ++i) {
for (RegionList::iterator i = remove_regions.begin (); i != remove_regions.end (); ++i) {
(*i)->drop_references ();
}
}