Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KSWriteASCII: Fix header & improve output #125

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 31 additions & 10 deletions Kassiopeia/Writers/Include/KSWriteASCII.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,36 @@ class KSWriteASCII : public KSComponentTemplate<KSWriteASCII, KSWriter>
class Data
{
public:
Data(KSComponent* aComponent);
Data(KSComponent* aComponent, KSWriteASCII* aWriter);
Data(KSComponent* aComponent, int aPrecision);
~Data();

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


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

class Objekt
class OutputObjectASCII
{
private:
KSComponent* fComponent;
std::string fType;
int fPrecision;

public:
Objekt(KSComponent* aComponent, std::string aType, int Precision);
~Objekt();
OutputObjectASCII(KSComponent* aComponent, std::string aType, int Precision);
~OutputObjectASCII();
std::string getValue();
};

std::vector<KSComponent*> fComponents;
std::vector<Objekt*> fObjekts;
std::vector<OutputObjectASCII*> fOutputObjectASCIIs;
};

using KSComponentMap = std::map<KSComponent*, Data*>;
Expand All @@ -66,10 +66,12 @@ class KSWriteASCII : public KSComponentTemplate<KSWriteASCII, KSWriter>
void SetPrecision(const unsigned int& aValue);

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 @@ -162,13 +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)
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
Loading