diff --git a/modules/io/src/mol/mmcif_info.hh b/modules/io/src/mol/mmcif_info.hh index 0a00a838258de949f47c1796a9c70c93b284ef1e..9b781e40712b1c75dd66dac920da5ec16693349d 100644 --- a/modules/io/src/mol/mmcif_info.hh +++ b/modules/io/src/mol/mmcif_info.hh @@ -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 diff --git a/modules/io/tests/test_mmcif_info.cc b/modules/io/tests/test_mmcif_info.cc index 2eb111336ddca9de0379430b91ba5b9906dfad9d..bef7ed4922b31af5363da757d074668d3c5e9a6d 100644 --- a/modules/io/tests/test_mmcif_info.cc +++ b/modules/io/tests/test_mmcif_info.cc @@ -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();