minor tweaks

This commit is contained in:
Garux 2021-03-20 02:30:11 +03:00
parent ebd90382a4
commit e200ffc762
6 changed files with 27 additions and 27 deletions

View File

@ -118,12 +118,12 @@ void forEachInstance( const scene::Instantiable::Visitor& visitor ){
}
void insert( scene::Instantiable::Observer* observer, const scene::Path& path, scene::Instance* instance ){
ASSERT_MESSAGE( m_instances.find( key_type( observer, PathConstReference( instance->path() ) ) ) == m_instances.end(), "InstanceSet::insert - element already exists" );
m_instances.insert( InstanceMap::value_type( key_type( observer, PathConstReference( instance->path() ) ), instance ) );
const bool inserted = m_instances.insert( InstanceMap::value_type( key_type( observer, PathConstReference( instance->path() ) ), instance ) ).second;
ASSERT_MESSAGE( inserted, "InstanceSet::insert - element already exists" );
}
scene::Instance* erase( scene::Instantiable::Observer* observer, const scene::Path& path ){
ASSERT_MESSAGE( m_instances.find( key_type( observer, PathConstReference( path ) ) ) != m_instances.end(), "InstanceSet::erase - failed to find element" );
InstanceMap::iterator i = m_instances.find( key_type( observer, PathConstReference( path ) ) );
ASSERT_MESSAGE( i != m_instances.end(), "InstanceSet::erase - failed to find element" );
scene::Instance* instance = i->second;
m_instances.erase( i );
return instance;

View File

@ -35,12 +35,12 @@ public:
ASSERT_MESSAGE( m_observers.empty(), "ModuleObservers::~ModuleObservers: observers still attached" );
}
void attach( ModuleObserver& observer ){
ASSERT_MESSAGE( m_observers.find( &observer ) == m_observers.end(), "ModuleObservers::attach: cannot attach observer" );
m_observers.insert( &observer );
const bool inserted = m_observers.insert( &observer ).second;
ASSERT_MESSAGE( inserted, "ModuleObservers::attach: cannot attach observer" );
}
void detach( ModuleObserver& observer ){
ASSERT_MESSAGE( m_observers.find( &observer ) != m_observers.end(), "ModuleObservers::detach: cannot detach observer" );
m_observers.erase( &observer );
const bool erased = m_observers.erase( &observer );
ASSERT_MESSAGE( erased, "ModuleObservers::detach: cannot detach observer" );
}
void realise(){
for ( Observers::iterator i = m_observers.begin(); i != m_observers.end(); ++i )

View File

@ -424,12 +424,12 @@ typedef std::set<TargetableInstance*> TargetableInstances;
TargetableInstances m_instances;
public:
void attach( TargetableInstance& instance ){
ASSERT_MESSAGE( m_instances.find( &instance ) == m_instances.end(), "cannot attach instance" );
m_instances.insert( &instance );
const bool inserted = m_instances.insert( &instance ).second;
ASSERT_MESSAGE( inserted, "cannot attach instance" );
}
void detach( TargetableInstance& instance ){
ASSERT_MESSAGE( m_instances.find( &instance ) != m_instances.end(), "cannot detach instance" );
m_instances.erase( &instance );
const bool erased = m_instances.erase( &instance );
ASSERT_MESSAGE( erased, "cannot detach instance" );
}
void renderSolid( Renderer& renderer, const VolumeTest& volume ) const {

View File

@ -96,13 +96,13 @@ void addFilter( Filter& filter, int mask ){
g_filters.back().update();
}
void registerFilterable( Filterable& filterable ){
ASSERT_MESSAGE( g_filterables.find( &filterable ) == g_filterables.end(), "filterable already registered" );
filterable.updateFiltered();
g_filterables.insert( &filterable );
const bool inserted = g_filterables.insert( &filterable ).second;
ASSERT_MESSAGE( inserted, "filterable already registered" );
}
void unregisterFilterable( Filterable& filterable ){
ASSERT_MESSAGE( g_filterables.find( &filterable ) != g_filterables.end(), "filterable not registered" );
g_filterables.erase( &filterable );
const bool erased = g_filterables.erase( &filterable );
ASSERT_MESSAGE( erased, "filterable not registered" );
}
};

View File

@ -1437,13 +1437,13 @@ void changed( LightCullable& cullable ){
( *i ).second.lightsChanged();
}
void attach( RendererLight& light ){
ASSERT_MESSAGE( m_lights.find( &light ) == m_lights.end(), "light could not be attached" );
m_lights.insert( &light );
const bool inserted = m_lights.insert( &light ).second;
ASSERT_MESSAGE( inserted, "light could not be attached" );
changed( light );
}
void detach( RendererLight& light ){
ASSERT_MESSAGE( m_lights.find( &light ) != m_lights.end(), "light could not be detached" );
m_lights.erase( &light );
const bool erased = m_lights.erase( &light );
ASSERT_MESSAGE( erased, "light could not be detached" );
changed( light );
}
void changed( RendererLight& light ){
@ -1467,13 +1467,13 @@ mutable bool m_traverseRenderablesMutex;
// renderables
void attachRenderable( const Renderable& renderable ){
ASSERT_MESSAGE( !m_traverseRenderablesMutex, "attaching renderable during traversal" );
ASSERT_MESSAGE( m_renderables.find( &renderable ) == m_renderables.end(), "renderable could not be attached" );
m_renderables.insert( &renderable );
const bool inserted = m_renderables.insert( &renderable ).second;
ASSERT_MESSAGE( inserted, "renderable could not be attached" );
}
void detachRenderable( const Renderable& renderable ){
ASSERT_MESSAGE( !m_traverseRenderablesMutex, "detaching renderable during traversal" );
ASSERT_MESSAGE( m_renderables.find( &renderable ) != m_renderables.end(), "renderable could not be detached" );
m_renderables.erase( &renderable );
const bool erased = m_renderables.erase( &renderable );
ASSERT_MESSAGE( erased, "renderable could not be detached" );
}
void forEachRenderable( const RenderableCallback& callback ) const {
ASSERT_MESSAGE( !m_traverseRenderablesMutex, "for-each during traversal" );

View File

@ -340,12 +340,12 @@ void clear(){
trackersClear();
}
void trackerAttach( UndoTracker& tracker ){
ASSERT_MESSAGE( m_trackers.find( &tracker ) == m_trackers.end(), "undo tracker already attached" );
m_trackers.insert( &tracker );
const bool inserted = m_trackers.insert( &tracker ).second;
ASSERT_MESSAGE( inserted, "undo tracker already attached" );
}
void trackerDetach( UndoTracker& tracker ){
ASSERT_MESSAGE( m_trackers.find( &tracker ) != m_trackers.end(), "undo tracker cannot be detached" );
m_trackers.erase( &tracker );
const bool erased = m_trackers.erase( &tracker );
ASSERT_MESSAGE( erased, "undo tracker cannot be detached" );
}
void trackersClear() const {
for ( Trackers::const_iterator i = m_trackers.begin(); i != m_trackers.end(); ++i )