Skip to content

Implementation of common TRestRawToSignalProcesss::FRead #108

@jgalan

Description

@jgalan

We could perhaps simplify the code of external to raw signal processes if we introduce a template method inside TRestRawToSignalProcess::FRead.

Each time we read, it is required to increase the variable totalBytesRead. This could also be encapsulated in the base class. And probably totalBytesReaded could be made private.

For example:

    char buffer[CTAG_SZ];
    if (fread(buffer, sizeof(char), CTAG_SZ, fInputBinFile) != CTAG_SZ) {
        printf("Error: could not read first ACQ prefix.\n");
        exit(1);
    }
    totalBytesReaded += CTAG_SZ * sizeof(char);

could be replaced by:

char buffer[CTAG_SZ];
FRead( buffer, sizeof(char), CTAG_SZ);

For example:

    if (fread(&tmp, sizeof(int32_t), 1, fInputBinFile) != 1) {
        printf("Error: could not read timestamp.\n");
        exit(1);
    }
    totalBytesReaded += sizeof(int32_t);

could be replaced by:

int32_t tmp;
FRead( tmp, sizeof(int32_t), 1);

or even

int32_t tmp;
FReadOne( tmp, sizeof(int32_t));

or

tmp = FRead<int32_t>();

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions