Skip to content
Snippets Groups Projects
Commit 2a7faff2 authored by Bienchen's avatar Bienchen
Browse files

Added methods to deal witht he citation type.

parent f9c31892
No related branches found
No related tags found
No related merge requests found
......@@ -390,6 +390,13 @@ private:
class DLLEXPORT_OST_IO MMCifInfoCitation {
public:
/// \enum types of citations
typedef enum {
JOURNAL,
BOOK,
UNKNOWN
} MMCifInfoCType;
/// \brief Create a citation.
MMCifInfoCitation(): id_(""), where_(UNKNOWN), cas_(""), published_in_(""),
volume_(""), page_first_(""), page_last_(""), doi_(""), pubmed_(0),
......@@ -506,6 +513,54 @@ public:
/// \return title
String GetTitle() const { return title_; }
/// \brief Set the type of a publication
///
/// \param publication_type
void SetCitationType(MMCifInfoCType publication_type) {
where_ = publication_type;
}
/// \brief Set the type of a publication to journal
void SetCitationTypeJournal() {
where_ = MMCifInfoCitation::JOURNAL;
}
/// \brief Set the type of a publication to book
void SetCitationTypeBook() {
where_ = MMCifInfoCitation::BOOK;
}
/// \brief Set the type of a publication to unknown
void SetCitationTypeUnknown() {
where_ = MMCifInfoCitation::UNKNOWN;
}
/// \brief Get the type of a publication
///
/// \return citation type
MMCifInfoCType GetCitationType() const { return where_; }
/// \brief Check a citation to be published in a journal
///
/// \return true or false
bool IsCitationTypeJournal() const {
return where_ == MMCifInfoCitation::JOURNAL;
}
/// \brief Check a citation to be published in a book
///
/// \return true or false
bool IsCitationTypeBook() const {
return where_ == MMCifInfoCitation::BOOK;
}
/// \brief Check if the citation type is unknow
///
/// \return true or false
bool IsCitationTypeUnknown() const {
return where_ == MMCifInfoCitation::UNKNOWN;
}
/// \brief Set the list of authors
///
/// \param list
......@@ -574,13 +629,6 @@ public:
}
private:
/// \enum types of citations
typedef enum {
JOURNAL,
BOOK,
UNKNOWN
} MMCifInfoCType;
String id_; ///< internal identifier
MMCifInfoCType where_; ///< journal or book?
String cas_; ///< CAS identifier
......
......@@ -73,6 +73,7 @@ BOOST_AUTO_TEST_CASE(mmcif_info_citation)
cit.SetYear(815);
cit.SetTitle("Foo");
cit.SetAuthorList(author_list);
cit.SetCitationType(MMCifInfoCitation::JOURNAL);
author_list.clear();
BOOST_CHECK(cit.GetID() == "ID");
......@@ -86,9 +87,21 @@ BOOST_AUTO_TEST_CASE(mmcif_info_citation)
BOOST_CHECK(cit.GetPubMed() == 815);
BOOST_CHECK(cit.GetYear() == 815);
BOOST_CHECK(cit.GetTitle() == "Foo");
BOOST_CHECK(cit.GetCitationType() == MMCifInfoCitation::JOURNAL);
BOOST_CHECK(cit.IsCitationTypeJournal() == true);
BOOST_CHECK(cit.IsCitationTypeBook() == false);
BOOST_CHECK(cit.IsCitationTypeUnknown() == false);
author_list = cit.GetAuthorList();
BOOST_CHECK(author_list.back() == "Kabel, H.");
// checking all possible variants of citation type
cit.SetCitationTypeJournal();
BOOST_CHECK(cit.IsCitationTypeJournal() == true);
cit.SetCitationTypeBook();
BOOST_CHECK(cit.IsCitationTypeBook() == true);
cit.SetCitationTypeUnknown();
BOOST_CHECK(cit.IsCitationTypeUnknown() == true);
BOOST_TEST_MESSAGE(" done.");
BOOST_TEST_MESSAGE(" trying to add everything to an info object");
MMCifInfo info = MMCifInfo();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment