Import Geant4 10.6.0 source tree

This commit is contained in:
Gabriele Cosmo
2019-12-06 15:12:28 +01:00
parent b2a62ae692
commit 5baee230e9
2997 changed files with 141580 additions and 98673 deletions
@@ -15,6 +15,8 @@ namespace rroot {
template <class T>
class obj_array : public virtual iro,public std::vector<T*> {
typedef typename std::vector<T*> parent;
private:
static const std::string& s_store_class() {
static const std::string s_v("TObjArray");
return s_v;
@@ -43,10 +45,8 @@ public:
return stream(a_buffer,args,accept_null);
}
public:
obj_array(ifac& a_fac,bool a_owner,bool a_warn) //a_warn used if a_owner=false.
obj_array(ifac& a_fac)
:m_fac(a_fac)
,m_owner(a_owner)
,m_warn(a_warn)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
@@ -61,34 +61,32 @@ public:
public:
obj_array(const obj_array& a_from)
:iro(a_from)
,std::vector<T*>()
,parent()
,m_fac(a_from.m_fac)
,m_owner(a_from.m_owner)
,m_warn(a_from.m_warn)
{
#ifdef TOOLS_MEM
mem::increment(s_class().c_str());
#endif
if(a_from.m_owner) {
typedef typename std::vector<T*>::const_iterator it_t;
for(it_t it=a_from.begin();it!=a_from.end();++it) {
if(!(*it)) {
std::vector<T*>::push_back(0);
typedef typename parent::const_iterator it_t;
for(it_t it=a_from.begin();it!=a_from.end();++it) {
if(!(*it)) {
parent::push_back(0);
m_owns.push_back(false);
} else {
iro* _obj = (*it)->copy();
T* obj = safe_cast<iro,T>(*_obj);
if(!obj) {
m_fac.out() << "tools::rroot::obj_array::obj_array :"
<< " inlib::cast failed."
<< std::endl;
delete _obj;
parent::push_back(0);
m_owns.push_back(false);
} else {
iro* _obj = (*it)->copy();
T* obj = safe_cast<iro,T>(*_obj);
if(!obj) {
//a_buffer.out() << "tools::rroot::obj_array::obj_array :"
// << " inlib::cast failed."
// << std::endl;
delete _obj;
} else {
std::vector<T*>::push_back(obj);
}
parent::push_back(obj);
m_owns.push_back(true);
}
}
} else {
std::vector<T*>::operator=(a_from);
}
}
obj_array& operator=(const obj_array& a_from){
@@ -96,29 +94,26 @@ public:
_clear();
m_owner = a_from.m_owner;
m_warn = a_from.m_warn;
if(a_from.m_owner) {
typedef typename std::vector<T*>::const_iterator it_t;
for(it_t it=a_from.begin();it!=a_from.end();++it) {
if(!(*it)) {
std::vector<T*>::push_back(0);
typedef typename parent::const_iterator it_t;
for(it_t it=a_from.begin();it!=a_from.end();++it) {
if(!(*it)) {
parent::push_back(0);
m_owns.push_back(false);
} else {
iro* _obj = (*it)->copy();
T* obj = safe_cast<iro,T>(*_obj);
if(!obj) {
m_fac.out() << "tools::rroot::obj_array::operator= :"
<< " inlib::cast failed."
<< std::endl;
delete _obj;
parent::push_back(0);
m_owns.push_back(false);
} else {
iro* _obj = (*it)->copy();
T* obj = safe_cast<iro,T>(*_obj);
if(!obj) {
//a_buffer.out() << "tools::rroot::obj_array::operator= :"
// << " inlib::cast failed."
// << std::endl;
delete _obj;
} else {
std::vector<T*>::push_back(obj);
}
parent::push_back(obj);
m_owns.push_back(true);
}
}
} else {
std::vector<T*>::operator=(a_from);
}
return *this;
@@ -129,11 +124,13 @@ public:
bool stream(buffer& a_buffer,const ifac::args& a_args,bool a_accept_null = false) {
_clear();
//::printf("debug : obj_array::stream : %lu : begin\n",(unsigned long)this);
short v;
unsigned int sp, bc;
if(!a_buffer.read_version(v,sp,bc)) return false;
//::printf("debug : obj_array::stream : version %d, byte count %d\n",v,c);
//::printf("debug : obj_array::stream : version %d, byte count %d\n",v,bc);
{uint32 id,bits;
if(!Object_stream(a_buffer,id,bits)) return false;}
@@ -144,19 +141,21 @@ public:
int lowerBound;
if(!a_buffer.read(lowerBound)) return false;
//::printf("debug : obj_array : name \"%s\", nobject %d, lowerBound %d\n",
// name.c_str(),nobjects,lowerBound);
//::printf("debug : obj_array : name \"%s\", nobject %d, lowerBound %d\n",name.c_str(),nobjects,lowerBound);
for (int i=0;i<nobjects;i++) {
//::printf("debug : obj_array : n=%d i=%d ...\n",nobjects,i);
//::printf("debug : obj_array::stream : %lu : n=%d i=%d ...\n",(unsigned long)this,nobjects,i);
iro* obj;
bool created;
if(!a_buffer.read_object(m_fac,a_args,obj,created)){
a_buffer.out() << "tools::rroot::obj_array::stream : can't read object." << std::endl;
a_buffer.out() << "tools::rroot::obj_array::stream : can't read object"
<< " in obj_array : name " << sout(name)
<< ", nobjects " << nobjects << ", iobject " << i << std::endl;
return false;
}
//::printf("debug : obj_array : n=%d i=%d : ok\n",nobjects,i);
//::printf("debug : obj_array::stream : %lu : n=%d i=%d : ok, obj %lu\n",(unsigned long)this,
// nobjects,i,(unsigned long)obj);
if(obj) {
T* to = safe_cast<iro,T>(*obj);
if(!to) {
@@ -170,28 +169,19 @@ public:
}
} else {
if(created) {
if(m_owner) {
std::vector<T*>::push_back(to);
} else { //who manage this object ?
if(m_warn) {
a_buffer.out() << "tools::rroot::obj_array::stream :"
<< " warning : created object of class " << sout(obj->s_cls()) << " not managed."
<< std::endl;
}
std::vector<T*>::push_back(to);
}
} else { //someone else may manage this object.
if(m_owner) {
a_buffer.out() << "tools::rroot::obj_array::stream : not created object can't be manage here." << std::endl;
return false;
} else {
std::vector<T*>::push_back(to);
}
parent::push_back(to);
m_owns.push_back(true);
} else { //someone else manage this object.
parent::push_back(to);
m_owns.push_back(false);
}
}
} else {
//a_accept_null for branch::stream m_baskets.
if(a_accept_null) std::vector<T*>::push_back(0);
if(a_accept_null) {
parent::push_back(0);
m_owns.push_back(false);
}
}
}
@@ -199,16 +189,21 @@ public:
}
protected:
void _clear() {
if(m_owner) {
safe_clear<T>(*this);
} else {
std::vector<T*>::clear();
typedef typename parent::iterator it_t;
typedef std::vector<bool>::iterator itb_t;
while(!parent::empty()) {
it_t it = parent::begin();
itb_t itb = m_owns.begin();
T* entry = (*it);
bool own = (*itb);
parent::erase(it);
m_owns.erase(itb);
if(own) delete entry;
}
}
protected:
ifac& m_fac;
bool m_owner;
bool m_warn;
std::vector<bool> m_owns;
};
}}