Skip to content

Commit

Permalink
Merge pull request #167 from FRIBDAQ/rfoxkendo/issue165
Browse files Browse the repository at this point in the history
Issue #165 - port to unified format 2.x
  • Loading branch information
rfoxkendo authored Aug 30, 2024
2 parents 99b0d4c + 550d622 commit 851d630
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 106 deletions.
12 changes: 6 additions & 6 deletions main/Core/FRIBFilterFormatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ CFRIBFilterFormat::operator()(CEvent& event) {


size_t bodySize = sizeof(ParameterItem) + present.size()*(sizeof(ParameterValue));
v12::RingItemFactory fact;
ufmt::v12::RingItemFactory fact;

// Allocate the item with my usual chicken size:

std::unique_ptr<CRingItem> pItem(fact.makeRingItem(PARAMETER_DATA, bodySize + 100));
std::unique_ptr<ufmt::CRingItem> pItem(fact.makeRingItem(PARAMETER_DATA, bodySize + 100));

union cursor {
std::uint64_t* p64;
Expand Down Expand Up @@ -213,8 +213,8 @@ CFRIBFilterFormat::writeParameterDescriptions(
}
// Have the factory give me a ring item I'm chicken on the size.:

v12::RingItemFactory fact;
std::unique_ptr<CRingItem> pItem(fact.makeRingItem(PARAMETER_DEFINITIONS, bodySize + 100));
ufmt::v12::RingItemFactory fact;
std::unique_ptr<ufmt::CRingItem> pItem(fact.makeRingItem(PARAMETER_DEFINITIONS, bodySize + 100));

// Get my body cursor and have at it:

Expand Down Expand Up @@ -267,8 +267,8 @@ CFRIBFilterFormat::writeVariableDefs() {
// Allocate the ring item and fill inthe body:
// I'm chicken on my size computation:

v12::RingItemFactory fact;
std::unique_ptr<CRingItem> pItem(fact.makeRingItem(VARIABLE_VALUES, bodySize + 100));
ufmt::v12::RingItemFactory fact;
std::unique_ptr<ufmt::CRingItem> pItem(fact.makeRingItem(VARIABLE_VALUES, bodySize + 100));

union cursor {
std::uint32_t* p32;
Expand Down
50 changes: 25 additions & 25 deletions main/Core/RingFormatHelper10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* need to delete it on destruction.
*/
CRingFormatHelper10::CRingFormatHelper10() :
m_Factory(FormatSelector::selectFactory(FormatSelector::v10))
m_Factory(ufmt::FormatSelector::selectFactory(::ufmt::FormatSelector::v10))
{}

/**
Expand Down Expand Up @@ -65,7 +65,7 @@ CRingFormatHelper10::hasBodyHeader(void* pItem) const
void*
CRingFormatHelper10::getBodyPointer(void* pItem)
{
v10::pRingItem pI = reinterpret_cast<v10::pRingItem>(pItem);
ufmt::v10::pRingItem pI = reinterpret_cast<ufmt::v10::pRingItem>(pItem);
return pI->s_body;

}
Expand Down Expand Up @@ -111,10 +111,10 @@ CRingFormatHelper10::getBodyHeaderPointer(void* pItem)
std::string
CRingFormatHelper10::getTitle(void* pItem)
{
const ::RingItem* pRaw = reinterpret_cast<const ::RingItem*>(pItem);
std::unique_ptr<::CRingItem> pBase(m_Factory.makeRingItem(pRaw));
const ufmt::RingItem* pRaw = reinterpret_cast<const ufmt::RingItem*>(pItem);
std::unique_ptr<ufmt::CRingItem> pBase(m_Factory.makeRingItem(pRaw));
try {
std::unique_ptr<::CRingStateChangeItem> pStateChange(
std::unique_ptr<ufmt::CRingStateChangeItem> pStateChange(
m_Factory.makeStateChangeItem(*pBase)); // Throws if bad type.
return pStateChange->getTitle();
}
Expand All @@ -138,10 +138,10 @@ CRingFormatHelper10::getTitle(void* pItem)
unsigned
CRingFormatHelper10::getRunNumber(void* pItem, BufferTranslator* pTranslator)
{
const ::RingItem* pRaw = reinterpret_cast<const ::RingItem*>(pItem);
std::unique_ptr<::CRingItem> pBase(m_Factory.makeRingItem(pRaw));
const ufmt::RingItem* pRaw = reinterpret_cast<const ufmt::RingItem*>(pItem);
std::unique_ptr<ufmt::CRingItem> pBase(m_Factory.makeRingItem(pRaw));
try {
std::unique_ptr<::CRingStateChangeItem> pStateChange(
std::unique_ptr<ufmt::CRingStateChangeItem> pStateChange(
m_Factory.makeStateChangeItem(*pBase)); // Throws if bad type.
return pStateChange->getRunNumber();
}
Expand Down Expand Up @@ -181,10 +181,10 @@ CRingFormatHelper10::getStringCount(void* pItem, BufferTranslator* pTranslator)
std::vector<std::string>
CRingFormatHelper10::getStrings(void* pItem, BufferTranslator* pTranslator)
{
const ::RingItem* pRaw = reinterpret_cast<const ::RingItem*>(pItem);
std::unique_ptr<::CRingItem> pBase(m_Factory.makeRingItem(pRaw));
const ufmt::RingItem* pRaw = reinterpret_cast<const ufmt::RingItem*>(pItem);
std::unique_ptr<ufmt::CRingItem> pBase(m_Factory.makeRingItem(pRaw));
try {
std::unique_ptr<::CRingTextItem> p(m_Factory.makeTextItem(*pBase));
std::unique_ptr<ufmt::CRingTextItem> p(m_Factory.makeTextItem(*pBase));
return p->getStrings();
}
catch (...) {
Expand Down Expand Up @@ -221,10 +221,10 @@ CRingFormatHelper10::getScalerCount(void* pItem, BufferTranslator* pTranslator)
std::vector<uint32_t>
CRingFormatHelper10::getScalers(void* pItem, BufferTranslator* pTranslator)
{
const ::RingItem* pRaw = reinterpret_cast<const ::RingItem*>(pItem);
std::unique_ptr<::CRingItem> pBase(m_Factory.makeRingItem(pRaw));
const ufmt::RingItem* pRaw = reinterpret_cast<const ufmt::RingItem*>(pItem);
std::unique_ptr<ufmt::CRingItem> pBase(m_Factory.makeRingItem(pRaw));
try {
std::unique_ptr<::CRingScalerItem> p(m_Factory.makeScalerItem(*pBase));
std::unique_ptr<ufmt::CRingScalerItem> p(m_Factory.makeScalerItem(*pBase));
return p->getScalers();
}
catch (...) {
Expand Down Expand Up @@ -261,10 +261,10 @@ CRingFormatHelper10::getScalerOriginalSourceId(void* pItem, BufferTranslator* pT
uint64_t
CRingFormatHelper10::getTriggerCount(void* pItem, BufferTranslator* pTranslator)
{
const ::RingItem* pRaw = reinterpret_cast<const ::RingItem*>(pItem);
std::unique_ptr<::CRingItem> pBase(m_Factory.makeRingItem(pRaw));
const ufmt::RingItem* pRaw = reinterpret_cast<const ufmt::RingItem*>(pItem);
std::unique_ptr<ufmt::CRingItem> pBase(m_Factory.makeRingItem(pRaw));
try {
std::unique_ptr<::CRingPhysicsEventCountItem> p( // Will check
std::unique_ptr<ufmt::CRingPhysicsEventCountItem> p( // Will check
m_Factory.makePhysicsEventCountItem(*pBase) // correct type.
);
return p->getEventCount();
Expand Down Expand Up @@ -294,10 +294,10 @@ CRingFormatHelper10::isStateTransition(void* pItem)
uint16_t type = itemType(pItem);

return (
(type == v10::BEGIN_RUN)
|| (type == v10::END_RUN)
|| (type == v10::PAUSE_RUN)
|| (type == v10::RESUME_RUN)
(type == ufmt::v10::BEGIN_RUN)
|| (type == ufmt::v10::END_RUN)
|| (type == ufmt::v10::PAUSE_RUN)
|| (type == ufmt::v10::RESUME_RUN)
);
}
/**
Expand All @@ -312,8 +312,8 @@ CRingFormatHelper10::isTextItem(void* pItem)
uint16_t type = itemType(pItem);

return (
(type == v10::PACKET_TYPES)
|| (type == v10::MONITORED_VARIABLES)
(type == ufmt::v10::PACKET_TYPES)
|| (type == ufmt::v10::MONITORED_VARIABLES)
);
}
/**
Expand All @@ -330,7 +330,7 @@ CRingFormatHelper10::isScalerItem(void* pItem)
{
uint16_t type = itemType(pItem);

return type == v10::INCREMENTAL_SCALERS;
return type == ufmt::v10::INCREMENTAL_SCALERS;
}
/**
* isTriggerItem
Expand All @@ -341,5 +341,5 @@ CRingFormatHelper10::isScalerItem(void* pItem)
*/
bool CRingFormatHelper10::isTriggerItem(void* pItem)
{
return itemType(pItem) == v10::PHYSICS_EVENT_COUNT;
return itemType(pItem) == ufmt::v10::PHYSICS_EVENT_COUNT;
}
7 changes: 5 additions & 2 deletions main/Core/RingFormatHelper10.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
*/

#include "RingFormatHelper.h"
class RingItemFactoryBase;

namespace ufmt {
class RingItemFactoryBase;
}


/**
Expand All @@ -34,7 +37,7 @@ class RingItemFactoryBase;
*/
class CRingFormatHelper10 : public CRingFormatHelper
{
RingItemFactoryBase& m_Factory;
ufmt::RingItemFactoryBase& m_Factory;

public:
CRingFormatHelper10();
Expand Down
76 changes: 38 additions & 38 deletions main/Core/RingFormatHelper11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
CRingFormatHelper11::CRingFormatHelper11():
m_glomSourceId(0), m_nLastEventCount(0),
m_Factory(&FormatSelector::selectFactory(FormatSelector::v11))
m_Factory(&ufmt::FormatSelector::selectFactory(ufmt::FormatSelector::v11))
{}

/**
Expand All @@ -58,8 +58,8 @@ CRingFormatHelper11::CRingFormatHelper11():
bool
CRingFormatHelper11::hasBodyHeader(void* pItem) const
{
const ::RingItem* p = reinterpret_cast<const ::RingItem*>(pItem);
std::unique_ptr<::CRingItem> pBase(m_Factory->makeRingItem(p));
const ::ufmt::RingItem* p = reinterpret_cast<const ::ufmt::RingItem*>(pItem);
std::unique_ptr<::ufmt::CRingItem> pBase(m_Factory->makeRingItem(p));
return pBase->hasBodyHeader();

}
Expand All @@ -78,14 +78,14 @@ CRingFormatHelper11::CRingFormatHelper11():
void*
CRingFormatHelper11::getBodyPointer(void* pItem)
{
pRingItem p = reinterpret_cast<pRingItem>(pItem);
ufmt::pRingItem p = reinterpret_cast<ufmt::pRingItem>(pItem);

if (hasBodyHeader(pItem)) {
// If there's a body header, and this is a physics event item,
// save the source id so we know which sid to use for
// event counting.

if (p->s_header.s_type == PHYSICS_EVENT) m_glomSourceId =
if (p->s_header.s_type == ufmt::PHYSICS_EVENT) m_glomSourceId =
p->s_body.u_hasBodyHeader.s_bodyHeader.s_sourceId;

// The code below will work if the body header has been extended
Expand All @@ -98,7 +98,7 @@ CRingFormatHelper11::CRingFormatHelper11():
return reinterpret_cast<void*>(b);

} else {
if (p->s_header.s_type == PHYSICS_EVENT) m_glomSourceId = 0; // don't know.
if (p->s_header.s_type == ufmt::PHYSICS_EVENT) m_glomSourceId = 0; // don't know.
return reinterpret_cast<void*>(p->s_body.u_noBodyHeader.s_body);
}
}
Expand All @@ -116,7 +116,7 @@ CRingFormatHelper11::CRingFormatHelper11():
void*
CRingFormatHelper11::getBodyHeaderPointer(void* pItem)
{
pRingItem p = reinterpret_cast<pRingItem>(pItem);
ufmt::pRingItem p = reinterpret_cast<ufmt::pRingItem>(pItem);

if (hasBodyHeader(pItem)) {
return reinterpret_cast<void*>(&(p->s_body.u_hasBodyHeader.s_bodyHeader));
Expand All @@ -137,8 +137,8 @@ CRingFormatHelper11::getSourceId(void* pItem, BufferTranslator* pTranslator)

uint32_t result = 0;
if (hasBodyHeader(pItem)) {
const ::RingItem* pRaw = reinterpret_cast<const ::RingItem*>(pItem);
std::unique_ptr<::CRingItem> pBase(m_Factory->makeRingItem(pRaw));
const ::ufmt::RingItem* pRaw = reinterpret_cast<const ::ufmt::RingItem*>(pItem);
std::unique_ptr<::ufmt::CRingItem> pBase(m_Factory->makeRingItem(pRaw));
result = pBase->getSourceId();

}
Expand All @@ -162,10 +162,10 @@ CRingFormatHelper11::getSourceId(void* pItem, BufferTranslator* pTranslator)
std::string
CRingFormatHelper11::getTitle(void* pItem)
{
const ::RingItem* pRaw = reinterpret_cast<const ::RingItem*>(pItem);
std::unique_ptr<::CRingItem> pBase(m_Factory->makeRingItem(pRaw));
const ::ufmt::RingItem* pRaw = reinterpret_cast<const ::ufmt::RingItem*>(pItem);
std::unique_ptr<::ufmt::CRingItem> pBase(m_Factory->makeRingItem(pRaw));
try {
std::unique_ptr<::CRingStateChangeItem> pActual(
std::unique_ptr<::ufmt::CRingStateChangeItem> pActual(
m_Factory->makeStateChangeItem(*pBase)
);
return pActual->getTitle();
Expand All @@ -189,10 +189,10 @@ CRingFormatHelper11::getTitle(void* pItem)
unsigned
CRingFormatHelper11::getRunNumber(void* pItem, BufferTranslator* pTranslator)
{
const ::RingItem* pRaw = reinterpret_cast<const ::RingItem*>(pItem);
std::unique_ptr<::CRingItem> pBase(m_Factory->makeRingItem(pRaw));
const ::ufmt::RingItem* pRaw = reinterpret_cast<const ::ufmt::RingItem*>(pItem);
std::unique_ptr<::ufmt::CRingItem> pBase(m_Factory->makeRingItem(pRaw));
try {
std::unique_ptr<::CRingStateChangeItem> pActual(
std::unique_ptr<::ufmt::CRingStateChangeItem> pActual(
m_Factory->makeStateChangeItem(*pBase)
);
return pActual->getRunNumber();
Expand Down Expand Up @@ -230,10 +230,10 @@ CRingFormatHelper11::getStringCount(void* pItem, BufferTranslator* pTranslator)
std::vector<std::string>
CRingFormatHelper11::getStrings(void* pItem, BufferTranslator* pTranslator)
{
const ::RingItem* pRaw = reinterpret_cast<const ::RingItem*>(pItem);
std::unique_ptr<::CRingItem> pBase(m_Factory->makeRingItem(pRaw));
const ::ufmt::RingItem* pRaw = reinterpret_cast<const ::ufmt::RingItem*>(pItem);
std::unique_ptr<::ufmt::CRingItem> pBase(m_Factory->makeRingItem(pRaw));
try {
std::unique_ptr<::CRingTextItem> p(m_Factory->makeTextItem(*pBase));
std::unique_ptr<::ufmt::CRingTextItem> p(m_Factory->makeTextItem(*pBase));
return p->getStrings();
}
catch (...) {
Expand All @@ -257,10 +257,10 @@ CRingFormatHelper11::getStrings(void* pItem, BufferTranslator* pTranslator)
unsigned
CRingFormatHelper11::getScalerCount(void* pItem, BufferTranslator* pTranslator)
{
const ::RingItem* pRaw = reinterpret_cast<const ::RingItem*>(pItem);
std::unique_ptr<::CRingItem> pBase(m_Factory->makeRingItem(pRaw));
const ::ufmt::RingItem* pRaw = reinterpret_cast<const ::ufmt::RingItem*>(pItem);
std::unique_ptr<::ufmt::CRingItem> pBase(m_Factory->makeRingItem(pRaw));
try {
std::unique_ptr<CRingScalerItem> pActual(
std::unique_ptr<ufmt::CRingScalerItem> pActual(
m_Factory->makeScalerItem(*pBase)
);
return pActual->getScalerCount();
Expand All @@ -286,10 +286,10 @@ std::vector<uint32_t> CRingFormatHelper11::getScalers(
void* pItem, BufferTranslator* pTranslator
)
{
const ::RingItem* pRaw = reinterpret_cast<const ::RingItem*>(pItem);
std::unique_ptr<::CRingItem> pBase(m_Factory->makeRingItem(pRaw));
const ::ufmt::RingItem* pRaw = reinterpret_cast<const ::ufmt::RingItem*>(pItem);
std::unique_ptr<::ufmt::CRingItem> pBase(m_Factory->makeRingItem(pRaw));
try {
std::unique_ptr<CRingScalerItem> pActual(
std::unique_ptr<ufmt::CRingScalerItem> pActual(
m_Factory->makeScalerItem(*pBase)
);
return pActual->getScalers();
Expand All @@ -312,10 +312,10 @@ std::vector<uint32_t> CRingFormatHelper11::getScalers(
uint32_t
CRingFormatHelper11::getScalerOriginalSourceId(void* pItem, BufferTranslator* pTranslator)
{
const ::RingItem* pRaw = reinterpret_cast<const ::RingItem*>(pItem);
std::unique_ptr<::CRingItem> pBase(m_Factory->makeRingItem(pRaw));
const ::ufmt::RingItem* pRaw = reinterpret_cast<const ::ufmt::RingItem*>(pItem);
std::unique_ptr<::ufmt::CRingItem> pBase(m_Factory->makeRingItem(pRaw));
try {
std::unique_ptr<CRingScalerItem> pActual(
std::unique_ptr<::ufmt::CRingScalerItem> pActual(
m_Factory->makeScalerItem(*pBase)
);
return pActual->getOriginalSourceId();
Expand Down Expand Up @@ -345,11 +345,11 @@ CRingFormatHelper11::getScalerOriginalSourceId(void* pItem, BufferTranslator* pT
uint64_t
CRingFormatHelper11::getTriggerCount(void* pItem, BufferTranslator* pTranslator)
{
std::unique_ptr<::CRingItem> pBase(
m_Factory->makeRingItem(reinterpret_cast<const ::RingItem*>(pItem))
std::unique_ptr<::ufmt::CRingItem> pBase(
m_Factory->makeRingItem(reinterpret_cast<const ::ufmt::RingItem*>(pItem))
);
try {
std::unique_ptr<CRingPhysicsEventCountItem> p(
std::unique_ptr<ufmt::CRingPhysicsEventCountItem> p(
m_Factory->makePhysicsEventCountItem(*pBase)
);
return p->getEventCount();
Expand All @@ -375,10 +375,10 @@ CRingFormatHelper11::isStateTransition(void* pItem)
uint16_t type = itemType(pItem);

return (
(type == BEGIN_RUN)
|| (type == END_RUN)
|| (type == PAUSE_RUN)
|| (type == RESUME_RUN)
(type == ufmt::BEGIN_RUN)
|| (type == ufmt::END_RUN)
|| (type == ufmt::PAUSE_RUN)
|| (type == ufmt::RESUME_RUN)
);
}
/**
Expand All @@ -393,8 +393,8 @@ CRingFormatHelper11::isTextItem(void* pItem)
uint16_t type = itemType(pItem);

return (
(type == PACKET_TYPES)
|| (type == MONITORED_VARIABLES)
(type == ::ufmt::PACKET_TYPES)
|| (type == ::ufmt::MONITORED_VARIABLES)
);
}
/**
Expand All @@ -406,7 +406,7 @@ CRingFormatHelper11::isTextItem(void* pItem)
bool
CRingFormatHelper11::isScalerItem(void* pItem)
{
return itemType(pItem) == PERIODIC_SCALERS;
return itemType(pItem) == ::ufmt::PERIODIC_SCALERS;
}
/**
* isTriggerItem
Expand All @@ -417,5 +417,5 @@ CRingFormatHelper11::isScalerItem(void* pItem)
bool
CRingFormatHelper11::isTriggerCountItem(void* pItem)
{
return itemType(pItem) == PHYSICS_EVENT_COUNT;
return itemType(pItem) == ::ufmt::PHYSICS_EVENT_COUNT;
}
Loading

0 comments on commit 851d630

Please sign in to comment.