OpendTect  6.3
saveable.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: Bert
8  Date: April 2016
9 ________________________________________________________________________
10 
11 -*/
12 
13 #include "generalmod.h"
14 #include "sharedobject.h"
15 #include "dbkey.h"
16 #include "iopar.h"
17 #include "uistring.h"
18 class IOObj;
19 
20 
23 mExpClass(General) Saveable : public Monitorable
25 public:
26 
27  Saveable(const SharedObject&);
28  ~Saveable();
30 
31  const SharedObject* object() const;
32  bool objectAlive() const { return objectalive_; }
33  void setObject(const SharedObject&);
34 
35  mImplSimpleMonitoredGetSet(inline,key,setKey,DBKey,storekey_,0)
36  mImplSimpleMonitoredGetSet(inline,ioObjPars,setIOObjPars,IOPar,ioobjpars_,0)
37  // The pars will be merge()'d with the IOObj's current
38 
39  virtual uiRetVal save() const;
40  virtual uiRetVal store(const IOObj&) const;
41 
42  bool needsSave() const;
43  virtual void setJustSaved() const;
44 
45  DirtyCountType lastSavedDirtyCount() const
46  { return lastsavedirtycount_; }
47  DirtyCountType curDirtyCount() const;
48 
49  static ChangeType cSaveSucceededChangeType() { return 1; }
50  static ChangeType cSaveFailedChangeType() { return 2; }
51 
52 protected:
53 
59 
60  // This function can be called from any thread
61  virtual uiRetVal doStore(const IOObj&) const = 0;
62  bool isSave(const IOObj&) const;
63 
64 private:
65 
66  void attachCBToObj();
67  void detachCBFromObj();
68  void objDelCB(CallBacker*);
69 
70 };
#define mExpClass(module)
Definition: commondefs.h:157
Object that can be MT-safely monitored from cradle to grave.
Definition: monitorable.h:76
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:182
IOPar ioobjpars_
Definition: saveable.h:57
Definition: ioobj.h:57
int ChangeType
Definition: monitorable.h:80
int64_t DirtyCountType
Definition: monitorable.h:84
#define mODTextTranslationClass(clss)
Definition: uistring.h:37
Definition: sharedobject.h:18
Threads::Atomic< bool > objectalive_
Definition: saveable.h:55
void setKey(const DBKey &ky)
Definition: ioobj.h:156
Object that can be saved at any time.
Definition: saveable.h:23
bool objectAlive() const
Definition: saveable.h:32
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:53
#define mImplSimpleMonitoredGetSet(pfx, fnnmget, fnnmset, typ, memb, chgtyp)
Defines simple MT-safe copyable member access.
Definition: monitor.h:39
static ChangeType cSaveSucceededChangeType()
Definition: saveable.h:49
virtual DBKey key() const
Definition: ioobj.h:68
const SharedObject * object_
Definition: saveable.h:54
static ChangeType cSaveFailedChangeType()
Definition: saveable.h:50
DirtyCounter lastsavedirtycount_
Definition: saveable.h:58
DBKey storekey_
Definition: saveable.h:56
Definition: uistring.h:299
Full key to any object in the OpendTect data store.
Definition: dbkey.h:36
#define mDeclAbstractMonitorableAssignment(clss)
Monitorable subclasses: assignment and comparison.
Definition: monitor.h:105

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2017