Commit 10924151 authored by Stezowski Olivier's avatar Stezowski Olivier
Browse files

ADF and GW have now a separated log system

git-svn-id: svn+ssh://anonsvn.in2p3.fr/agata/gammaware/trunk@1867 c3abf467-7ff2-0310-b516-c5fb849bdde0
parent d21c0968
#ifndef _LogCollector
#include "LogCollector.h"
#endif
#include "ADFLogCollector.h"
#ifndef _BasicAFP
#include "BasicAFP.h"
#endif
......
......@@ -19,9 +19,9 @@
***************************************************************************/
// ADF includes
#ifndef _LogMessage
#include "LogCollector.h"
#endif
#include "GwLogCollector.h"
#ifndef ADF_FrameBlock
#include "FrameBlock.h"
#endif
......
......@@ -73,7 +73,7 @@ UInt_t NOMADGene::ProcessBlock(ADF::FrameBlock &out)
out.Rewind(ConfAgent::kWrite);
//
if ( fNumberOfEventsSimulated > fNumberOfEventsToCreate ) { //
printf("NB SIMULATED %d \n ",fNumberOfEventsSimulated);
printf("NB SIMULATED %d \n ",(Int_t)fNumberOfEventsSimulated);
out.SetEoB(true);
return 0u;
}
......
......@@ -23,9 +23,9 @@
#include "ALoadedActor.h"
#include <stdexcept>
using namespace ADF;
using namespace Gw;
ADF::AConfigurator::AConfigurator(ALoadedActor *lactor, ConfigFunction f) :
Gw::AConfigurator::AConfigurator(ALoadedActor *lactor, ConfigFunction f) :
fError(0u),
fRefToLoadedActor(lactor),
fConfigFunction(f)
......@@ -33,7 +33,7 @@ ADF::AConfigurator::AConfigurator(ALoadedActor *lactor, ConfigFunction f) :
;
}
void ADF::AConfigurator::Configure()
void Gw::AConfigurator::Configure()
{
// now call the conf method, get path from the loaded actor
NamedItem<std::string> conf_path("ConfDir","./");
......@@ -46,7 +46,7 @@ void ADF::AConfigurator::Configure()
}
ADF::ALoadedActor::ALoadedActor(const Char_t *name) :
Gw::ALoadedActor::ALoadedActor(const Char_t *name) :
fLog("ALoadedActor"),
fName(name),
fGlobals(),
......@@ -63,7 +63,7 @@ ADF::ALoadedActor::ALoadedActor(const Char_t *name) :
;
}
AConfigurator *ADF::ALoadedActor::SetConfigurator(AConfigurator *new_conf)
AConfigurator *Gw::ALoadedActor::SetConfigurator(AConfigurator *new_conf)
{
AConfigurator *old_conf = fConfigurator; fConfigurator = new_conf;
//
......@@ -74,21 +74,21 @@ AConfigurator *ADF::ALoadedActor::SetConfigurator(AConfigurator *new_conf)
//! Add one input line to the actor. It does not check if possible ... it has to be done by the user before calling this using GetMaxInput/GetMaxOutput
/*!
*/
void ADF::ALoadedActor::AddInput(AnActorConnection *aconnection)
void Gw::ALoadedActor::AddInput(AnActorConnection *aconnection)
{
// add the connection to this and attach the right block of the connection
// to the embedded actor
fInputs.push_back(aconnection);
}
void ADF::ALoadedActor::AddOutput(AnActorConnection *aconnection)
void Gw::ALoadedActor::AddOutput(AnActorConnection *aconnection)
{
// add the connection to this and attach the right block of the connection
// to the embedded actor
fOutputs.push_back(aconnection);
}
void ADF::ALoadedActor::ComputeDepth(Int_t &depth)
void Gw::ALoadedActor::ComputeDepth(Int_t &depth)
{
if ( GetNbInput() == 0 )
return;
......@@ -110,7 +110,7 @@ void ADF::ALoadedActor::ComputeDepth(Int_t &depth)
depth = max_depth;
}
void ADF::ALoadedActor::SetGlobals( const std::vector < ANamedItem *> &globals )
void Gw::ALoadedActor::SetGlobals( const std::vector < ANamedItem *> &globals )
{
for (size_t i = 0; i < globals.size(); i++) {
Bool_t add_new = true;
......@@ -138,7 +138,7 @@ void ADF::ALoadedActor::SetGlobals( const std::vector < ANamedItem *> &globals )
}
}
void ADF::ALoadedActor::SetGlobal( const ANamedItem &global )
void Gw::ALoadedActor::SetGlobal( const ANamedItem &global )
{
Bool_t add_new = true;
//
......@@ -164,7 +164,7 @@ void ADF::ALoadedActor::SetGlobal( const ANamedItem &global )
}
}
Bool_t ADF::ALoadedActor::GetGlobal( ANamedItem &global ) const
Bool_t Gw::ALoadedActor::GetGlobal( ANamedItem &global ) const
{
Bool_t is_set = false;
//
......@@ -181,7 +181,7 @@ Bool_t ADF::ALoadedActor::GetGlobal( ANamedItem &global ) const
return is_set;
}
Short_t ADF::ALoadedActor::IsLinked(ALoadedActor *actor, AnActorConnection *&connection) const
Short_t Gw::ALoadedActor::IsLinked(ALoadedActor *actor, AnActorConnection *&connection) const
{
Short_t result = 0;
......@@ -207,7 +207,7 @@ Short_t ADF::ALoadedActor::IsLinked(ALoadedActor *actor, AnActorConnection *&con
connection = 0x0; return result;
}
void ADF::ALoadedActor::ConfigureActor()
void Gw::ALoadedActor::ConfigureActor()
{
fConfigurator->SetError(0u);
fConfigurator->Configure();
......@@ -215,7 +215,7 @@ void ADF::ALoadedActor::ConfigureActor()
SetLastError(fConfigurator->GetError());
}
void ADF::ALoadedActor::RegisterActor()
void Gw::ALoadedActor::RegisterActor()
{
fLog.SetProcessMethod("RegisterActor()");
......@@ -311,7 +311,7 @@ void ADF::ALoadedActor::RegisterActor()
fLog << dolog;
}
void ADF::ALoadedActor::InitActor()
void Gw::ALoadedActor::InitActor()
{
UInt_t error_code = 0u;
fActor->process_initialise(&error_code);
......@@ -319,7 +319,7 @@ void ADF::ALoadedActor::InitActor()
SetLastError(error_code);
}
void ADF::ALoadedActor::ProcessActorGeneration_2_1_0 (Short_t generation)
void Gw::ALoadedActor::ProcessActorGeneration_2_1_0 (Short_t generation)
{
NarvalProducer *p; NarvalConsumer *c; NarvalFilter *f; FrameBlock *block_in, *block_out; UInt_t error_code = 0u, size_in, size_out, used_size_out; char *input_buffer, *output_buffer;
......@@ -399,7 +399,7 @@ void ADF::ALoadedActor::ProcessActorGeneration_2_1_0 (Short_t generation)
p = dynamic_cast<NarvalProducer *> (fActor);
SetStatus(kRunning);
error_code = p->ProcessBlock((*block));
if ( block->GetSize() ) {
if ( block->GetSize() ) { // producer are specific, could produce empty
SetStatus(ALoadedActor::kHasRun);
}
/*
......@@ -467,7 +467,7 @@ void ADF::ALoadedActor::ProcessActorGeneration_2_1_0 (Short_t generation)
SetLastError(error_code);
}
void ADF::ALoadedActor::ProcessActor ()
void Gw::ALoadedActor::ProcessActor ()
{
// std::cout << " Call of (ProcessActor) " << fName << std::endl ;
......
......@@ -20,8 +20,8 @@
/** \file ALoadedActor.h header file for ALoadedActor.cpp */
#ifndef ADF_ALoadedActor
#define ADF_ALoadedActor
#ifndef Gw_ALoadedActor
#define Gw_ALoadedActor
// std headers
#include <string>
......@@ -34,7 +34,8 @@
//! the function used to configure the underlying actor. Added to allow configuration by calling explicitely one of the base class instead of the class itself.
typedef void (*ConfigFunction)(const Char_t *, UInt_t *);
namespace ADF {
using namespace ADF;
namespace Gw {
class ALoadedActor;
......@@ -124,9 +125,9 @@ protected:
AConfigurator *fConfigurator;
protected:
//! link to actors providing data ... not owned by this
std::vector < ADF::AnActorConnection * > fInputs;
std::vector < Gw::AnActorConnection * > fInputs;
//! link to actors for sending data ... not owned by this
std::vector < ADF::AnActorConnection * > fOutputs;
std::vector < Gw::AnActorConnection * > fOutputs;
protected:
//! depth in the toplogy in which this actor is active.
Int_t fDepth;
......
......@@ -2,7 +2,7 @@
#include "AnActorConnection.h"
#include "ALoadedActor.h"
using namespace ADF;
using namespace Gw;
AnActorConnection::AnActorConnection() : fLazy(0u)
{;}
......
......@@ -20,18 +20,19 @@
/** \file AnActorConnection.h header file for AnActorConnection.cpp */
#ifndef ADF_AnActorConnection
#define ADF_AnActorConnection
#ifndef Gw_AnActorConnection
#define Gw_AnActorConnection
#include <string>
//
#include "ADFConfig.h"
#include "FrameBlock.h"
namespace ADF
namespace Gw
{
class ALoadedActor;
class FrameBlock;
//! Base class that connects two actors in a general topology
/*!
......@@ -87,7 +88,7 @@ public:
{ return false; }
//! return the address of the block - opt = p => producer, c => consumer (different in case the connection is a pipeline)
virtual FrameBlock *GetBlock(const Char_t opt) = 0;
virtual ADF::FrameBlock *GetBlock(const Char_t opt) = 0;
};
} // end namespace
......
......@@ -23,7 +23,7 @@
#include "BaseEmulator.h"
#include <stdexcept>
using namespace ADF;
using namespace Gw;
BaseEmulator::BaseEmulator(std::string name) : fLog(name.data()), fName(name), fGlobals(), fAllActors() , fAllConnections(), fTopology()
{
......@@ -79,7 +79,7 @@ BaseEmulator::~BaseEmulator()
fLog << dolog;
}
void ADF::BaseEmulator::SetGlobal( const ANamedItem &global )
void BaseEmulator::SetGlobal( const ANamedItem &global )
{
Bool_t add_new = true;
//
......@@ -250,16 +250,22 @@ void BaseEmulator::Run(Int_t max_loop)
for (UInt_t i = 0; i < fTopology.size(); i++ ) {
for (UInt_t j = 0; j < fTopology[i].size() ; j++) {
if ( nb_try > 0 ) {
if ( fTopology[i][j]->GetStatus() == ALoadedActor::kRunning )
fTopology[i][j]->SetStatus(ALoadedActor::kDoRunning);
// at least one loop with no active actors, reste running into do running
}
switch (fTopology[i][j]->GetStatus()) {
case ALoadedActor::kInitialised :
case ALoadedActor::kIdle :
case ALoadedActor::kDoRunning :
fTopology[i][j]->SetStatus(ALoadedActor::kDoRunning);
fTopology[i][j]->ProcessActor();
if ( fTopology[i][j]->GetStatus() == ALoadedActor::kHasRun ) {
nb_run++;
fTopology[i][j]->SetStatus(ALoadedActor::kIdle);
}
else
break;
default:
......@@ -279,6 +285,8 @@ void BaseEmulator::Run(Int_t max_loop)
nb_try++;
fLog << info << " No active actors ==> STOP emulator after " << max_try << " # of tries. nb_try = " << nb_try << " nb_loop "<< nb_loop << nline;
}
else nb_try = 0;
nb_loop++;
} // while
......
......@@ -20,8 +20,8 @@
/** \file BaseEmulator.h header file for BaseEmulator.cpp */
#ifndef ADF_BaseEmulator
#define ADF_BaseEmulator
#ifndef Gw_BaseEmulator
#define Gw_BaseEmulator
#include <vector>
#include <sstream>
......@@ -31,9 +31,9 @@
#include "NarvalInterface.h"
#include "DataHandling.h"
#include "LogMessage.h"
#include "GwLogMessage.h"
namespace ADF {
namespace Gw {
//! Base class for an emulator
/*!
......
......@@ -24,7 +24,7 @@
#include "BasicReplica.h"
using namespace ADF;
using namespace Gw;
UInt_t BasicReplica::ProcessBlocks()
{
......
......@@ -25,19 +25,22 @@
#include "NarvalInterface.h"
#include "FrameBlock.h"
#include "ADFConfig.h"
namespace ADF {
class FrameBlock;
class ADF::FrameBlock;
using namespace ADF;
namespace Gw {
//! It has a single input line and copies it to all the output lines attached
/*!
*/
class BasicReplica : public NarvalShunter
class BasicReplica : public ADF::NarvalShunter
{
private:
FrameBlock *fAttachedInputBlock;
std::vector < FrameBlock * > fAttachedOutputBlocks;
ADF::FrameBlock *fAttachedInputBlock;
std::vector < ADF::FrameBlock * > fAttachedOutputBlocks;
private:
ULong64_t fBytesAttachedInputBlock;
std::vector < ULong64_t > fBytesAttachedOutputBlock;
......@@ -68,7 +71,7 @@ public:
The returned value is the slot position
if slot < 0 and >= GetNbInput, the block cannot be attached and it returns -1
*/
virtual Int_t AttachInput(FrameBlock * block, Int_t slot = -1)
virtual Int_t AttachInput(ADF::FrameBlock * block, Int_t slot = -1)
{
if ( slot < 1 ) {
fAttachedInputBlock = block;
......@@ -82,7 +85,7 @@ public:
The returned value is the slot position
if slot < 0 and >= GetNbOutput, the block cannot be attached and it returns -1
*/
virtual Int_t AttachOutput(FrameBlock *block, Int_t slot = -1)
virtual Int_t AttachOutput(ADF::FrameBlock *block, Int_t slot = -1)
{
Int_t rslot = -1; ULong64_t init = 0UL;
......
......@@ -2,7 +2,7 @@
#include "DEmulator.h"
#include <stdexcept>
using namespace ADF;
using namespace Gw;
Bool_t DActorConnection::IsReadyforConsumer()
{
......
......@@ -20,11 +20,8 @@
/** \file DEmulator.h header file for DEmulator.cpp */
#ifndef ADF_DEmulator
#define ADF_DEmulator
// #include <LogMessage.h>
#ifndef Gw_DEmulator
#define Gw_DEmulator
#include <vector>
#include <string>
......@@ -32,7 +29,7 @@
#include "BaseEmulator.h"
namespace ADF
namespace Gw
{
//! Default connection between actors : to be used in non-multi threaded programs
......
......@@ -26,6 +26,7 @@
// ADF includes
#include "NarvalInterface.h"
#include "Trigger.h"
#include "GwLogMessage.h"
// ROOT includes
#include "TTask.h"
......
......@@ -34,9 +34,13 @@ set( with_dictionnaries
Random
)
set( without_dictionnaries
../../adf/CentralLog # to avoid having the same file in two directories in the svn
../../adf/LogCollector
../../adf/LogMessage
SingletonDestroyer
GwCentralLog
GwLogCollector
GwLogMessage
# ../../adf/CentralLog # to avoid having the same file in two directories in the svn
# ../../adf/LogCollector
# ../../adf/LogMessage
XtermProgressBar
)
# add includes : root + current (before to have the latest) + all gw includes copied in CMAKE_BINARY_DIR/include
......
......@@ -32,9 +32,7 @@
#include "Env.h"
#endif
#ifndef _LogMessage
#include "LogMessage.h"
#endif
#include "GwLogMessage.h"
#include "TGClient.h"
#include "TGMimeTypes.h"
......
/***************************************************************************
* Copyright (C) 2004 by Olivier Stezowski *
* stezow(AT)ipnl.in2p3.fr *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* aLong_t with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/** \file GwCentralLog.cpp compiled in GwCore*/
#include <iostream>
#ifndef Gw_LogCollector
#include "GwLogCollector.h"
#endif
#ifndef Gw_CentralLog
#include "GwCentralLog.h"
#endif
using namespace Gw;
SingletonDestroyer<CentralLog> CentralLog::gTheCentralLogDestroyer;
CentralLog *CentralLog::gTheCentralLog = 0x0;
/*
CentralLogDestroyer::CentralLogDestroyer (Gw::CentralLog * s)
{
fCentralLog = s;
}
CentralLogDestroyer::~CentralLogDestroyer ()
{
if (fCentralLog)
delete fCentralLog;
fCentralLog = 0x0;
}
void CentralLogDestroyer::SetCentralLog(CentralLog *log)
{
fCentralLog = log;
}
*/
CentralLog::CentralLog() :
fCurrentCollector(0x0),
fListOfCollectors()
{
#ifdef DEBUGSTATIC
std::clog << "[[static]] CentralLog::CentralLog() ]\n[...\n" ;
std::clog << " Default collectors are built " << std::endl;
#endif
Add ( new LogCollector("Null",true) );
Add ( new OStreamCollector("cout",true) );
// default is clog
ChangeCollector("cout");
#ifdef DEBUGSTATIC
std::clog << "...]" << std::endl;
#endif
}
CentralLog::~CentralLog()
{
#ifdef DEBUGSTATIC
std::clog << "[[static]] CentralLog::~CentralLog() ]\n[...\n" ;
std::clog << " Collectors owned by Central Log are deleted " << std::endl;
#endif
fCurrentCollector = 0x0;
// loop to check the name does not yet exist
std::list< LogCollector * >::iterator
listed_item;
for ( listed_item = fListOfCollectors.begin() ; listed_item != fListOfCollectors.end() ; listed_item++ ) {
if ( (*listed_item)->IsDeleteByCentralLog() ) {
#ifdef DEBUGSTATIC
std::clog << " --> " << (*listed_item)->GetName()
<< " deleted from the central log ... ";
#endif
delete (*listed_item);
#ifdef DEBUGSTATIC
std::clog << " ... done " << std::endl;
#endif
}
}
#ifdef DEBUGSTATIC
std::clog << "...]" << std::endl;
#endif
}
CentralLog *CentralLog::theCentralLog()
{
if ( gTheCentralLog == 0x0 ) {
gTheCentralLog = new CentralLog();
gTheCentralLogDestroyer.SetSingleton (gTheCentralLog) ;
}
return gTheCentralLog;
}
bool CentralLog::ChangeCollector(std::string whichlog)
{
bool ok = false;
// loop to check the name does not yet exist
std::list< LogCollector * >::iterator
listed_item;
for ( listed_item = fListOfCollectors.begin() ; listed_item != fListOfCollectors.end() ; listed_item++ ) {
if ( (*listed_item)->GetName() == whichlog ) {
fCurrentCollector = (*listed_item);
ok = true;
break;
}
}
if ( ok )
std::clog << "[[info]] CentralLog::ChangeCollector() ] [ "
<< fCurrentCollector->GetName() << " is now the current collector ]" << std::endl;
return ok;
}
bool CentralLog::IsCollector(std::string whichlog)
{
bool ok = false;
// loop to check the name does not yet exist
std::list< LogCollector * >::iterator
listed_item;
for ( listed_item = fListOfCollectors.begin() ; listed_item != fListOfCollectors.end() ; listed_item++ ) {
if ( (*listed_item)->GetName() == whichlog ) {
fCurrentCollector = (*listed_item);
ok = true;
break;
}
}
return ok;
}
LogCollector *CentralLog::GetCurrentLogCollector() const
{
return fCurrentCollector;
}