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 293 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 300 of file file.hpp.

300{ ; }

◆ 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 669 of file file.cpp.

671 , p_author(author)
673 , p_text(text)
674{
675 validate();
676}
std::string p_created_by
Definition file.hpp:329
std::string p_created_on
Definition file.hpp:331
std::string p_text
Definition file.hpp:332
std::string p_author
Definition file.hpp:330
void validate(const std::string &creation_time)
Definition file.cpp:649
static std::string & get_host_name()
Get hostname of given process.
Definition kernel.cpp:392
static std::string & get_user_name()
Get username of given process.
Definition kernel.cpp:427

◆ 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 678 of file file.cpp.

679 : p_created_by(src.p_created_by)
680 , p_author(src.p_author)
681 , p_created_on(src.p_created_on)
682 , p_text(src.p_text)
683{
684}

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 314 of file file.hpp.

314{ 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 311 of file file.hpp.

311{ 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 317 of file file.hpp.

317{ return p_created_on; }

◆ get_text()

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

The comment text.

Definition at line 320 of file file.hpp.

320{ 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 662 of file file.cpp.

663{
664 if (p_text.empty()) {
665 throw std::runtime_error("text is empty");
666 }
667}

◆ 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 649 of file file.cpp.

650{
651 // YYYYMMDDThhmmss
652 if (creation_time.size() != 15 || creation_time[8] != 'T') {
653 std::ostringstream msg;
654 msg << "the creation time \'" << creation_time << "\' is not an ISO-8601 date-time";
655 throw std::runtime_error(msg.str().c_str());
656 }
657
658 validate();
659}

◆ OksFile

friend class OksFile
friend

Definition at line 296 of file file.hpp.

Member Data Documentation

◆ p_author

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

Definition at line 330 of file file.hpp.

◆ p_created_by

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

Definition at line 329 of file file.hpp.

◆ p_created_on

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

Definition at line 331 of file file.hpp.

◆ p_text

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

Definition at line 332 of file file.hpp.


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