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

Go to the SVN repository for this file.

1 /* $Id: scope_transaction.cpp 48677 2011-02-16 16:42:21Z vasilche $
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 <objmgr/scope.hpp>
40 #include <objmgr/error_codes.hpp>
41 
42 
43 #define NCBI_USE_ERRCODE_X ObjMgr_ScopeTrans
44 
45 
48 
50 {
51  CScope_Impl& impl = scope.GetImpl();
52  x_Set( *impl.CreateTransaction() );
53 }
54 
56 {
57  try {
58  RollBack();
59  } catch (exception& ex) {
60  ERR_POST_X(1, Fatal << "Exception cought in ~CScopeTransaction() : "
61  << ex.what());
62  }
63 }
64 
66 {
67  x_GetImpl().AddScope(scope.GetImpl());
68 }
69 
71 {
72  x_GetImpl().Commit();
73 }
75 {
76  x_GetImpl().RollBack();
77 }
78 
80 {
81  return static_cast<IScopeTransaction_Impl&>(*m_Impl);
82 }
83 
85 {
86  m_Impl.Reset(&impl);
87 }
Scope Transaction.
IScopeTransaction_Impl & x_GetImpl()
~CScopeTransaction()
Destractor.
void Commit()
Finish the editing operation.
CRef< CObject > m_Impl
void x_Set(IScopeTransaction_Impl &)
void AddScope(CScope &scope)
If the editing operation affects objects from another scope this scope should be added to the current...
void RollBack()
Undo all made modificatins.
CScope –.
Definition: scope.hpp:92
virtual void RollBack()=0
virtual void Commit()=0
virtual void AddScope(CScope_Impl &)=0
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
Definition: ncbidiag.hpp:550
void Fatal(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1209
CScope_Impl & GetImpl(void)
Definition: scope.hpp:719
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#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
Definition of all error codes used in objmgr libraries (xobjmgr.lib, xobjutil.lib and others).
Modified on Fri Sep 20 14:57:37 2024 by modify_doxy.py rev. 669887