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

Go to the SVN repository for this file.

00001 /*  $Id: bioseq_edit_commands.cpp 33815 2007-05-04 17:18:18Z kazimird $
00002 * ===========================================================================
00003 *
00004 *                            PUBLIC DOMAIN NOTICE
00005 *               National Center for Biotechnology Information
00006 *
00007 *  This software/database is a "United States Government Work" under the
00008 *  terms of the United States Copyright Act.  It was written as part of
00009 *  the author's official duties as a United States Government employee and
00010 *  thus cannot be copyrighted.  This software/database is freely available
00011 *  to the public for use. The National Library of Medicine and the U.S.
00012 *  Government have not placed any restriction on its use or reproduction.
00013 *
00014 *  Although all reasonable efforts have been taken to ensure the accuracy
00015 *  and reliability of the software and data, the NLM and the U.S.
00016 *  Government do not and cannot warrant the performance or results that
00017 *  may be obtained by using this software or data. The NLM and the U.S.
00018 *  Government disclaim all warranties, express or implied, including
00019 *  warranties of performance, merchantability or fitness for any particular
00020 *  purpose.
00021 *
00022 *  Please cite the author in any work or product based on this material.
00023 *
00024 * ===========================================================================
00025 *
00026 * Author: Maxim Didenko
00027 *
00028 * File Description:
00029 *   Scope transaction
00030 *
00031 */
00032 
00033 
00034 #include <ncbi_pch.hpp>
00035 
00036 #include <objmgr/impl/bioseq_edit_commands.hpp>
00037 #include <objmgr/bioseq_handle.hpp>
00038 
00039 BEGIN_NCBI_SCOPE
00040 BEGIN_SCOPE(objects)
00041 
00042 ///////////////////////////////////////////////////////////////////////////////
00043 ///////////////////////////////////////////////////////////////////////////////
00044 CResetIds_EditCommand::CResetIds_EditCommand(const CBioseq_EditHandle& handle)
00045     : m_Handle(handle)
00046 {
00047 }
00048 CResetIds_EditCommand::~CResetIds_EditCommand() 
00049 {
00050 }
00051 
00052 void CResetIds_EditCommand::Do(IScopeTransaction_Impl& tr)
00053 {
00054     if (m_Handle.IsSetId()) {
00055         const CBioseq_EditHandle::TId& ids = m_Handle.GetId();
00056         m_Ids.insert(ids.begin(), ids.end());
00057         m_Handle.x_RealResetId();
00058         tr.AddCommand(CRef<IEditCommand>(this));
00059         IEditSaver* saver = GetEditSaver(m_Handle);
00060         if (saver) {
00061             tr.AddEditSaver(saver);
00062             saver->ResetIds(m_Handle, m_Ids, IEditSaver::eDo);
00063         }
00064     }   
00065 }
00066 void CResetIds_EditCommand::Undo()
00067 {
00068     ITERATE(TIds, it, m_Ids) {
00069         m_Handle.x_RealAddId(*it);
00070     }
00071     IEditSaver* saver = GetEditSaver(m_Handle);
00072     if (saver) {
00073         ITERATE(TIds, it, m_Ids) {
00074             saver->AddId(m_Handle, *it, IEditSaver::eUndo);
00075         }
00076     }             
00077 }
00078 
00079 END_SCOPE(objects)
00080 END_NCBI_SCOPE
Modified on Thu Feb 26 14:01:11 2015 by modify_doxy.py rev. 426318