NCBI C++ ToolKit
scope_transaction_impl.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef OBJECTS_OBJMGR_IMPL___SCOP_TRANSACTION_IMPL__HPP
2 #define OBJECTS_OBJMGR_IMPL___SCOP_TRANSACTION_IMPL__HPP
3 
4 /* $Id: scope_transaction_impl.hpp 33815 2007-05-04 17:18:18Z kazimird $
5 * ===========================================================================
6 *
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author: Maxim Didenko
30 *
31 * File Description:
32 *
33 */
34 
35 #include <corelib/ncbistd.hpp>
36 #include <corelib/ncbiobj.hpp>
37 
39 
40 #include <list>
41 #include <set>
42 
45 
46 class IEditSaver;
48 
49 ///////////////////////////////////////////////////////////////////////////////
50 ///////////////////////////////////////////////////////////////////////////////
52 {
53 public:
54 
55  virtual ~IEditCommand();
56 
57  virtual void Do(IScopeTransaction_Impl&) = 0;
58  virtual void Undo() = 0;
59 };
60 
61 
62 ///////////////////////////////////////////////////////////////////////////////
64 {
65 public:
67  typedef list<TCommand> TCommands;
68 
70  virtual ~CMultEditCommand();
71 
72  void AddCommand(TCommand cmd);
73 
74  template<typename Iter>
75  void AddCommands(Iter begin, Iter end)
76  {
77  m_Commands.insert(m_Commands.end(), begin, end);
78  }
79 
80  virtual void Do(IScopeTransaction_Impl&);
81  virtual void Undo();
82 
83 private:
84 
87 };
88 
89 ///////////////////////////////////////////////////////////////////////////////
90 ///////////////////////////////////////////////////////////////////////////////
91 
92 
94 {
95 public:
96 
98 
99  virtual ~IScopeTransaction_Impl();
100 
101  virtual void AddCommand(TCommand) = 0;
102  virtual void AddEditSaver(IEditSaver*) = 0;
103 
104  virtual void Commit() = 0;
105  virtual void RollBack() = 0;
106 
107  virtual void AddScope(CScope_Impl&) = 0;
108  virtual bool HasScope(CScope_Impl&) const = 0;
109 
110 protected:
111  virtual bool x_CanCommitRollBack() const = 0;
112  // virtual void x_Finish() = 0;
113 };
114 
115 ///////////////////////////////////////////////////////////////////////////////
117 {
118 public:
119 
121  typedef list<TCommand> TCommands;
125 
127  virtual ~CScopeTransaction_Impl();
128 
129  virtual void AddCommand(TCommand cmd);
130  virtual void AddEditSaver(IEditSaver*);
131 
132  virtual void Commit();
133  virtual void RollBack();
134 
135  virtual void AddScope(CScope_Impl& scope);
136  virtual bool HasScope(CScope_Impl& scope) const;
137 
138 protected:
139 
140  virtual bool x_CanCommitRollBack() const;
141 
142 protected:
143 
145  TCommands::iterator m_CurCmd;
149 
150  void x_AddScope(CScope_Impl& scope);
151  void x_DoFinish(IScopeTransaction_Impl*);
152 
153 private:
156 
157 };
158 /*
159 ///////////////////////////////////////////////////////////////////////////////
160 class NCBI_XOBJMGR_EXPORT CScopeSubTransaction_Impl : public CScopeTransaction_Impl
161 {
162 public:
163 
164  CScopeSubTransaction_Impl(CScope_Impl& scope);
165 
166  virtual ~CScopeSubTransaction_Impl();
167 
168  virtual void Commit();
169 
170  virtual void AddScope(CScope_Impl& scope);
171  virtual bool HasScope(CScope_Impl& scope) const;
172 
173  virtual void AddEditSaver(IEditSaver*);
174 
175 protected:
176  virtual void x_Finish();
177 
178 private:
179  CRef<IScopeTransaction_Impl> m_Parent;
180 
181 
182 private:
183  CScopeSubTransaction_Impl(const CScopeTransaction_Impl&);
184  CScopeSubTransaction_Impl& operator=(const CScopeTransaction_Impl&);
185 };
186 */
187 
190 
191 #endif //OBJECTS_OBJMGR_IMPL___SCOP_TRANSACTION_IMPL__HPP
void AddCommands(Iter begin, Iter end)
CRef< IEditCommand > TCommand
list< TCommand > TCommands
CObject –.
Definition: ncbiobj.hpp:180
CRef –.
Definition: ncbiobj.hpp:618
CScopeTransaction_Impl & operator=(const CScopeTransaction_Impl &)
CScopeTransaction_Impl(const CScopeTransaction_Impl &)
CRef< IScopeTransaction_Impl > m_Parent
Interface (functor) for object editing.
virtual void Do(IScopeTransaction_Impl &)=0
virtual void Undo()=0
virtual ~IEditCommand()
Edit Saver Interface.
Definition: edit_saver.hpp:72
virtual void RollBack()=0
virtual void AddCommand(TCommand)=0
virtual void Commit()=0
CRef< IEditCommand > TCommand
virtual void AddScope(CScope_Impl &)=0
virtual bool x_CanCommitRollBack() const =0
virtual void AddEditSaver(IEditSaver *)=0
virtual bool HasScope(CScope_Impl &) const =0
Include a standard set of the NCBI C++ Toolkit most basic headers.
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
#define NCBI_XOBJMGR_EXPORT
Definition: ncbi_export.h:1307
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Modified on Tue Apr 23 07:37:39 2024 by modify_doxy.py rev. 669887