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

Go to the SVN repository for this file.

1 /* $Id: TMgr_AnnotCounts.cpp 59932 2013-09-27 10:09:37Z meric $
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: .......
27  *
28  * File Description:
29  * .......
30  *
31  * Remark:
32  * This code was originally generated by application DATATOOL
33  * using the following specifications:
34  * 'trackmgr.asn'.
35  */
36 
37 #include <ncbi_pch.hpp>
41 
42 
44 BEGIN_objects_SCOPE // namespace ncbi::objects::
45 
46 
48 {
49 }
50 
52 {
53 }
54 
57 {
58  // use a map to short-circuit search for any previously-found counts
60  if (it != m_Counts.end()) {
61  return it->second;
62  }
63  TTypeStatRef retval;
64  NON_CONST_ITERATE (TCounts, it, const_cast<CTMgr_AnnotCounts*>(this)->SetCounts()) {
65  TTypeStatRef cnt = *it;
66  m_Counts.insert(make_pair(cnt->GetType(), cnt));
67  if (cnt->GetType() == type) {
68  retval = cnt;
69  break;
70  }
71  }
72  return retval;
73 }
74 
77 {
79  return (cnt.IsNull() ? 0 : cnt->GetCount());
80 }
81 
82 void
84 {
86  if (cnt.IsNull()) {
87  cnt.Reset(new CTMgr_TypeStat());
88  cnt->SetType(type);
89  cnt->SetCount(0);
90  SetCounts().push_back(cnt);
91  }
92  cnt->SetCount(cnt->GetCount() + count);
93 }
94 
95 void
97 {
99  if (cnt.IsNull()) {
100  cnt.Reset(new CTMgr_TypeStat());
101  cnt->SetType(type);
102  cnt->SetCount(0);
103  SetCounts().push_back(cnt);
104  }
105  const CTMgr_TypeStat::TCount c = cnt->GetCount();
106  cnt->SetCount(c + 1);
107  cnt->SetLength_stats().Add(stop - start + 1, c);
108  cnt->SetPosition_stats().Add(start, stop, c);
109 }
110 
111 
112 END_objects_SCOPE // namespace ncbi::objects::
114 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CRef –.
Definition: ncbiobj.hpp:618
objects::CTMgr_TypeStat::TCount GetCount(ETMgr_AnnotType type) const
void AddPosition(ETMgr_AnnotType type, Uint8 start, Uint8 stop)
void Add(ETMgr_AnnotType type, Int8 count)
TTypeStatRef x_GetCount(ETMgr_AnnotType type) const
CTMgr_TypeStat –.
container_type::const_iterator const_iterator
Definition: map.hpp:53
const_iterator end() const
Definition: map.hpp:152
iterator_bool insert(const value_type &val)
Definition: map.hpp:165
const_iterator find(const key_type &key) const
Definition: map.hpp:153
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
Uint8 TCount
Alias for value type of counter.
Definition: ncbiobj.hpp:310
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
uint64_t Uint8
8-byte (64-bit) unsigned integer
Definition: ncbitype.h:105
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
TCounts & SetCounts(void)
Assign a value to Counts data member.
ETMgr_AnnotType
Access to ETMgr_AnnotType's attributes (values, names) as defined in spec.
list< CRef< CTMgr_TypeStat > > TCounts
static unsigned cnt[256]
Definition: type.c:6
Modified on Wed May 01 14:24:08 2024 by modify_doxy.py rev. 669887