1 #ifndef PUBSEQ_GATEWAY_ID2INFO__HPP 2 #define PUBSEQ_GATEWAY_ID2INFO__HPP 3 4 /* $Id: id2info.hpp 618495 2020-10-21 15:00:25Z satskyse $ 5 * =========================================================================== 6 * 7 * PUBLIC DOMAIN NOTICE 8 * National Center for Biotechnology Information 9 * 10 * This software/database is a "United States Government Work" under the 11 * terms of the United States Copyright Act. It was written as part of 12 * the author's official duties as a United States Government employee and 13 * thus cannot be copyrighted. This software/database is freely available 14 * to the public for use. The National Library of Medicine and the U.S. 15 * Government have not placed any restriction on its use or reproduction. 16 * 17 * Although all reasonable efforts have been taken to ensure the accuracy 18 * and reliability of the software and data, the NLM and the U.S. 19 * Government do not and cannot warrant the performance or results that 20 * may be obtained by using this software or data. The NLM and the U.S. 21 * Government disclaim all warranties, express or implied, including 22 * warranties of performance, merchantability or fitness for any particular 23 * purpose. 24 * 25 * Please cite the author in any work or product based on this material. 26 * 27 * =========================================================================== 28 * 29 * Authors: Sergey Satskiy 30 * 31 * File Description: 32 * PSG ID2 info wrapper 33 * 34 */ 35 36 #include "cass_blob_id.hpp" 37 38 #include <string> 39 using namespace std; 40 41 42 const int64_t kSplitInfoChunk = 999999999; 43 44 45 // There could be many ID2INFO flavors 46 enum EPSGSId2InfoFlavor { 47 ePSGS_SatInfoChunksVerId2InfoFlavor, 48 ePSGS_IdModifiedVerId2InfoFlavor, 49 ePSGS_UnknownId2InfoFlavor 50 }; 51 52 53 // May be found in cassandra 54 class CPSGS_SatInfoChunksVerFlavorId2Info 55 { 56 public: 57 using TSat = int16_t; 58 using TInfo = int32_t; 59 using TChunks = int32_t; 60 using TSplitVersion = int32_t; 61 62 public: 63 CPSGS_SatInfoChunksVerFlavorId2Info(const string & id2_info, 64 bool count_errors = true); CPSGS_SatInfoChunksVerFlavorId2Info()65 CPSGS_SatInfoChunksVerFlavorId2Info() : 66 m_Sat(-1), m_Info(-1), m_Chunks(-1), 67 m_SplitVersion(-1), m_SplitVersionPresent(false) 68 {} 69 70 public: GetSat(void) const71 TSat GetSat(void) const 72 { return m_Sat; } 73 GetInfo(void) const74 TInfo GetInfo(void) const 75 { return m_Info; } 76 GetChunks(void) const77 TChunks GetChunks(void) const 78 { return m_Chunks; } 79 GetSplitVersion(void) const80 TSplitVersion GetSplitVersion(void) const 81 { return m_SplitVersion; } 82 83 string Serialize(void) const; 84 85 private: 86 TSat m_Sat; 87 TInfo m_Info; 88 TChunks m_Chunks; 89 TSplitVersion m_SplitVersion; 90 bool m_SplitVersionPresent; 91 }; 92 93 94 // May come in the URL 95 class CPSGS_IdModifiedVerFlavorId2Info 96 { 97 public: 98 using TLastModified = int64_t; 99 using TSplitVersion = int32_t; 100 101 public: 102 CPSGS_IdModifiedVerFlavorId2Info(const string & id2_info); CPSGS_IdModifiedVerFlavorId2Info()103 CPSGS_IdModifiedVerFlavorId2Info() : 104 m_LastModified(-1), m_SplitVersion(-1), 105 m_LastModifiedPresent(false), 106 m_SplitVersionPresent(false) 107 {} 108 109 public: GetTSEId(void)110 SCass_BlobId & GetTSEId(void) 111 { return m_TSEId; } 112 GetLastModified(void) const113 TLastModified GetLastModified(void) const 114 { return m_LastModified; } 115 GetSplitVersion(void) const116 TSplitVersion GetSplitVersion(void) const 117 { return m_SplitVersion; } 118 119 string Serialize(void) const; 120 121 private: 122 SCass_BlobId m_TSEId; 123 TLastModified m_LastModified; 124 TSplitVersion m_SplitVersion; 125 bool m_LastModifiedPresent; 126 bool m_SplitVersionPresent; 127 }; 128 129 #endif /* PUBSEQ_GATEWAY_ID2INFO__HPP */ 130 131