- Use our down_cast<> instead of dynamic_cast<> where possible. Now bug-hunting the
infamous st8ad_cast bug. git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1194 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
470901d20e
commit
6d4e756546
|
@ -26,6 +26,7 @@
|
||||||
#include <sgpemv2/thread.hh>
|
#include <sgpemv2/thread.hh>
|
||||||
|
|
||||||
#include <sgpemv2/templates/deletor.tcc>
|
#include <sgpemv2/templates/deletor.tcc>
|
||||||
|
#include <sgpemv2/templates/down_cast.tcc>
|
||||||
#include <sgpemv2/templates/sequences.tcc>
|
#include <sgpemv2/templates/sequences.tcc>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -52,7 +53,7 @@ ConcreteEnvironment::ConcreteEnvironment(const ConcreteEnvironment& ce) :
|
||||||
// Update resource pointers in a way you won't like :-)
|
// Update resource pointers in a way you won't like :-)
|
||||||
{
|
{
|
||||||
for (Resources::iterator it = _resources.begin(); it != _resources.end(); it++)
|
for (Resources::iterator it = _resources.begin(); it != _resources.end(); it++)
|
||||||
it->second = new DynamicResource(dynamic_cast<const DynamicResource&>(*it->second));
|
it->second = new DynamicResource(down_cast<const DynamicResource&>(*it->second));
|
||||||
}
|
}
|
||||||
|
|
||||||
// DynamicProcess object need to be copied.
|
// DynamicProcess object need to be copied.
|
||||||
|
@ -61,7 +62,7 @@ ConcreteEnvironment::ConcreteEnvironment(const ConcreteEnvironment& ce) :
|
||||||
const Processes& ce_proc = ce._processes;
|
const Processes& ce_proc = ce._processes;
|
||||||
insert_iterator<Processes> dest(_processes, _processes.begin());
|
insert_iterator<Processes> dest(_processes, _processes.begin());
|
||||||
for (Iseq<Processes::const_iterator> orig = iseq(ce_proc); orig; orig++)
|
for (Iseq<Processes::const_iterator> orig = iseq(ce_proc); orig; orig++)
|
||||||
*dest++ = new DynamicProcess(dynamic_cast<const DynamicProcess&>(**orig));
|
*dest++ = new DynamicProcess(down_cast<const DynamicProcess&>(**orig));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,8 +105,8 @@ ConcreteEnvironment::ConcreteEnvironment(const ConcreteEnvironment& ce) :
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (it5_t it5 = queue.begin(); !found && it5 != queue.end(); it5++)
|
for (it5_t it5 = queue.begin(); !found && it5 != queue.end(); it5++)
|
||||||
{
|
{
|
||||||
DynamicSubRequest& _old = dynamic_cast<DynamicSubRequest&>(**it5);
|
DynamicSubRequest& _old = down_cast<DynamicSubRequest&>(**it5);
|
||||||
DynamicSubRequest& _new = dynamic_cast<DynamicSubRequest&>(**it4);
|
DynamicSubRequest& _new = down_cast<DynamicSubRequest&>(**it4);
|
||||||
if (&_old.get_core() == &_new.get_core())
|
if (&_old.get_core() == &_new.get_core())
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
// Include full template definition only in implementation files:
|
// Include full template definition only in implementation files:
|
||||||
#include <sgpemv2/templates/singleton.tcc>
|
#include <sgpemv2/templates/singleton.tcc>
|
||||||
|
|
||||||
|
#include <sgpemv2/templates/down_cast.tcc>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -122,7 +124,7 @@ CPUPoliciesGatekeeper::activate_policy(History *history, CPUPolicy* policy) thro
|
||||||
policy->activate();
|
policy->activate();
|
||||||
_active_policies[history] = policy;
|
_active_policies[history] = policy;
|
||||||
// the content of history (if any) is not vaild any more.
|
// the content of history (if any) is not vaild any more.
|
||||||
dynamic_cast<ConcreteHistory*>(history)->reset(true);
|
down_cast<ConcreteHistory*>(history)->reset(true);
|
||||||
}
|
}
|
||||||
catch(const CPUPolicyException& e)
|
catch(const CPUPolicyException& e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <sgpemv2/serialize_visitor.hh>
|
#include <sgpemv2/serialize_visitor.hh>
|
||||||
|
|
||||||
#include <sgpemv2/templates/deletor.tcc>
|
#include <sgpemv2/templates/deletor.tcc>
|
||||||
|
#include <sgpemv2/templates/down_cast.tcc>
|
||||||
#include <sgpemv2/templates/smartp.tcc>
|
#include <sgpemv2/templates/smartp.tcc>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -78,8 +79,7 @@ DynamicRequest::~DynamicRequest()
|
||||||
bool
|
bool
|
||||||
DynamicRequest::operator==(const Request& op2) const
|
DynamicRequest::operator==(const Request& op2) const
|
||||||
{
|
{
|
||||||
assert(dynamic_cast<const DynamicRequest*>(&op2) != NULL);
|
return _static_request == down_cast<const DynamicRequest&>(op2)._static_request;
|
||||||
return _static_request == dynamic_cast<const DynamicRequest&>(op2)._static_request;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include "static_resource.hh"
|
#include "static_resource.hh"
|
||||||
|
|
||||||
#include <sgpemv2/serialize_visitor.hh>
|
#include <sgpemv2/serialize_visitor.hh>
|
||||||
|
|
||||||
|
#include <sgpemv2/templates/down_cast.tcc>
|
||||||
#include <sgpemv2/templates/smartp.tcc>
|
#include <sgpemv2/templates/smartp.tcc>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
@ -36,8 +38,7 @@ DynamicResource::DynamicResource(StaticResource *core) :
|
||||||
bool
|
bool
|
||||||
DynamicResource::operator==(const Resource& op2) const
|
DynamicResource::operator==(const Resource& op2) const
|
||||||
{
|
{
|
||||||
assert(dynamic_cast<const DynamicResource*>(&op2) != NULL);
|
return _static_resource == down_cast<const DynamicResource&>(op2)._static_resource;
|
||||||
return _static_resource == dynamic_cast<const DynamicResource&>(op2)._static_resource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::ustring
|
Glib::ustring
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "dynamic_schedulable.hh"
|
#include "dynamic_schedulable.hh"
|
||||||
|
|
||||||
|
#include <sgpemv2/templates/down_cast.tcc>
|
||||||
#include <sgpemv2/templates/smartp.tcc>
|
#include <sgpemv2/templates/smartp.tcc>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
@ -34,8 +35,7 @@ DynamicSchedulable::DynamicSchedulable()
|
||||||
bool
|
bool
|
||||||
DynamicSchedulable::operator==(const Schedulable& op2) const
|
DynamicSchedulable::operator==(const Schedulable& op2) const
|
||||||
{
|
{
|
||||||
assert(dynamic_cast<const DynamicSchedulable*>(&op2) != NULL);
|
return &get_core() == &(down_cast<const DynamicSchedulable&>(op2).get_core());
|
||||||
return &get_core() == &(dynamic_cast<const DynamicSchedulable&>(op2).get_core());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::ustring
|
Glib::ustring
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <sgpemv2/request.hh>
|
#include <sgpemv2/request.hh>
|
||||||
#include <sgpemv2/serialize_visitor.hh>
|
#include <sgpemv2/serialize_visitor.hh>
|
||||||
|
|
||||||
|
#include <sgpemv2/templates/down_cast.tcc>
|
||||||
#include <sgpemv2/templates/smartp.tcc>
|
#include <sgpemv2/templates/smartp.tcc>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -64,8 +65,7 @@ DynamicSubRequest::~DynamicSubRequest()
|
||||||
bool
|
bool
|
||||||
DynamicSubRequest::operator==(const SubRequest& op2) const
|
DynamicSubRequest::operator==(const SubRequest& op2) const
|
||||||
{
|
{
|
||||||
assert(dynamic_cast<const DynamicSubRequest*>(&op2) != NULL);
|
return _static_subrequest == down_cast<const DynamicSubRequest&>(op2)._static_subrequest;
|
||||||
return _static_subrequest == dynamic_cast<const DynamicSubRequest&>(op2)._static_subrequest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
// Include full template definition only in implementation files:
|
// Include full template definition only in implementation files:
|
||||||
#include <sgpemv2/templates/singleton.tcc>
|
#include <sgpemv2/templates/singleton.tcc>
|
||||||
|
|
||||||
|
#include <sgpemv2/templates/down_cast.tcc>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
@ -96,7 +98,7 @@ ResourcePoliciesGatekeeper::activate_policy(History *history, ResourcePolicy* po
|
||||||
|
|
||||||
_active_policies[history] = policy;
|
_active_policies[history] = policy;
|
||||||
// the content of history (if any) is not vaild any more.
|
// the content of history (if any) is not vaild any more.
|
||||||
dynamic_cast<ConcreteHistory*>(history)->reset(true);
|
down_cast<ConcreteHistory*>(history)->reset(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourcePoliciesGatekeeper::ResourcePoliciesGatekeeper()
|
ResourcePoliciesGatekeeper::ResourcePoliciesGatekeeper()
|
||||||
|
|
Loading…
Reference in New Issue