code cleanup; fix move ctors and assignment

This commit is contained in:
Günter Obiltschnig
2020-01-21 17:52:43 +01:00
parent de52e23d12
commit 18adb1e43b
20 changed files with 327 additions and 188 deletions

View File

@@ -54,109 +54,109 @@ public:
PRIO_DEBUG, /// A debugging message.
PRIO_TRACE /// A tracing message. This is the lowest priority.
};
Message();
/// Creates an empty Message.
/// The thread and process ids are set.
Message(const std::string& source, const std::string& text, Priority prio);
/// Creates a Message with the given source, text and priority.
/// The thread and process ids are set.
Message(const std::string& source, const std::string& text, Priority prio, const char* file, int line);
/// Creates a Message with the given source, text, priority,
/// source file path and line.
/// source file path and line.
///
/// The source file path must be a
/// The source file path must be a
/// static string with a lifetime that's at least the lifetime
/// of the message object (the string is not copied internally).
/// Usually, this will be the path string obtained from the
/// Usually, this will be the path string obtained from the
/// __FILE__ macro.
///
/// The thread and process ids are set.
Message(const Message& msg);
/// Creates a Message by copying another one.
Message(Message&& msg);
Message(Message&& msg) noexcept;
/// Creates a Message by copying another one.
Message(const Message& msg, const std::string& text);
/// Creates a Message by copying all but the text from another message.
~Message();
/// Destroys the Message.
Message& operator = (const Message& msg);
/// Assignment operator.
Message& operator = (Message&& msg);
Message& operator = (Message&& msg) noexcept;
/// Assignment operator.
void swap(Message& msg);
/// Swaps the message with another one.
/// Swaps the message with another one.
void setSource(const std::string& src);
/// Sets the source of the message.
const std::string& getSource() const;
/// Returns the source of the message.
void setText(const std::string& text);
/// Sets the text of the message.
const std::string& getText() const;
/// Returns the text of the message.
void setPriority(Priority prio);
/// Sets the priority of the message.
Priority getPriority() const;
/// Returns the priority of the message.
void setTime(const Timestamp& time);
/// Sets the time of the message.
const Timestamp& getTime() const;
/// Returns the time of the message.
void setThread(const std::string& thread);
/// Sets the thread identifier for the message.
const std::string& getThread() const;
/// Returns the thread identifier for the message.
void setTid(long pid);
/// Sets the numeric thread identifier for the message.
long getTid() const;
/// Returns the numeric thread identifier for the message.
void setPid(long pid);
/// Sets the process identifier for the message.
long getPid() const;
/// Returns the process identifier for the message.
void setSourceFile(const char* file);
/// Sets the source file path of the statement
/// generating the log message.
///
/// File must be a static string, such as the value of
/// the __FILE__ macro. The string is not copied
/// internally for performance reasons.
/// internally for performance reasons.
const char* getSourceFile() const;
/// Returns the source file path of the code creating
/// the message. May be 0 if not set.
void setSourceLine(int line);
/// Sets the source file line of the statement
/// generating the log message.
///
/// This is usually the result of the __LINE__
/// macro.
int getSourceLine() const;
/// Returns the source file line of the statement
/// generating the log message. May be 0
@@ -183,7 +183,7 @@ public:
/// Returns a const reference to the value of the parameter
/// with the given name. Throws a NotFoundException if the
/// parameter does not exist.
std::string& operator [] (const std::string& param);
/// Returns a reference to the value of the parameter with the
/// given name. This can be used to set the parameter's value.
@@ -194,7 +194,7 @@ protected:
void init();
typedef std::map<std::string, std::string> StringMap;
private:
private:
std::string _source;
std::string _text;
Priority _prio;