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

Go to the SVN repository for this file.

1 /* $Id: cmd_create_desc.cpp 44316 2019-11-27 16:08:06Z filippov $
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  * Authors: Roman Katargin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 
32 #include <objmgr/seqdesc_ci.hpp>
33 #include <objmgr/seq_entry_ci.hpp>
34 #include <objmgr/seqdesc_ci.hpp>
35 
37 
38 
41 
43 {
44  if (m_Failure || !m_seh)
45  return;
46 
47  m_TopSeqEntry = m_seh.GetTopLevelEntry();
48  if (m_Desc->IsSource()) {
50  if (desc_it) {
51  LOG_POST(Error << "CCmdCreateDesc: BioSource descriptor already set");
52  m_Failure = true;
53  return;
54  }
55  }
56 
57  CSeq_entry_EditHandle eseh = m_seh.GetEditHandle();
58  eseh.AddSeqdesc(const_cast<CSeqdesc&>(*m_Desc));
59 }
60 
62 {
63  if (m_Failure || !m_TopSeqEntry)
64  return;
65  if (!m_seh)
66  {
68  for ( CSeqdesc_CI desc_it(*entry_it, m_Desc->Which(), 1); desc_it; ++desc_it)
69  if (&*desc_it == m_Desc.GetPointer())
70  m_seh = desc_it.GetSeq_entry_Handle();
71 
72  }
73  if (!m_seh)
74  return;
75  CSeq_entry_EditHandle eseh = m_seh.GetEditHandle();
76  eseh.RemoveSeqdesc(*m_Desc);
77 }
78 
80 {
81  return "Create Descriptor";
82 }
83 
objects::CSeq_entry_Handle m_TopSeqEntry
virtual string GetLabel()
CConstRef< objects::CSeqdesc > m_Desc
objects::CSeq_entry_Handle m_seh
virtual void Execute()
Do the editing action.
virtual void Unexecute()
Undo (opposite to Execute())
CSeq_entry_CI –.
CSeq_entry_Handle –.
CSeqdesc_CI –.
Definition: seqdesc_ci.hpp:65
USING_SCOPE(objects)
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
CRef< CSeqdesc > RemoveSeqdesc(const CSeqdesc &v) const
bool AddSeqdesc(CSeqdesc &v) const
@ fIncludeGivenEntry
Include the top (given) entry.
@ fRecursive
Iterate recursively.
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:1684
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
@ e_Source
source of materials, includes Org-ref
Definition: Seqdesc_.hpp:133
Modified on Sat May 25 14:16:18 2024 by modify_doxy.py rev. 669887