Skip to content

Commit

Permalink
Fixing linux build
Browse files Browse the repository at this point in the history
Signed-off-by: Max <mcschrader@crimson.ua.edu>
  • Loading branch information
mschrader15 committed Aug 7, 2024
1 parent e2f973e commit f444857
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
#cmakedefine HAVE_GDAL

/* defined if PARQUET is available */
#cmakedefine HAVE_PARQUET
# cmakedefine HAVE_PARQUET

/* defined if GL2PS is available */
#cmakedefine HAVE_GL2PS
Expand Down
30 changes: 7 additions & 23 deletions src/utils/common/MsgRetrievingFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,35 +50,23 @@ class MsgRetrievingFunction : public OutputDevice {
MsgRetrievingFunction(T* object, Operation operation, MsgHandler::MsgType type) :
myObject(object),
myOperation(operation),
myMsgType(type) {}
myMsgType(type) {
/// @todo We should design a new formatter type for this.
myFormatter = new PlainXMLFormatter();
myStreamDevice = new OStreamDevice(new std::ostringstream());
}


/// @brief Destructor
~MsgRetrievingFunction() {}


protected:
/// @name Methods that override/implement OutputDevice-methods
/// @{

/** @brief Returns the associated ostream
*
* The stream is an ostringstream, actually, into which the message
* is written. It is sent when postWriteHook is called.
*
* @return The used stream
* @see postWriteHook
*/
std::ostream& getOStream() {
return myMessage;
}


/** @brief Sends the data which was written to the string stream via the retrieving function.
*/
virtual void postWriteHook() {
(myObject->*myOperation)(myMsgType, myMessage.str());
myMessage.str("");
(myObject->*myOperation)(myMsgType, getOStream().str());
getOStream().str("");
}
/// @}

Expand All @@ -92,8 +80,4 @@ class MsgRetrievingFunction : public OutputDevice {

/// @brief The type of message to retrieve.
MsgHandler::MsgType myMsgType;

/// @brief message buffer
std::ostringstream myMessage;

};
17 changes: 7 additions & 10 deletions src/utils/gui/div/GUIMessageWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,29 +124,26 @@ class GUIMessageWindow : public FXText {
/// @brief constructor
MsgOutputDevice(GUIMessageWindow* msgWindow, GUIEventType type) :
myMsgWindow(msgWindow),
myType(type) { }
myType(type){
/// @todo We should design a new formatter type for this.
myFormatter = new PlainXMLFormatter();
myStreamDevice = new OStreamDevice(new std::ostringstream());
}

/// @brief destructor
~MsgOutputDevice() { }

protected:
/// @brief get Output Stream
std::ostream& getOStream() {
return myStream;
}
/// @brief write hook
void postWriteHook() {
myMsgWindow->appendMsg(myType, myStream.str());
myStream.str("");
myMsgWindow->appendMsg(myType, getOStream().str());
getOStream().str("");
}

private:
/// @brief pointer to message Windows
GUIMessageWindow* myMsgWindow;

/// @brief output string stream
std::ostringstream myStream;

/// @brief type of event
GUIEventType myType;
};
Expand Down
8 changes: 3 additions & 5 deletions src/utils/iodevices/OutputDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,17 +436,15 @@ class OutputDevice {
/// @brief the stream device
StreamDevice* myStreamDevice;

/// @brief The formatter for XML
OutputFormatter* myFormatter;

/// @brief return a type casted formatter
template <typename T>
T* getFormatter() {
return static_cast<T*>(myFormatter);
}


private:
/// @brief The formatter for XML
OutputFormatter* const myFormatter;

private:
/// @brief Invalidated copy constructor.
OutputDevice(const OutputDevice&) = delete;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/iodevices/OutputFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,5 @@ class OutputFormatter {
void writeRaw(StreamDevice& into, const T& val){

into << val;
};
}
};
1 change: 0 additions & 1 deletion src/utils/iodevices/PlainXMLFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ class PlainXMLFormatter : public OutputFormatter {
into << " " << attr << "=\"" << toString(val, into.precision()) << "\"";
}

template<>
void writeAttr(StreamDevice& into, const std::string& attr, const double& val){
#ifdef HAVE_FMT
fmt::print(into, " {}=\"{:.{}f}\"", attr, val, into.precision());
Expand Down
26 changes: 17 additions & 9 deletions src/utils/iodevices/StreamDevices.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#pragma once
#include <config.h>
#include <fstream>

#include <memory>
#include <string>

#ifdef HAVE_PARQUET
Expand All @@ -24,7 +24,7 @@ class StreamDevice {
};

// create a constructor that a type and raw write access
StreamDevice(Type type, bool access) : myType(type), rawWriteAccess(access) {};
StreamDevice(Type type, bool access) : rawWriteAccess(access), myType(type) {};
// create a default constructor
StreamDevice() = default;

Expand Down Expand Up @@ -63,7 +63,7 @@ class StreamDevice {

/// @brief write a string to the stream
/// @param s the string to write
virtual void str(const std::string& s) {};
virtual void str(const std::string& s) = 0;

/// @brief write an endline to the stream
/// @return this
Expand Down Expand Up @@ -95,11 +95,11 @@ class OStreamDevice : public StreamDevice {
public:

// write a constructor that takes a std::ofstream
OStreamDevice(std::ofstream* stream) : myStream(std::move(stream)), StreamDevice(Type::OSTREAM, true) {};
OStreamDevice(std::ostream* stream) : myStream(std::move(stream)), StreamDevice(Type::OSTREAM, true) {};
OStreamDevice(std::ofstream stream) : myStream(new std::ofstream(std::move(stream))), StreamDevice(Type::OSTREAM, true) {};
OStreamDevice(std::ofstream* stream) : StreamDevice(Type::OSTREAM, true), myStream(std::move(stream)) {}
OStreamDevice(std::ostream* stream) : StreamDevice(Type::OSTREAM, true), myStream(std::move(stream)) {}
OStreamDevice(std::ofstream stream) : StreamDevice(Type::OSTREAM, true), myStream(new std::ofstream(std::move(stream))) {}

virtual ~OStreamDevice() = default;
virtual ~OStreamDevice() override = default;

bool ok() override {
return myStream->good();
Expand Down Expand Up @@ -140,6 +140,10 @@ class OStreamDevice : public StreamDevice {
return "";
}

void str(const std::string& s) override {
(*myStream) << s;
}

operator std::ostream& () override {
return *myStream;
}
Expand All @@ -155,8 +159,8 @@ class OStreamDevice : public StreamDevice {
}

private:
const std::unique_ptr<std::ostream> myStream;
};
std::unique_ptr<std::ostream> myStream;
}; // Add the missing semicolon here

class ParquetStream : public StreamDevice {

Expand Down Expand Up @@ -195,6 +199,10 @@ class ParquetStream : public StreamDevice {
return "";
}

void str([[maybe_unused]] const std::string& s) override {

};

template <typename T>
void print(const T& t) {
(*myStream) << t;
Expand Down

0 comments on commit f444857

Please sign in to comment.