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

Go to the SVN repository for this file.

1 /* $Id: seq_entry_edit_commands.cpp 33815 2007-05-04 17:18:18Z kazimird $
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: Maxim Didenko
27 *
28 * File Description:
29 * Scope transaction
30 *
31 */
32 
33 
34 #include <ncbi_pch.hpp>
35 
36 #include <corelib/ncbiexpt.hpp>
37 
40 
43 ///////////////////////////////////////////////////////////////////////////////
44 ///////////////////////////////////////////////////////////////////////////////
45 
48  CScope_Impl& scope)
49  : m_Handle(handle), m_Scope(scope)
50 {
51 }
53 {
54 }
55 
57 {
58  if (m_Handle.IsSeq())
60  else if(m_Handle.IsSet())
62  else
63  return;
64  tr.AddCommand(CRef<IEditCommand>(this));
67  if (saver) {
68  tr.AddEditSaver(saver);
71  else if(m_BioseqSetHandle.IsRemoved())
73  }
74 
75 }
77 {
80  if (m_BioseqHandle.IsRemoved()) {
82  if (saver)
84  }
85  else if (m_BioseqSetHandle.IsRemoved()) {
87  if (saver)
89  }
90 }
91 ///////////////////////////////////////////////////////////////////////////////
92 ///////////////////////////////////////////////////////////////////////////////
93 
95 {
96 }
97 
99 {
100  _ASSERT(m_Handle.GetParentEntry()); // Does not handle TSE
102  m_Index = m_ParentHandle.GetSeq_entry_Index(m_Handle);
103  if( m_Index < 0 )
104  return;
105  tr.AddCommand(CRef<IEditCommand>(this));
106  IEditSaver* saver = GetEditSaver(m_Handle);
108  if (saver) {
109  tr.AddEditSaver(saver);
110  saver->Remove(m_ParentHandle, m_Handle, m_Index, IEditSaver::eDo);
111  }
112 }
113 
115 {
117  IEditSaver* saver = GetEditSaver(m_Handle);
118  if (saver) {
120  }
121 }
122 
123 
124 ///////////////////////////////////////////////////////////////////////////////
125 ///////////////////////////////////////////////////////////////////////////////
126 
128 {
129 }
130 
132 {
133  _ASSERT(!m_Handle.GetParentEntry()); // Handles TSE only
135  // TODO entry.Reset();
136  IEditSaver* saver = GetEditSaver(m_Handle);
138  tr.AddCommand(CRef<IEditCommand>(this));
139  if (saver) {
140  tr.AddEditSaver(saver);
141  saver->RemoveTSE(tse, IEditSaver::eDo);
142  }
143 
144 }
146 {
147  _ASSERT(0);
149  "CRemoveTSE_EditCommand::Undo() is not implemented yet");
150 }
151 
TSet SetSet(void) const
bool IsRemoved(void) const
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:73
The method is called when a modification has just been undone.
Definition: edit_saver.hpp:78
virtual void Do(IScopeTransaction_Impl &tr)
CBioseq_set_EditHandle GetParentBioseq_set(void) const
Get parent bioseq-set edit handle.
CSeq_entry_EditHandle AttachEntry(const CBioseq_set_EditHandle &seqset, CSeq_entry &entry, int index=-1)
Definition: scope_impl.cpp:644
virtual void Undo()
CScope_Impl & m_Scope
virtual ~CSeq_entry_SelectNone_EditCommand()
TSeq SetSeq(void) const
int m_Index
CSeq_entry_EditHandle m_Handle
CSeq_entry_EditHandle GetParentEntry(void) const
Get parent seq-entry edit handle.
Defines NCBI C++ exception handling.
Edit Saver Interface.
Definition: edit_saver.hpp:71
void SelectNone(const CSeq_entry_EditHandle &entry)
virtual void Undo()
virtual void AddEditSaver(IEditSaver *)=0
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
virtual void Remove(const CSeq_entry_Handle &entry, const CSeq_annot_Handle &what, ECallMode)=0
void RemoveEntry(const CSeq_entry_EditHandle &entry)
The method is called when a modification has just been done.
Definition: edit_saver.hpp:77
virtual void Detach(const CSeq_entry_Handle &entry, const CBioseq_Handle &what, ECallMode)=0
CSeq_entry_Handle –.
virtual void Do(IScopeTransaction_Impl &tr)
CBioseq_set_EditHandle m_ParentHandle
virtual void AddCommand(TCommand)=0
CSeq_entry_EditHandle m_Handle
CBioseq_EditHandle SelectSeq(const CSeq_entry_EditHandle &entry, CBioseq &seq)
Definition: scope_impl.cpp:708
void RemoveTopLevelSeqEntry(CTSE_Handle entry)
Definition: scope_impl.cpp:431
CException –.
Definition: ncbiexpt.hpp:709
CRef –.
Definition: ncbiobj.hpp:616
static CRef< CScope > m_Scope
bool IsSeq(void) const
virtual void RemoveTSE(const CTSE_Handle &handle, ECallMode)=0
CScope_Impl & m_Scope
CBioseq_set_EditHandle m_BioseqSetHandle
virtual void Do(IScopeTransaction_Impl &tr)
virtual void Attach(const CBioObjectId &old_id, const CSeq_entry_Handle &entry, const CBioseq_Handle &what, ECallMode)=0
#define _ASSERT
CBioseq_set_EditHandle SelectSet(const CSeq_entry_EditHandle &entry, CBioseq_set &seqset)
Definition: scope_impl.cpp:765
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:70
#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:546
bool IsRemoved(void) const
Check if handle points to a removed bioseq.
#define const
Definition: zconf.h:217
virtual ~CSeq_entry_Remove_EditCommand()
bool IsSet(void) const
CBioseq_EditHandle m_BioseqHandle
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
CSeq_entry_EditHandle m_Handle
const CTSE_Handle & GetTSE_Handle(void) const
IEditSaver * GetEditSaver(const Handle &handle)
const CBioObjectId & GetBioObjectId(void) const
Get unique object id.
Modified on Fri Aug 26 18:15:49 2016 by modify_doxy.py rev. 506947