Skip to content

Commit

Permalink
KSWriteASCII: Fix headers, add type prefixes before lines
Browse files Browse the repository at this point in the history
Before, the single header row contained a list of all outputs, mixing e.g. track and step outputs.
With this commit, there are multiple header rows, splitting the header up into step, track etc. output.
To use the header meaningfully, the further lines are also prepended by "track", "step" etc. indicating
their type.
Also, since outputs have been observed to change order at random (which still has to be understood and
if possible avoided), this commit uses fActive*Component to list the actually used components in their
correct order.
  • Loading branch information
2xB committed Dec 11, 2024
1 parent 2ccfce5 commit 06a85ec
Show file tree
Hide file tree
Showing 2 changed files with 168 additions and 208 deletions.
24 changes: 19 additions & 5 deletions Kassiopeia/Writers/Include/KSWriteASCII.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ class KSWriteASCII : public KSComponentTemplate<KSWriteASCII, KSWriter>
class Data
{
public:
Data(KSComponent* aComponent, KSWriteASCII* aWriter);
Data(KSComponent* aComponent, int aPrecision);
~Data();

void Initialize(KSComponent* aComponent, int aPrecision);
void Start(const unsigned int& anIndex);
std::string ValuesAsString();
void MakeTitle(KSComponent* aComponent, int aTrack);
std::string Label();


private:
std::string fLabel;
std::string fType;
KSWriteASCII* fWriter;
unsigned int fIndex;
unsigned int fLength;

Expand Down Expand Up @@ -67,10 +67,11 @@ class KSWriteASCII : public KSComponentTemplate<KSWriteASCII, KSWriter>

katrin::KTextFile* TextFile();
void Write(std::string str);
void Write(char c);
int Precision() const;

protected:
katrin::KTextFile* MakeOutputFile(int anIndex) const;
void MakeOutputFile(int anIndex);

private:
std::string fBase;
Expand Down Expand Up @@ -163,19 +164,32 @@ inline void KSWriteASCII::SetPrecision(const unsigned int& aValue)

inline katrin::KTextFile* KSWriteASCII::TextFile()
{
if (!fTextFile)
MakeOutputFile(fTrackIndex);

return fTextFile;
}

inline void KSWriteASCII::Write(std::string str)
{
for (char& it : str)
fTextFile->File()->put(it);
TextFile()->File()->put(it);
}

inline void KSWriteASCII::Write(char c)
{
TextFile()->File()->put(c);
}

inline int KSWriteASCII::Precision() const
{
return fPrecision;
}

inline std::string KSWriteASCII::Data::Label()
{
return fLabel;
}

} // namespace Kassiopeia

Expand Down
Loading

0 comments on commit 06a85ec

Please sign in to comment.