CMS 3D CMS Logo

Classes | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends

gen::FortranInstance Class Reference

#include <FortranInstance.h>

Inheritance diagram for gen::FortranInstance:
gen::Herwig6Instance gen::Pythia6Service gen::PomwigHadronizer Herwig6Hadronizer MCatNLOSource gen::Pythia6ServiceWithCallback gen::Pythia6ServiceWithCallback

List of all members.

Classes

struct  InstanceWrapper

Public Member Functions

void call (void(&fn)())
template<typename T >
T call (T(&fn)())
template<typename T , typename A1 , typename A2 >
T call (T(&fn)(A1, A2), A1 a1, A2 a2)
template<typename A >
void call (void(&fn)(A), A a)
template<typename T , typename A >
T call (T(&fn)(A), A a)
template<typename A1 , typename A2 >
void call (void(&fn)(A1, A2), A1 a1, A2 a2)
virtual void enter ()
 FortranInstance ()
virtual void leave ()
virtual void upEvnt ()
virtual void upInit ()
virtual bool upVeto ()
virtual ~FortranInstance ()

Static Public Member Functions

template<typename T >
static TgetInstance ()

Static Private Member Functions

static void throwMissingInstance ()

Private Attributes

int instanceNesting

Static Private Attributes

static FortranInstancecurrentInstance = 0

Friends

void gen::upevnt_ ()
void gen::upinit_ ()
void gen::upveto_ (int *)

Detailed Description

Definition at line 13 of file FortranInstance.h.


Constructor & Destructor Documentation

gen::FortranInstance::FortranInstance ( ) [inline]

Definition at line 15 of file FortranInstance.h.

gen::FortranInstance::~FortranInstance ( ) [virtual]

Definition at line 36 of file FortranInstance.cc.

References currentInstance, and edm::friendlyname::friendlyName().

{
        if (currentInstance == this) {
                edm::LogWarning("ReentrancyProblem")
                        << edm::friendlyname::friendlyName(typeid(*this).name())
                        << " destroyed while it was the "
                           "current active instance." << std::endl;
                currentInstance = 0;
        }
}

Member Function Documentation

void gen::FortranInstance::call ( void(&)()  fn) [inline]
template<typename T >
T gen::FortranInstance::call ( T(&)()  fn) [inline]

Definition at line 20 of file FortranInstance.h.

References wrapper.

        { InstanceWrapper wrapper(this); return fn(); }
template<typename T , typename A >
T gen::FortranInstance::call ( T(&)(A)  fn,
a 
) [inline]

Definition at line 24 of file FortranInstance.h.

References wrapper.

        { InstanceWrapper wrapper(this); return fn(a); }
template<typename A1 , typename A2 >
void gen::FortranInstance::call ( void(&)(A1, A2)  fn,
A1  a1,
A2  a2 
) [inline]

Definition at line 26 of file FortranInstance.h.

References wrapper.

        { InstanceWrapper wrapper(this); fn(a1, a2); }
template<typename A >
void gen::FortranInstance::call ( void(&)(A)  fn,
a 
) [inline]

Definition at line 22 of file FortranInstance.h.

References wrapper.

        { InstanceWrapper wrapper(this); fn(a); }
template<typename T , typename A1 , typename A2 >
T gen::FortranInstance::call ( T(&)(A1, A2)  fn,
A1  a1,
A2  a2 
) [inline]

Definition at line 28 of file FortranInstance.h.

References wrapper.

        { InstanceWrapper wrapper(this); return fn(a1, a2); }
void gen::FortranInstance::enter ( ) [virtual]

Reimplemented in gen::Pythia6Service.

Definition at line 49 of file FortranInstance.cc.

References Exception, edm::friendlyname::friendlyName(), and edm::errors::LogicError.

Referenced by gen::FortranInstance::InstanceWrapper::InstanceWrapper().

{
        // we should add a boost::mutex here if we care about being
        // multithread-safe
        if (currentInstance && currentInstance != this)
                throw edm::Exception(edm::errors::LogicError)
                        << edm::friendlyname::friendlyName(typeid(*this).name())
                        << "::enter() called from a different "
                           "instance while an instance was already active."
                        << std::endl;

        if (!currentInstance && instanceNesting != 0)
                throw edm::Exception(edm::errors::LogicError)
                        << edm::friendlyname::friendlyName(typeid(*this).name())
                        << "::enter() called on an empty "
                           "instance, but instance counter is nonzero."
                        << std::endl;

        currentInstance = this;
        instanceNesting++;
}
template<typename T >
static T* gen::FortranInstance::getInstance ( ) [inline, static]
void gen::FortranInstance::leave ( ) [virtual]

Definition at line 71 of file FortranInstance.cc.

References Exception, edm::friendlyname::friendlyName(), and edm::errors::LogicError.

Referenced by gen::FortranInstance::InstanceWrapper::~InstanceWrapper().

{
        if (!currentInstance)
                throw edm::Exception(edm::errors::LogicError)
                        << edm::friendlyname::friendlyName(typeid(*this).name())
                        << "::leave() called without an "
                           "active instance." << std::endl;
        else if (currentInstance != this)
                throw edm::Exception(edm::errors::LogicError)
                        << edm::friendlyname::friendlyName(typeid(*this).name())
                        << "::leave() called from a "
                           "different instance." << std::endl;
        else if (instanceNesting <= 0)
                throw edm::Exception(edm::errors::LogicError)
                        << edm::friendlyname::friendlyName(typeid(*this).name())
                        << "::leave() called with a "
                           "nesting level of zero." << std::endl;

        if (--instanceNesting == 0)
                currentInstance = 0;
}
void gen::FortranInstance::throwMissingInstance ( ) [static, private]

Definition at line 93 of file FortranInstance.cc.

References Exception, and edm::errors::LogicError.

Referenced by getInstance().

{
        throw edm::Exception(edm::errors::LogicError)
                << "FortranInstance::getInstance() called from "
                   "a Fortran context, but no current instance "
                   "has been registered." << std::endl;
}
void gen::FortranInstance::upEvnt ( ) [virtual]

Reimplemented in gen::Pythia6ServiceWithCallback, Herwig6Hadronizer, and gen::Pythia6ServiceWithCallback.

Definition at line 112 of file FortranInstance.cc.

References Exception, and edm::friendlyname::friendlyName().

{
        throw cms::Exception("UnimplementedCallback")
                << edm::friendlyname::friendlyName(typeid(*this).name())
                << "::upEvnt() stub called. "
                   "If user process needs to be generated, please derive "
                   "and implement the upEvnt() method." << std::endl;
}
void gen::FortranInstance::upInit ( ) [virtual]

Reimplemented in gen::Pythia6ServiceWithCallback, Herwig6Hadronizer, and gen::Pythia6ServiceWithCallback.

Definition at line 103 of file FortranInstance.cc.

References Exception, and edm::friendlyname::friendlyName().

{
        throw cms::Exception("UnimplementedCallback")
                << edm::friendlyname::friendlyName(typeid(*this).name())
                << "::upInit() stub called. "
                   "If user process needs to be generated, please derive "
                   "and implement the upInit() method." << std::endl;
}
bool gen::FortranInstance::upVeto ( ) [virtual]

Reimplemented in gen::Pythia6ServiceWithCallback, and gen::Pythia6ServiceWithCallback.

Definition at line 121 of file FortranInstance.cc.

{
        return false;
}

Friends And Related Function Documentation

void gen::upevnt_ ( ) [friend]
void gen::upinit_ ( ) [friend]
void gen::upveto_ ( int *  ) [friend]

Member Data Documentation

Definition at line 86 of file FortranInstance.h.

Referenced by getInstance(), and ~FortranInstance().

Definition at line 83 of file FortranInstance.h.