OpendTect  6.3
dbkey.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: Sep 2016
9 ________________________________________________________________________
10 
11 -*/
12 
13 #include "groupedid.h"
14 #include "bufstring.h"
15 #include "uistring.h"
16 #include "typeset.h"
17 
18 class BufferStringSet;
19 
20 
36 mExpClass(Basic) DBKey : public IDWithGroup<int,int>
37 {
38 public:
39 
40  typedef GroupID DirID;
41  typedef GroupNrType DirNrType;
42 
44  : auxkey_(0) {}
45  DBKey( const DBKey& oth )
46  : auxkey_(0) { *this = oth; }
47  DBKey( DirID dirid, ObjID oid=ObjID::getInvalid() )
48  : IDWithGroup<int,int>(dirid,oid)
49  , auxkey_(0) {}
50  ~DBKey();
51 
52  DBKey& operator =(const DBKey&);
53  bool operator ==(const DBKey&) const;
54  inline bool operator !=( const DBKey& oth ) const
55  { return !(oth == *this); }
56 
57  static DBKey getInvalid() { return DBKey(-1,-1); }
58  static DBKey get( DirNrType gnr, ObjNrType onr=-1 )
59  { return DBKey(gnr,onr); }
60  static DBKey getFromString(const char*);
61  static DBKey getFromInt64(od_int64);
62 
63  virtual bool isInvalid() const { return groupnr_ < 0; }
64 
65  // aliases
66  inline bool hasValidDirID() const { return hasValidGroupID(); }
67  inline DirID dirID() const { return groupID(); }
68  inline void setDirID( DirID id ) { setGroupID( id ); }
69 
70  virtual BufferString toString() const;
71  virtual void fromString(const char*);
72 
73  uiString toUiString() const;
74 
75  bool hasAuxKey() const { return auxkey_; }
76  BufferString auxKey() const;
77  void setAuxKey(const char*);
78 
79  mDeprecated DBKey(const char*);
80  mDeprecated static DBKey udf() { return getInvalid(); }
81  mDeprecated bool isEmpty() const { return isInvalid(); }
82  mDeprecated bool isUdf() const { return isInvalid(); }
83  mDeprecated void setEmpty() { setInvalid(); }
84 
85 protected:
86 
87  DBKey( DirNrType dnr, ObjNrType onr=-1 )
88  : IDWithGroup<int,int>(dnr,onr)
89  , auxkey_(0) {}
90 
92 
93  static void doGetfromString(DBKey&,const char*);
94 
95 };
96 
97 
98 mExpClass(Basic) DBKeySet : public TypeSet<DBKey>
99 {
100 public:
101 
102  inline DBKeySet() : TypeSet<DBKey>() {}
103  inline DBKeySet( const DBKeySet& oth )
104  : TypeSet<DBKey>(oth) {}
105  inline DBKeySet( size_type sz, DBKey ky )
106  : TypeSet<DBKey>(sz,ky) {}
107 
108  inline DBKeySet& operator =( const DBKeySet& oth )
109  { copy( oth ); return *this; }
110 
111  void addTo(BufferStringSet&) const;
112 };
113 
114 
115 mGlobal(Basic) inline BufferString toString( const DBKey& ky )
116 { return ky.toString(); }
117 mGlobal(Basic) inline uiString toUiString( const DBKey& ky )
118 { return ky.toUiString(); }
#define mExpClass(module)
Definition: commondefs.h:157
bool getFromString(int &, const char *, int udfval)
DBKeySet(const DBKeySet &oth)
Definition: dbkey.h:103
static DBKey udf()
Definition: dbkey.h:80
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:51
DBKeySet(size_type sz, DBKey ky)
Definition: dbkey.h:105
#define mGlobal(module)
Definition: commondefs.h:160
#define od_int64
Definition: plftypes.h:34
Definition: dbkey.h:98
GroupID DirID
Definition: dbkey.h:40
Definition: uistring.h:88
Set of BufferString objects.
Definition: bufstringset.h:25
int ObjNrType
Definition: groupedid.h:39
DBKey(const DBKey &oth)
Definition: dbkey.h:45
DirID dirID() const
Definition: dbkey.h:67
I size_type
Definition: typeset.h:29
Set of (small) copyable elements.
Definition: commontypes.h:26
DBKey(DirID dirid, ObjID oid=ObjID::getInvalid())
Definition: dbkey.h:47
void setEmpty()
Definition: dbkey.h:83
DBKey(DirNrType dnr, ObjNrType onr=-1)
Definition: dbkey.h:87
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:60
uiString toUiString(const DBKey &ky)
Definition: dbkey.h:117
BufferString toString(const DBKey &ky)
Definition: dbkey.h:115
static DBKey getInvalid()
Definition: dbkey.h:57
GroupNrType DirNrType
Definition: dbkey.h:41
void setDirID(DirID id)
Definition: dbkey.h:68
#define mDeprecated
Definition: plfdefs.h:213
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
bool isUdf() const
Definition: dbkey.h:82
BufferString * auxkey_
Definition: dbkey.h:91
virtual bool isInvalid() const
Definition: dbkey.h:63
Full key to any object in the OpendTect data store.
Definition: dbkey.h:36
void copy(TypeSetBase< T, I > &to, const TypeSetBase< S, I > &from)
Definition: typeset.h:221
DBKey()
Definition: dbkey.h:43
bool isEmpty() const
Definition: dbkey.h:81
DBKeySet()
Definition: dbkey.h:102
A unique identifier for an object consisting of a group and an ID within the group.
Definition: groupedid.h:34
bool hasValidDirID() const
Definition: dbkey.h:66
bool hasAuxKey() const
Definition: dbkey.h:75

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