DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::oks::Comment Class Reference

The comment about file modification. A comment can be added when user saves file using OKS tools. More...

#include <file.hpp>

Public Member Functions

const std::string & get_created_by () const
const std::string & get_author () const
const std::string & get_created_on () const
const std::string & get_text () const
void validate (const std::string &creation_time)
void validate ()

Private Member Functions

 Comment () noexcept
 Comment (const std::string &text, const std::string &author)
 Comment (const oks::Comment &src) noexcept

Private Attributes

std::string p_created_by
std::string p_author
std::string p_created_on
std::string p_text

Friends

class OksFile

Detailed Description

The comment about file modification. A comment can be added when user saves file using OKS tools.

Definition at line 275 of file file.hpp.

Constructor & Destructor Documentation

◆ Comment() [1/3]

dunedaq::oks::Comment::Comment ( )
inlineprivatenoexcept

The constructor creates comment read from file. Only OksFile is allowed to create comments.

Definition at line 282 of file file.hpp.

282{ ; }

◆ Comment() [2/3]

dunedaq::oks::oks::Comment::Comment ( const std::string & text,
const std::string & author )
private

The constructor creates new comment from text. Only OksFile is allowed to create comments.

Exceptions
Throwstd::exception in case of problems.

Definition at line 656 of file file.cpp.

656 :
658 p_author (author),
660 p_text (text)
661{
662 validate();
663}
std::string p_created_by
Definition file.hpp:314
std::string p_created_on
Definition file.hpp:316
std::string p_text
Definition file.hpp:317
std::string p_author
Definition file.hpp:315
static std::string & get_host_name()
Get hostname of given process.
Definition kernel.cpp:434
static std::string & get_user_name()
Get username of given process.
Definition kernel.cpp:473

◆ Comment() [3/3]

dunedaq::oks::oks::Comment::Comment ( const oks::Comment & src)
privatenoexcept

The copy constructor. Only OksFile is allowed to create comments.

Definition at line 665 of file file.cpp.

665 :
666 p_created_by (src.p_created_by),
667 p_author (src.p_author),
668 p_created_on (src.p_created_on),
669 p_text (src.p_text)
670{
671}

Member Function Documentation

◆ get_author()

const std::string & dunedaq::oks::Comment::get_author ( ) const
inline

The name of author created comment (as defined from user input, e.g. first and last name, email address, etc.).

Definition at line 297 of file file.hpp.

297{ return p_author; }

◆ get_created_by()

const std::string & dunedaq::oks::Comment::get_created_by ( ) const
inline

The name of user created comment (as defined by process ID).

Definition at line 294 of file file.hpp.

294{ return p_created_by; }

◆ get_created_on()

const std::string & dunedaq::oks::Comment::get_created_on ( ) const
inline

The name of host where comment was created.

Definition at line 300 of file file.hpp.

300{ return p_created_on; }

◆ get_text()

const std::string & dunedaq::oks::Comment::get_text ( ) const
inline

The comment text.

Definition at line 303 of file file.hpp.

303{ return p_text; }

◆ validate() [1/2]

void dunedaq::oks::oks::Comment::validate ( )

Validate text of the comment.

Exceptions
Throwstd::exception if it is empty.

Definition at line 649 of file file.cpp.

650{
651 if(p_text.empty()) {
652 throw std::runtime_error("text is empty");
653 }
654}

◆ validate() [2/2]

void dunedaq::oks::oks::Comment::validate ( const std::string & creation_time)

Parse creation time-stamp and validate text.

Exceptions
Throwstd::exception in case of problems.

Definition at line 636 of file file.cpp.

637{
638 // YYYYMMDDThhmmss
639 if( creation_time.size() != 15 || creation_time[8] != 'T' ) {
640 std::ostringstream msg;
641 msg << "the creation time \'" << creation_time << "\' is not an ISO-8601 date-time";
642 throw std::runtime_error(msg.str().c_str());
643 }
644
645 validate();
646}

◆ OksFile

friend class OksFile
friend

Definition at line 277 of file file.hpp.

Member Data Documentation

◆ p_author

std::string dunedaq::oks::Comment::p_author
private

Definition at line 315 of file file.hpp.

◆ p_created_by

std::string dunedaq::oks::Comment::p_created_by
private

Definition at line 314 of file file.hpp.

◆ p_created_on

std::string dunedaq::oks::Comment::p_created_on
private

Definition at line 316 of file file.hpp.

◆ p_text

std::string dunedaq::oks::Comment::p_text
private

Definition at line 317 of file file.hpp.


The documentation for this class was generated from the following files: