#include "TError.h"
#include "TClassEdit.h"
#include "TCollectionProxyFactory.h"
#include "TGenCollectionProxy.h"
#include "TGenCollectionStreamer.h"
#include "TEmulatedMapProxy.h"
#include "TEmulatedCollectionProxy.h"
namespace {
static TClassEdit::ESTLType stl_type(const std::string& class_name) {
int nested = 0;
std::vector<std::string> inside;
int num = TClassEdit::GetSplit(class_name.c_str(),inside,nested);
if ( num > 1 ) {
return (TClassEdit::ESTLType)TClassEdit::STLKind(inside[0].c_str());
}
return TClassEdit::kNotSTL;
}
static TEmulatedCollectionProxy* GenEmulation(const char* class_name) {
if ( class_name ) {
std::string cl = class_name;
if ( cl.find("stdext::hash_") != std::string::npos )
cl.replace(3,10,"::");
if ( cl.find("__gnu_cxx::hash_") != std::string::npos )
cl.replace(0,16,"std::");
switch ( stl_type(cl) ) {
case TClassEdit::kNotSTL:
return 0;
case TClassEdit::kMap:
case TClassEdit::kMultiMap:
return new TEmulatedMapProxy(class_name);
default:
return new TEmulatedCollectionProxy(class_name);
}
}
return 0;
}
}
TVirtualCollectionProxy*
TCollectionProxyFactory::GenEmulatedProxy(const char* class_name)
{
return GenEmulation(class_name);
}
TClassStreamer*
TCollectionProxyFactory::GenEmulatedClassStreamer(const char* class_name)
{
TCollectionClassStreamer* s = new TCollectionClassStreamer();
s->AdoptStreamer(GenEmulation(class_name));
return s;
}
TMemberStreamer*
TCollectionProxyFactory::GenEmulatedMemberStreamer(const char* class_name)
{
TCollectionMemberStreamer* s = new TCollectionMemberStreamer();
s->AdoptStreamer(GenEmulation(class_name));
return s;
}
TCollectionProxyFactory::Proxy_t*
TCollectionProxyFactory::GenExplicitProxy( const ::ROOT::TCollectionProxyInfo &info, TClass *cl)
{
return new TGenCollectionProxy(info,cl);
}
TGenCollectionStreamer*
TCollectionProxyFactory::GenExplicitStreamer( const ::ROOT::TCollectionProxyInfo &info, TClass *cl )
{
TGenCollectionStreamer* ptr = new TGenCollectionStreamer(info,cl);
return ptr;
}
TClassStreamer*
TCollectionProxyFactory::GenExplicitClassStreamer( const ::ROOT::TCollectionProxyInfo &info, TClass *cl )
{
TCollectionClassStreamer* s = new TCollectionClassStreamer();
s->AdoptStreamer(GenExplicitStreamer(info,cl));
return s;
}
TMemberStreamer*
TCollectionProxyFactory::GenExplicitMemberStreamer( const ::ROOT::TCollectionProxyInfo &info, TClass *cl)
{
TCollectionMemberStreamer* s = new TCollectionMemberStreamer();
s->AdoptStreamer(GenExplicitStreamer(info,cl));
return s;
}
void TCollectionStreamer::InvalidProxyError() {
Fatal("TCollectionStreamer>","No proxy available. Data streaming impossible.");
}
TCollectionStreamer::TCollectionStreamer() : fStreamer(0)
{
}
TCollectionStreamer::TCollectionStreamer(const TCollectionStreamer& c)
{
if ( c.fStreamer ) {
fStreamer = dynamic_cast<TGenCollectionProxy*>(c.fStreamer->Generate());
R__ASSERT(fStreamer != 0);
return;
}
InvalidProxyError();
}
TCollectionStreamer::~TCollectionStreamer()
{
if ( fStreamer ) {
delete fStreamer;
}
}
void TCollectionStreamer::AdoptStreamer(TGenCollectionProxy* streamer)
{
if ( fStreamer ) {
delete fStreamer;
}
fStreamer = streamer;
}
void TCollectionStreamer::Streamer(TBuffer &buff, void *pObj, int , TClass* onFileClass )
{
if ( fStreamer ) {
TVirtualCollectionProxy::TPushPop env(fStreamer, pObj);
fStreamer->SetOnFileClass( onFileClass );
fStreamer->Streamer(buff);
return;
}
InvalidProxyError();
}
Last change: Fri Sep 19 09:32:39 2008
Last generated: 2008-09-19 09:32
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.