NCBI C++ ToolKit
seqdbvolset.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: seqdbvolset.cpp 78040 2017-05-22 15:48:20Z zaretska $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Kevin Bealer
27  *
28  */
29 
30 /// @file seqdbvolset.cpp
31 /// Implementation for the CSeqDBVolSet class, which manages a list of volumes.
32 #include <ncbi_pch.hpp>
33 #include "seqdbvolset.hpp"
34 
36 
38  const vector<string> & vol_names,
39  char prot_nucl,
40  CSeqDBGiList * user_gilist,
41  CSeqDBNegativeList * neg_gilist)
42  : m_RecentVol(0)
43 {
44  CSeqDBLockHold locked(atlas);
45 
46 
47  try {
48  for(int i = 0; i < (int) vol_names.size(); i++) {
49  x_AddVolume(atlas,
50  vol_names[i],
51  prot_nucl,
52  user_gilist,
53  neg_gilist,
54  locked);
55 
56  if (prot_nucl == '-') {
57  // Once one volume picks a prot/nucl type, enforce that
58  // for the rest of the volumes. This should happen at
59  // most once.
60 
61  prot_nucl = m_VolList.back().Vol()->GetSeqType();
62  }
63  }
64  }
65  catch(CSeqDBException&) {
66  // The volume destructor will assume the lock is not held.
67  atlas.Unlock(locked);
68 
69  // For SeqDB's own exceptions, we'll keep the error message.
70 
71  for(int i = 0; i < (int) m_VolList.size(); i++) {
72  m_VolList[i].Free();
73  }
74  throw;
75  }
76  catch(...) {
77 
78  // For other exceptions, we'll provide a message.
79 
80  for(int i = 0; i < (int) m_VolList.size(); i++) {
81  m_VolList[i].Free();
82  }
84  eFileErr,
85  "Error: Could not construct all volumes.");
86  }
87 }
88 
90  : m_RecentVol(0)
91 {
92 }
93 
95 {
96  for(int i = 0; i < (int) m_VolList.size(); i++) {
97  m_VolList[i].Free();
98  }
99 }
100 
102  const string & nm,
103  char pn,
104  CSeqDBGiList * user_list,
105  CSeqDBNegativeList * neg_list,
106  CSeqDBLockHold & locked)
107 {
108  int num_oids = x_GetNumOIDs();
109 
110  CSeqDBVol * new_volp =
111  new CSeqDBVol(atlas, nm, pn, user_list, neg_list, num_oids, locked);
112 
113  CSeqDBVolEntry new_vol( new_volp );
114  new_vol.SetStartAndEnd( num_oids );
115  m_VolList.push_back( new_vol );
116 }
117 
119 
CSeqDBAtlas class.
Definition: seqdbatlas.hpp:298
void Unlock(CSeqDBLockHold &locked)
Unlock the atlas.
Definition: seqdbatlas.hpp:480
CSeqDBException.
Definition: seqdbcommon.hpp:73
CSeqDBGiList.
CSeqDBLockHold.
Definition: seqdbatlas.hpp:167
CSeqDBNegativeList.
CSeqDBVolEntry.
Definition: seqdbvolset.hpp:59
void SetStartAndEnd(int start)
Set the OID range.
Definition: seqdbvolset.hpp:97
CSeqDBVolSet()
Default Constructor.
Definition: seqdbvolset.cpp:89
~CSeqDBVolSet()
Destructor.
Definition: seqdbvolset.cpp:94
void x_AddVolume(CSeqDBAtlas &atlas, const string &nm, char pn, CSeqDBGiList *user_list, CSeqDBNegativeList *neg_list, CSeqDBLockHold &locked)
Add a volume.
int x_GetNumOIDs() const
Get the size of the entire OID range.
vector< CSeqDBVolEntry > m_VolList
The actual set of volumes.
CSeqDBVol class.
Definition: seqdbvol.hpp:169
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
int i
Manages a set of database volumes.
Modified on Thu Dec 07 10:12:10 2023 by modify_doxy.py rev. 669887