1 /***************************************************************************** 2 * $Id: record.hpp 634611 2021-07-15 17:13:56Z ivanov $ 3 * =========================================================================== 4 * 5 * PUBLIC DOMAIN NOTICE 6 * National Center for Biotechnology Information 7 * 8 * This software/database is a "United States Government Work" under the 9 * terms of the United States Copyright Act. It was written as part of 10 * the author's official duties as a United States Government employee and 11 * thus cannot be copyrighted. This software/database is freely available 12 * to the public for use. The National Library of Medicine and the U.S. 13 * Government have not placed any restriction on its use or reproduction. 14 * 15 * Although all reasonable efforts have been taken to ensure the accuracy 16 * and reliability of the software and data, the NLM and the U.S. 17 * Government do not and cannot warrant the performance or results that 18 * may be obtained by using this software or data. The NLM and the U.S. 19 * Government disclaim all warranties, express or implied, including 20 * warranties of performance, merchantability or fitness for any particular 21 * purpose. 22 * 23 * Please cite the author in any work or product based on this material. 24 * 25 * Blob storage: blob status history record 26 * 27 *****************************************************************************/ 28 29 #ifndef OBJTOOLS__PUBSEQ_GATEWAY__IMPL__CASSANDRA__STATUS_HISTORY__RECORD_HPP 30 #define OBJTOOLS__PUBSEQ_GATEWAY__IMPL__CASSANDRA__STATUS_HISTORY__RECORD_HPP 31 32 #include <corelib/ncbistd.hpp> 33 34 #include <sstream> 35 #include <string> 36 37 #include "../IdCassScope.hpp" 38 39 BEGIN_IDBLOB_SCOPE 40 USING_NCBI_SCOPE; 41 42 using TBlobStatusFlagsBase = int64_t; 43 enum class EBlobStatusFlags : TBlobStatusFlagsBase { 44 eWithdrawn = 1, 45 eWithdrawnPermanently = 2, 46 eSuppressPermanently = 4, 47 eSuppressEditBlocked = 8, 48 eSuppressTemporary = 16, 49 }; 50 51 class CBlobStatusHistoryRecord { 52 53 public: CBlobStatusHistoryRecord()54 CBlobStatusHistoryRecord() 55 : m_SatKey(0) 56 , m_Replaces(0) 57 , m_DoneWhen(0) 58 , m_Flags(0) 59 {} 60 CBlobStatusHistoryRecord(CBlobStatusHistoryRecord const &) = default; 61 CBlobStatusHistoryRecord(CBlobStatusHistoryRecord &&) = default; 62 63 CBlobStatusHistoryRecord& operator=(CBlobStatusHistoryRecord const &) = default; 64 CBlobStatusHistoryRecord& operator=(CBlobStatusHistoryRecord&&) = default; 65 SetKey(int32_t value)66 CBlobStatusHistoryRecord& SetKey(int32_t value) { 67 m_SatKey = value; 68 return *this; 69 } 70 SetReplaces(int32_t value)71 CBlobStatusHistoryRecord& SetReplaces(int32_t value) { 72 m_Replaces = value; 73 return *this; 74 } 75 SetDoneWhen(int64_t value)76 CBlobStatusHistoryRecord& SetDoneWhen(int64_t value) { 77 m_DoneWhen = value; 78 return *this; 79 } 80 SetComment(string value)81 CBlobStatusHistoryRecord& SetComment(string value) { 82 m_Comment = move(value); 83 return *this; 84 } 85 SetPublicComment(string value)86 CBlobStatusHistoryRecord& SetPublicComment(string value) { 87 m_PublicComment = move(value); 88 return *this; 89 } 90 SetUserName(string value)91 CBlobStatusHistoryRecord& SetUserName(string value) { 92 m_UserName = move(value); 93 return *this; 94 } 95 SetFlag(bool set_flag,EBlobStatusFlags flag)96 CBlobStatusHistoryRecord& SetFlag(bool set_flag, EBlobStatusFlags flag) { 97 if (set_flag) { 98 m_Flags |= static_cast<TBlobStatusFlagsBase>(flag); 99 } else { 100 m_Flags &= ~(static_cast<TBlobStatusFlagsBase>(flag)); 101 } 102 return *this; 103 } 104 SetFlags(TBlobStatusFlagsBase value)105 CBlobStatusHistoryRecord& SetFlags(TBlobStatusFlagsBase value) { 106 m_Flags = value; 107 return *this; 108 } 109 GetSatKey() const110 int32_t GetSatKey() const { 111 return m_SatKey; 112 } 113 GetReplaces() const114 int32_t GetReplaces() const { 115 return m_Replaces; 116 } 117 GetDoneWhen() const118 int64_t GetDoneWhen() const { 119 return m_DoneWhen; 120 } 121 GetUserName() const122 string GetUserName() const { 123 return m_UserName; 124 } 125 GetComment() const126 string GetComment() const { 127 return m_Comment; 128 } 129 GetPublicComment() const130 string GetPublicComment() const { 131 return m_PublicComment; 132 } 133 GetFlag(EBlobStatusFlags flag) const134 bool GetFlag(EBlobStatusFlags flag) const { 135 return m_Flags & static_cast<TBlobStatusFlagsBase>(flag); 136 } 137 GetFlags() const138 TBlobStatusFlagsBase GetFlags() const { 139 return m_Flags; 140 } 141 ToString() const142 string ToString() const { 143 stringstream ss; 144 ss << "SatKey: " << m_SatKey << endl 145 << "DoneWhen:" << m_DoneWhen << endl 146 << "Flags: " << m_Flags << endl 147 << "User: " << m_UserName << endl 148 << "Comment: " << m_Comment << endl 149 << "Public comment: " << m_PublicComment << endl 150 << "Replaces: " << m_Replaces << endl; 151 152 return ss.str(); 153 } 154 155 private: 156 int32_t m_SatKey; 157 int32_t m_Replaces; 158 int64_t m_DoneWhen; 159 TBlobStatusFlagsBase m_Flags; 160 string m_UserName; 161 string m_Comment; 162 string m_PublicComment; 163 }; 164 165 END_IDBLOB_SCOPE 166 167 #endif // OBJTOOLS__PUBSEQ_GATEWAY__IMPL__CASSANDRA__STATUS_HISTORY__RECORD_HPP 168