#define GET_ALL "GET ALL\n"
#ifdef USE_ROOT
-ClassImp(MonitoringReader);
-ClassImp(HOMERReader);
+ClassImp(AliHLTMonitoringReader);
+ClassImp(AliHLTHOMERReader);
#endif
#ifdef USE_ROOT
-HOMERReader::HOMERReader()
+AliHLTHOMERReader::AliHLTHOMERReader()
:
fCurrentEventType(~(homer_uint64)0),
fCurrentEventID(~(homer_uint64)0),
#endif
-HOMERReader::HOMERReader( const char* hostname, unsigned short port )
+AliHLTHOMERReader::AliHLTHOMERReader( const char* hostname, unsigned short port )
:
- MonitoringReader(),
+ AliHLTMonitoringReader(),
fCurrentEventType(~(homer_uint64)0),
fCurrentEventID(~(homer_uint64)0),
fBlockCnt(0),
}
}
-HOMERReader::HOMERReader( unsigned int tcpCnt, const char** hostnames, unsigned short* ports )
+AliHLTHOMERReader::AliHLTHOMERReader( unsigned int tcpCnt, const char** hostnames, unsigned short* ports )
:
- MonitoringReader(),
+ AliHLTMonitoringReader(),
fCurrentEventType(~(homer_uint64)0),
fCurrentEventID(~(homer_uint64)0),
fBlockCnt(0),
}
}
-HOMERReader::HOMERReader( key_t shmKey, int shmSize )
+AliHLTHOMERReader::AliHLTHOMERReader( key_t shmKey, int shmSize )
:
- MonitoringReader(),
+ AliHLTMonitoringReader(),
fCurrentEventType(~(homer_uint64)0),
fCurrentEventID(~(homer_uint64)0),
fBlockCnt(0),
}
}
-HOMERReader::HOMERReader( unsigned int shmCnt, key_t* shmKeys, int* shmSizes )
+AliHLTHOMERReader::AliHLTHOMERReader( unsigned int shmCnt, key_t* shmKeys, int* shmSizes )
:
- MonitoringReader(),
+ AliHLTMonitoringReader(),
fCurrentEventType(~(homer_uint64)0),
fCurrentEventID(~(homer_uint64)0),
fBlockCnt(0),
}
}
-HOMERReader::HOMERReader( unsigned int tcpCnt, const char** hostnames, unsigned short* ports,
+AliHLTHOMERReader::AliHLTHOMERReader( unsigned int tcpCnt, const char** hostnames, unsigned short* ports,
unsigned int shmCnt, key_t* shmKeys, int* shmSizes )
:
- MonitoringReader(),
+ AliHLTMonitoringReader(),
fCurrentEventType(~(homer_uint64)0),
fCurrentEventID(~(homer_uint64)0),
fBlockCnt(0),
fDataSources[n].fNdx = n;
}
}
-HOMERReader::~HOMERReader()
+AliHLTHOMERReader::~AliHLTHOMERReader()
{
// see header file for class documentation
ReleaseCurrentEvent();
FreeDataSources();
}
-int HOMERReader::ReadNextEvent()
+int AliHLTHOMERReader::ReadNextEvent()
{
// see header file for class documentation
// Read in the next available event
return ReadNextEvent( false, 0 );
}
-int HOMERReader::ReadNextEvent( unsigned long timeout )
+int AliHLTHOMERReader::ReadNextEvent( unsigned long timeout )
{
// see header file for class documentation
// Read in the next available event
return ReadNextEvent( true, timeout );
}
-unsigned long HOMERReader::GetBlockDataLength( unsigned long ndx ) const
+unsigned long AliHLTHOMERReader::GetBlockDataLength( unsigned long ndx ) const
{
// see header file for class documentation
// Return the size (in bytes) of the current event's data
return fBlocks[ndx].fLength;
}
-const void* HOMERReader::GetBlockData( unsigned long ndx ) const
+const void* AliHLTHOMERReader::GetBlockData( unsigned long ndx ) const
{
// see header file for class documentation
// Return a pointer to the start of the current event's data
return fBlocks[ndx].fData;
}
-const char* HOMERReader::GetBlockSendNodeID( unsigned long ndx ) const
+const char* AliHLTHOMERReader::GetBlockSendNodeID( unsigned long ndx ) const
{
// see header file for class documentation
// Return IP address or hostname of node which sent the
//return fBlocks[ndx].fOriginatingNodeID;
}
-homer_uint8 HOMERReader::GetBlockByteOrder( unsigned long ndx ) const
+homer_uint8 AliHLTHOMERReader::GetBlockByteOrder( unsigned long ndx ) const
{
// see header file for class documentation
// Return byte order of the data stored in the
return *(((homer_uint8*)fBlocks[ndx].fMetaData)+kByteOrderAttribute_8b_Offset);
}
-homer_uint8 HOMERReader::GetBlockTypeAlignment( unsigned long ndx, homer_uint8 dataType ) const
+homer_uint8 AliHLTHOMERReader::GetBlockTypeAlignment( unsigned long ndx, homer_uint8 dataType ) const
{
// see header file for class documentation
// Return the alignment (in bytes) of the given datatype
return *(((homer_uint8*)fBlocks[ndx].fMetaData)+kAlignment_8b_StartOffset+dataType);
}
-homer_uint64 HOMERReader::GetBlockStatusFlags( unsigned long ndx ) const
+homer_uint64 AliHLTHOMERReader::GetBlockStatusFlags( unsigned long ndx ) const
{
// see header file for class documentation
if ( ndx >= fBlockCnt )
/* HOMER specific */
/* Return the type of the data in the current event's data
block with the given block index (starting at 0). */
-homer_uint64 HOMERReader::GetBlockDataType( unsigned long ndx ) const
+homer_uint64 AliHLTHOMERReader::GetBlockDataType( unsigned long ndx ) const
{
// see header file for class documentation
if ( ndx >= fBlockCnt )
/* Return the origin of the data in the current event's data
block with the given block index (starting at 0). */
-homer_uint32 HOMERReader::GetBlockDataOrigin( unsigned long ndx ) const
+homer_uint32 AliHLTHOMERReader::GetBlockDataOrigin( unsigned long ndx ) const
{
// see header file for class documentation
if ( ndx >= fBlockCnt )
/* Return a specification of the data in the current event's data
block with the given block index (starting at 0). */
-homer_uint32 HOMERReader::GetBlockDataSpec( unsigned long ndx ) const
+homer_uint32 AliHLTHOMERReader::GetBlockDataSpec( unsigned long ndx ) const
{
// see header file for class documentation
if ( ndx >= fBlockCnt )
/* Find the next data block in the current event with the given
data type, origin, and specification. Returns the block's
index. */
-unsigned long HOMERReader::FindBlockNdx( homer_uint64 type, homer_uint32 origin,
+unsigned long AliHLTHOMERReader::FindBlockNdx( homer_uint64 type, homer_uint32 origin,
homer_uint32 spec, unsigned long startNdx ) const
{
// see header file for class documentation
/* Find the next data block in the current event with the given
data type, origin, and specification. Returns the block's
index. */
-unsigned long HOMERReader::FindBlockNdx( char type[8], char origin[4],
+unsigned long AliHLTHOMERReader::FindBlockNdx( char type[8], char origin[4],
homer_uint32 spec, unsigned long startNdx ) const
{
// see header file for class documentation
/* Return the ID of the node that actually produced this data block.
This may be different from the node which sent the data to this
monitoring object as returned by GetBlockSendNodeID. */
-const char* HOMERReader::GetBlockCreateNodeID( unsigned long ndx ) const
+const char* AliHLTHOMERReader::GetBlockCreateNodeID( unsigned long ndx ) const
{
// see header file for class documentation
if ( ndx >= fBlockCnt )
}
-void HOMERReader::Init()
+void AliHLTHOMERReader::Init()
{
// see header file for class documentation
fCurrentEventType = ~(homer_uint64)0;
fEventRequestAdvanceTime = 0;
}
-bool HOMERReader::AllocDataSources( unsigned int sourceCnt )
+bool AliHLTHOMERReader::AllocDataSources( unsigned int sourceCnt )
{
// see header file for class documentation
fDataSources = new DataSource[ sourceCnt ];
return true;
}
-int HOMERReader::AddDataSource( const char* hostname, unsigned short port, DataSource& source )
+int AliHLTHOMERReader::AddDataSource( const char* hostname, unsigned short port, DataSource& source )
{
// see header file for class documentation
struct hostent* he;
return 0;
}
-int HOMERReader::AddDataSource( key_t shmKey, int shmSize, DataSource& source )
+int AliHLTHOMERReader::AddDataSource( key_t shmKey, int shmSize, DataSource& source )
{
// see header file for class documentation
int ret;
return 0;
}
-void HOMERReader::FreeDataSources()
+void AliHLTHOMERReader::FreeDataSources()
{
// see header file for class documentation
for ( unsigned n=0; n < fDataSourceCnt; n++ )
}
}
-int HOMERReader::FreeShmDataSource( DataSource& source )
+int AliHLTHOMERReader::FreeShmDataSource( DataSource& source )
{
// see header file for class documentation
if ( source.fShmPtr )
return 0;
}
-int HOMERReader::FreeTCPDataSource( DataSource& source )
+int AliHLTHOMERReader::FreeTCPDataSource( DataSource& source )
{
// see header file for class documentation
if ( source.fTCPConnection )
return 0;
}
-int HOMERReader::ReadNextEvent( bool useTimeout, unsigned long timeout )
+int AliHLTHOMERReader::ReadNextEvent( bool useTimeout, unsigned long timeout )
{
// see header file for class documentation
if ( fDataSourceCnt<=0 )
return 0;
}
-void HOMERReader::ReleaseCurrentEvent()
+void AliHLTHOMERReader::ReleaseCurrentEvent()
{
// see header file for class documentation
// sources.fDataRead = 0;
}
}
-int HOMERReader::TriggerTCPSource( DataSource& source, bool useTimeout, unsigned long timeoutUsec )
+int AliHLTHOMERReader::TriggerTCPSource( DataSource& source, bool useTimeout, unsigned long timeoutUsec )
{
// see header file for class documentation
int ret;
return 0;
}
-int HOMERReader::TriggerShmSource( DataSource& source, bool, unsigned long )
+int AliHLTHOMERReader::TriggerShmSource( DataSource& source, bool, unsigned long )
{
// see header file for class documentation
+// clear the size indicator in the first 4 bytes of the buffer to request data
+// from the HOMER writer.
if ( source.fShmPtr )
{
*(homer_uint32*)( source.fShmPtr ) = 0;
return EFAULT;
}
-int HOMERReader::ReadDataFromTCPSources( unsigned sourceCnt, DataSource* sources, bool useTimeout, unsigned long timeout )
+int AliHLTHOMERReader::ReadDataFromTCPSources( unsigned sourceCnt, DataSource* sources, bool useTimeout, unsigned long timeout )
{
// see header file for class documentation
bool toRead = false;
}
/*
-int HOMERReader::ReadDataFromTCPSources( DataSource& source, bool useTimeout, unsigned long timeout )
+int AliHLTHOMERReader::ReadDataFromTCPSources( DataSource& source, bool useTimeout, unsigned long timeout )
{
#warning TODO If useTimeout: Set sockets to nonblocking, select + loop around GET_ONE write
// Send one event request
*/
/*
-int HOMERReader::ReadDataFromShmSource( DataSource& source, bool useTimeout, unsigned long timeout )
+int AliHLTHOMERReader::ReadDataFromShmSource( DataSource& source, bool useTimeout, unsigned long timeout )
{
}
*/
-int HOMERReader::ReadDataFromShmSources( unsigned sourceCnt, DataSource* sources, bool useTimeout, unsigned long timeout )
+int AliHLTHOMERReader::ReadDataFromShmSources( unsigned sourceCnt, DataSource* sources, bool useTimeout, unsigned long timeout )
{
// see header file for class documentation
struct timeval tv1, tv2;
return 0;
}
-int HOMERReader::ParseSourceData( DataSource& source )
+int AliHLTHOMERReader::ParseSourceData( DataSource& source )
{
// see header file for class documentation
if ( source.fData )
return EFAULT;
}
-int HOMERReader::ReAllocBlocks( unsigned long newCnt )
+int AliHLTHOMERReader::ReAllocBlocks( unsigned long newCnt )
{
// see header file for class documentation
DataBlock* newBlocks;
return 0;
}
-homer_uint64 HOMERReader::GetSourceEventID( DataSource& source )
+homer_uint64 AliHLTHOMERReader::GetSourceEventID( DataSource& source )
{
// see header file for class documentation
homer_uint8 sourceByteOrder = ((homer_uint8*)source.fData)[ kByteOrderAttribute_8b_Offset ];
return Swap( kHOMERNativeByteOrder, sourceByteOrder, ((homer_uint64*)source.fData)[ kSubType1_64b_Offset ] );
}
-homer_uint64 HOMERReader::GetSourceEventType( DataSource& source )
+homer_uint64 AliHLTHOMERReader::GetSourceEventType( DataSource& source )
{
// see header file for class documentation
homer_uint8 sourceByteOrder = ((homer_uint8*)source.fData)[ kByteOrderAttribute_8b_Offset ];
return Swap( kHOMERNativeByteOrder, sourceByteOrder, ((homer_uint64*)source.fData)[ kType_64b_Offset ] );
}
-homer_uint64 HOMERReader::Swap( homer_uint8 destFormat, homer_uint8 sourceFormat, homer_uint64 source ) const
+homer_uint64 AliHLTHOMERReader::Swap( homer_uint8 destFormat, homer_uint8 sourceFormat, homer_uint64 source ) const
{
// see header file for class documentation
if ( destFormat == sourceFormat )
((source & 0xFF00000000000000ULL) >> 56);
}
-homer_uint32 HOMERReader::Swap( homer_uint8 destFormat, homer_uint8 sourceFormat, homer_uint32 source ) const
+homer_uint32 AliHLTHOMERReader::Swap( homer_uint8 destFormat, homer_uint8 sourceFormat, homer_uint32 source ) const
{
// see header file for class documentation
if ( destFormat == sourceFormat )
((source & 0xFF0000UL) >> 8) |
((source & 0xFF000000UL) >> 24);
}
+
+AliHLTHOMERReader* AliHLTHOMERReaderCreate(const void* pBuffer, int size)
+ {
+// see header file for function documentation
+ //return new AliHLTHOMERReader(pBuffer, size);
+ return NULL;
+ }
+
+void AliHLTHOMERReaderDelete(AliHLTHOMERReader* pInstance)
+ {
+// see header file for function documentation
+ if (pInstance) delete pInstance;
+ }
+
/*
***************************************************************************
**
-class MonitoringReader
+class AliHLTMonitoringReader
{
public:
- MonitoringReader() {};
- virtual ~MonitoringReader() {};
+ AliHLTMonitoringReader() {};
+ virtual ~AliHLTMonitoringReader() {};
/* Read in the next available event */
virtual int ReadNextEvent() = 0;
virtual homer_uint64 GetBlockStatusFlags( unsigned long ndx ) const = 0;
#ifdef USE_ROOT
- ClassDef(MonitoringReader,1);
+ ClassDef(AliHLTMonitoringReader,1);
#endif
};
-class HOMERReader: public MonitoringReader
+class AliHLTHOMERReader: public AliHLTMonitoringReader
{
public:
#ifdef USE_ROOT
- HOMERReader();
+ AliHLTHOMERReader();
#endif
/* Constructors & destructors, HOMER specific */
/* For reading from a TCP port */
- HOMERReader( const char* hostname, unsigned short port );
+ AliHLTHOMERReader( const char* hostname, unsigned short port );
/* For reading from multiple TCP ports */
- HOMERReader( unsigned int tcpCnt, const char** hostnames, unsigned short* ports );
+ AliHLTHOMERReader( unsigned int tcpCnt, const char** hostnames, unsigned short* ports );
/* For reading from a System V shared memory segment */
- HOMERReader( key_t shmKey, int shmSize );
+ AliHLTHOMERReader( key_t shmKey, int shmSize );
/* For reading from multiple System V shared memory segments */
- HOMERReader( unsigned int shmCnt, key_t* shmKey, int* shmSize );
+ AliHLTHOMERReader( unsigned int shmCnt, key_t* shmKey, int* shmSize );
/* For reading from multiple TCP ports and multiple System V shared memory segments */
- HOMERReader( unsigned int tcpCnt, const char** hostnames, unsigned short* ports,
+ AliHLTHOMERReader( unsigned int tcpCnt, const char** hostnames, unsigned short* ports,
unsigned int shmCnt, key_t* shmKey, int* shmSize );
- virtual ~HOMERReader();
+ virtual ~AliHLTHOMERReader();
/* Return the status of the connection as established by one of the constructors.
0 means connection is ok, non-zero specifies the type of error that occured. */
fEventRequestAdvanceTime = time;
}
- /* Defined in MonitoringReader */
+ /* Defined in AliHLTMonitoringReader */
/* Read in the next available event */
virtual int ReadNextEvent();
/* Read in the next available event */
unsigned long fEventRequestAdvanceTime; //!transient
private:
/** copy constructor prohibited */
- HOMERReader(const HOMERReader&);
+ AliHLTHOMERReader(const AliHLTHOMERReader&);
/** assignment operator prohibited */
- HOMERReader& operator=(const HOMERReader&);
+ AliHLTHOMERReader& operator=(const AliHLTHOMERReader&);
#ifdef USE_ROOT
- ClassDef(HOMERReader,2);
+ ClassDef(AliHLTHOMERReader,2);
#endif
};
+/** defined for backward compatibility */
+typedef AliHLTMonitoringReader MonitoringReader;
+/** defined for backward compatibility */
+typedef AliHLTHOMERReader HOMERReader;
+
+// external interface of the HOMER reader
+#define ALIHLTHOMERREADER_CREATE_FROM_BUFFER "AliHLTHOMERReaderCreateFromBuffer"
+#define ALIHLTHOMERREADER_DELETE "AliHLTHOMERReaderDelete"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ typedef AliHLTHOMERReader* (*AliHLTHOMERReaderCreateFromBuffer_t)(const void* pBuffer, int size);
+ typedef void (*AliHLTHOMERReaderDelete_t)(AliHLTHOMERReader* pInstance);
+ /**
+ * Create instance of HOMER reader.
+ */
+ AliHLTHOMERReader* AliHLTHOMERReaderCreateFromBuffer();
+
+ /**
+ * Delete instance of HOMER reader.
+ */
+ void AliHLTHOMERReaderDelete(AliHLTHOMERReader* pInstance);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* AliHLTHOMERREADER_H */
#include <time.h>
-HOMERWriter::HOMERWriter()
+AliHLTHOMERWriter::AliHLTHOMERWriter()
:
fDataOffset(0),
fBlocks()
Clear();
}
-HOMERWriter::~HOMERWriter()
+AliHLTHOMERWriter::~AliHLTHOMERWriter()
{
// see header file for class documentation
}
-void HOMERWriter::Clear()
+void AliHLTHOMERWriter::Clear()
{
// see header file for class documentation
fDataOffset = 0;
fBlocks.clear();
}
-void HOMERWriter::AddBlock( const void* descriptor, const void* data )
+void AliHLTHOMERWriter::AddBlock( const void* descriptor, const void* data )
{
// see header file for class documentation
TBlockData bd;
fBlocks.push_back( bd );
}
-homer_uint32 HOMERWriter::GetTotalMemorySize( bool includeData )
+homer_uint32 AliHLTHOMERWriter::GetTotalMemorySize( bool includeData )
{
// see header file for class documentation
if ( includeData )
return HOMERBlockDescriptor::GetHOMERBlockDescriptorSize()*(fBlocks.size()+1);
}
-void HOMERWriter::Copy( void* destination, homer_uint64 eventType, homer_uint64 eventNr, homer_uint64 statusFlags, homer_uint64 nodeID, bool includeData )
+void AliHLTHOMERWriter::Copy( void* destination, homer_uint64 eventType, homer_uint64 eventNr, homer_uint64 statusFlags, homer_uint64 nodeID, bool includeData )
{
// see header file for class documentation
HOMERBlockDescriptor homerBlock;
gettimeofday( &now, NULL );
homerBlock.UseHeader( bd );
homerBlock.Initialize();
- homerBlock.SetUInt64Alignment( HOMERWriter::DetermineUInt64Alignment() );
- homerBlock.SetUInt32Alignment( HOMERWriter::DetermineUInt32Alignment() );
- homerBlock.SetUInt16Alignment( HOMERWriter::DetermineUInt16Alignment() );
- homerBlock.SetUInt8Alignment( HOMERWriter::DetermineUInt8Alignment() );
- homerBlock.SetDoubleAlignment( HOMERWriter::DetermineDoubleAlignment() );
- homerBlock.SetFloatAlignment( HOMERWriter::DetermineFloatAlignment() );
+ homerBlock.SetUInt64Alignment( AliHLTHOMERWriter::DetermineUInt64Alignment() );
+ homerBlock.SetUInt32Alignment( AliHLTHOMERWriter::DetermineUInt32Alignment() );
+ homerBlock.SetUInt16Alignment( AliHLTHOMERWriter::DetermineUInt16Alignment() );
+ homerBlock.SetUInt8Alignment( AliHLTHOMERWriter::DetermineUInt8Alignment() );
+ homerBlock.SetDoubleAlignment( AliHLTHOMERWriter::DetermineDoubleAlignment() );
+ homerBlock.SetFloatAlignment( AliHLTHOMERWriter::DetermineFloatAlignment() );
homerBlock.SetType( eventType );
homerBlock.SetSubType1( eventNr );
homerBlock.SetSubType2( fBlocks.size() );
}
}
-homer_uint8 HOMERWriter::DetermineUInt64Alignment()
+homer_uint8 AliHLTHOMERWriter::DetermineUInt64Alignment()
{
// see header file for class documentation
HOMERWriterAlignment64TestStructure test;
return 1;
}
-homer_uint8 HOMERWriter::DetermineUInt32Alignment()
+homer_uint8 AliHLTHOMERWriter::DetermineUInt32Alignment()
{
// see header file for class documentation
HOMERWriterAlignment32TestStructure test;
return 1;
}
-homer_uint8 HOMERWriter::DetermineUInt16Alignment()
+homer_uint8 AliHLTHOMERWriter::DetermineUInt16Alignment()
{
// see header file for class documentation
HOMERWriterAlignment16TestStructure test;
return 1;
}
-homer_uint8 HOMERWriter::DetermineUInt8Alignment()
+homer_uint8 AliHLTHOMERWriter::DetermineUInt8Alignment()
{
// see header file for class documentation
HOMERWriterAlignment8TestStructure test;
return 1;
}
-homer_uint8 HOMERWriter::DetermineDoubleAlignment()
+homer_uint8 AliHLTHOMERWriter::DetermineDoubleAlignment()
{
// see header file for class documentation
HOMERWriterAlignmentDoubleTestStructure test;
return 1;
}
-homer_uint8 HOMERWriter::DetermineFloatAlignment()
+homer_uint8 AliHLTHOMERWriter::DetermineFloatAlignment()
{
// see header file for class documentation
HOMERWriterAlignmentFloatTestStructure test;
return 1;
}
+AliHLTHOMERWriter* AliHLTHOMERWriterCreate()
+ {
+// see header file for function documentation
+ return new AliHLTHOMERWriter();
+ }
+
+void AliHLTHOMERWriterDelete(AliHLTHOMERWriter* pInstance)
+ {
+// see header file for function documentation
+ if (pInstance) delete pInstance;
+ }
/*