OpendTect-6_4  6.4
Classes | Macros
Basic

Classes

class  ApplicationData
 
class  ArrayND< T >
 An ArrayND is an array with a given number of dimensions and a size. More...
 
class  Array1D< T >
 Array1D ( Subclass of ArrayND ) is a one dimensional array. More...
 
class  Array2D< T >
 Array2D ( Subclass of ArrayND ) is a two dimensional array. More...
 
class  Array3D< T >
 Array3D ( Subclass of ArrayND ) is a three dimensional array. More...
 
class  ArrayNDIter
 Iterates through all samples in an ArrayND. More...
 
class  ArrayNDValseriesAdapter< T >
 Adapter that makes any ArrayND to a (slow) value series. More...
 
class  ArrayNDDataExtracter< T >
 Gets a one dimensional array from an ArrayND. More...
 
class  ArrayImplBase< T >
 
class  Array1DImpl< T >
 Implementation of Array1D. More...
 
class  Array2DImpl< T >
 Implementation of Array2D. More...
 
class  Array3DImpl< T >
 Implementation of Array3D. More...
 
class  ArrayNDImpl< T >
 Implementation of ArrayND. More...
 
class  ArrayNDInfo
 Contains the information about the size of ArrayND, and in what order the data is stored (if accessable via a pointer). More...
 
class  Array1DInfo
 Contains the information about the size of Array1D, and in what order the data is stored (if accessable via a pointer). More...
 
class  Array2DInfo
 Contains the information about the size of Array2D, and in what order the data is stored (if accessable via a pointer). More...
 
class  Array3DInfo
 Contains the information about the size of Array3D, and in what order the data is stored (if accessable via a pointer). More...
 
class  Array1DInfoImpl
 Implementation of Array1DInfo. More...
 
class  Array2DInfoImpl
 Implementation of Array2DInfo. More...
 
class  Array3DInfoImpl
 Implementation of Array3DInfo. More...
 
class  ArrayNDInfoImpl
 Implementation of ArrayNDInfo. More...
 
class  ArrayNDSliceBase
 Base class of Array1DSlice and Array2DSlice. Access-tool to another ArrayND with higher dimensionality. More...
 
class  Array1DSlice< T >
 Subclass of Array1D and ArrayNDSliceBase. More...
 
class  Array2DSlice< T >
 Subclass of Array2D and ArrayNDSliceBase. More...
 
class  ArrayNDWrapper
 Access tool to another array with a lower number of dimensions. More...
 
class  Array3DWrapper< T >
 Subclass of ArrayNDWrapper. More...
 
class  ascbinostream
 writes to a stream that can be Ascii or Binary. More...
 
class  ascbinistream
 reads from a stream that was created in ascbinostream style. More...
 
class  ascostream
 OpendTect standard ascii format file writing. More...
 
class  ascistream
 OpendTect standard ascii format file reading. More...
 
class  Threads::Atomic< T >
 
class  Threads::AtomicPointer< T >
 Atomic instantiated with a pointer. The class really only handles the casting from a void* to a T*. More...
 
class  Threads::SpinLock
 Is an alternative to Mutex. It is a lock which causes a thread trying to acquire it to simply wait in a loop ("spin") while repeatedly checking if the lock is available. Because they avoid overhead from operating system process re-scheduling or context switching, spinlocks are efficient if threads are only likely to be blocked for a short period. More...
 
class  BinDataDesc
 Description of binary data. More...
 
class  BinID
 Positioning in a seismic survey: inline/crossline or lineNr/trcNr. More...
 
class  BinIDValue
 BinID and a value. More...
 
class  BinIDValues
 BinID and values. If one of the values is Z, make it the first one. More...
 
class  BufferString
 OD::String with its own variable length buffer. The buffer has a guaranteed minimum size. More...
 
class  BufferStringSet
 Set of BufferString objects. More...
 
class  CallBack
 CallBacks object-oriented (object + method). More...
 
class  CallBackSet
 TypeSet of CallBacks with a few extras. More...
 
class  NotifierAccess
 Interface class for Notifier. See comments there. More...
 
class  Notifier< T >
 
class  CallBacker
 To be able to send and/or receive CallBacks, inherit from this class. More...
 
class  CBCapsule< T >
 Capsule class to wrap any class into a CallBacker. More...
 
class  CNotifier< T, C >
 Notifier with automatic capsule creation. More...
 
class  NotifyStopper
 Temporarily disables a Notifier. More...
 
class  Color
 Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer, similar to Qt. More...
 
class  Values::Undef< Color >
 Undefined Color. More...
 
class  CommandLineParser
 
class  CompoundKey
 Concatenated short keys separated by dots. Used for Object identifiers in the Object Manager, or stratigraphic IDs. More...
 
class  Coord
 A cartesian coordinate in 2D space. More...
 
class  Coord3
 A cartesian coordinate in 3D space. More...
 
class  Values::Undef< Coord >
 Undefined Coord. More...
 
class  Values::Undef< Coord3 >
 Undefined Coord3. More...
 
class  Coords::CoordSystem
 
class  Coords::UnlocatedXY
 
class  Coords::AnchorBasedXY
 
class  DataPack
 A data packet: data+positioning and more that needs to be shared. More...
 
class  BufferDataPack
 Simple DataPack based on an unstructured char array buffer. More...
 
class  DataPackMgr
 Manages DataPacks. More...
 
class  ConstDataPackRef< T >
 
class  DataPackRef< T >
 
class  DateInfo
 A date info class. More...
 
class  DirList
 Provides file and directory names in a certain directory. More...
 
class  EnumDef
 Holds data pertinent to a certain enum. It does not know the enum values themselves, but treat them as integers. More...
 
class  EnumDefImpl< ENUM >
 
class  Executor
 Specification to enable chunkwise execution of a process. More...
 
class  ExecutorGroup
 Executor consisting of other executors. More...
 
class  TextTaskRunner
 TaskRunner to show progress of a Task in text format. More...
 
class  FactoryBase
 Base class for Factories ( Factory, Factory1Param, Factory2Param and Factory3Param. ) More...
 
class  Factory< T >
 Generalized static factory that can deliver instances of T, when no variable is needed in the creation. More...
 
class  Factory1Param< T, P >
 Generalized static factory that can deliver instances of T, when a variable is needed in the creation. More...
 
class  Factory2Param< T, P0, P1 >
 Subclass of FactoryBase. More...
 
class  Factory3Param< T, P0, P1, P2 >
 Subclass of FactoryBase. More...
 
class  File::ViewPars
 
class  FilePath
 File pathname tools. More...
 
class  FileSpec
 Specification for one or more files. More...
 
class  FixedString
 OD::String that holds an existing text string. More...
 
class  Values::Undef< FixedString >
 
class  Geom::Point2D< T >
 Basic point class. More...
 
class  Geom::Size2D< T >
 Basic 2D sizes (width/height) class. More...
 
class  Geom::Rectangle< T >
 Basic 2D rectangle class. More...
 
class  Geom::PixRectangle< T >
 Integer rectangle class. More...
 
class  Geom::PosRectangle< T >
 Floating-point rectangle class. More...
 
class  GlobExpr
 Glob-expression matching like UNIX shells. More...
 
class  HiddenParam< O, V >
 Workaround manager when you cannot add class members to a class due to binary compability issues. More...
 
class  IdxPair
 A pair of numbers; base class for BinID et al. More...
 
class  IndexInfo
 Info on (floating-point) position in an array or StepInterval. More...
 
class  IOPar
 Generalized set of parameters of the keyword-value type. More...
 
class  LatLong
 Geographical coordinates in Decimal Degrees but with conv to deg, min, sec. More...
 
class  LatLong2Coord
 Estimates to/from LatLong coordinates. More...
 
class  ManagedObjectSet< T >
 ObjectSet where the objects contained are owned by this set. More...
 
class  OD::ModDep
 Module Dependency. More...
 
class  OD::ModDepMgr
 Dependency manager - provides tools for the dependencies between the different OpendTect 'modules'. More...
 
class  MsgClass
 Class to encapsulate a message to the user. More...
 
class  MultiID
 Compound key consisting of ints. More...
 
class  NamedObject
 Object with a name. More...
 
class  NrBytesToStringCreator
 
class  ObjDisposer
 Disposes after a couple of msecs to avoid all kinds of trouble. More...
 
class  ObjectSet< T >
 Set of pointers to objects. More...
 
class  od_istream
 OD class for stream read. More...
 
class  od_ostream
 OD class for stream write common access to the user log file, or std::cout in batch progs. More...
 
class  od_stream
 OD base class for stream read/write. More...
 
class  od_istrstream
 OD class for streaming from string. More...
 
class  od_ostrstream
 OD class for stream write into string. More...
 
class  Values::Undef< float_complex >
 Undefined float_complex. More...
 
class  OD::RGBImage
 Class for Red, Green, Blue image. More...
 
class  OD::RGBImageLoader
 Class To load image files, and return the image data in RGBImage object. More...
 
class  MemSetter< T >
 Sets large amounts of values to a constant using multiple threads. More...
 
class  MemCopier< T >
 ValueSeries Copier. More...
 
class  MemValReplacer< T >
 Goes through some mem or a ValSeries and replaces one value with another. More...
 
class  OD::Platform
 Platform or Operating System. More...
 
class  OD::Set
 Base class for all sets used in OpendTect. More...
 
class  OD::String
 encapsulates the read-access-only part of strings in OD. More...
 
class  OS::CommandExecPars
 Specifies how to execute a command. More...
 
class  OS::MachineCommand
 Encapsulates an actual command to execute + the machine to run it on. More...
 
class  OS::CommandLauncher
 Launches machine commands. More...
 
class  ParallelTask
 Generalization of a task that can be run in parallel. More...
 
class  PerThreadObjectRepository< T >
 Class that keeps one object per thread. This enables temporary passing of objects (such as strings) where needed. More...
 
class  PluginManager
 Plugin manager - loads plugins: shared libs or DLLs. More...
 
class  Pos::IdxPair
 IdxPair with position indices; base class for BinID et al. More...
 
class  Pos::IdxPair2Coord
 Encapsulates linear transform from (i,j) index to (x,y) coordinates. More...
 
class  Pos::ValueIdxPair< IPT, FT >
 IdxPair with a value. More...
 
class  Pos::IdxPairValues< IPT, FT >
 IdxPair with 0-N values. More...
 
class  PosInfo::LineData
 Position info for a line - in a 3D cube, that would be an inline. Stored as (crossline-)number segments. More...
 
class  PosInfo::CubeDataPos
 Position in a CubeData. More...
 
class  PosInfo::CubeData
 Position info for an entire 3D cube. The LineData's are not sorted. More...
 
class  PosInfo::SortedCubeData
 Position info for an entire 3D cube. The LineData's are sorted. More...
 
class  PosInfo::CubeDataFiller
 Fills CubeData object. Requires inline- and crossline-sorting. More...
 
class  PosInfo::CubeDataIterator
 Iterates through CubeData. More...
 
class  PosInfo::Line2DPos
 One position on a 2D line. More...
 
class  PosInfo::Line2DPos3D
 Line2DPos with a z value. More...
 
class  PosInfo::Line2DData
 Position info for a 2D line. More...
 
class  PosInfo::Line2DDataIterator
 Iterates through Line2DData. More...
 
class  PosInfo::Line2DKey
 Key holding ID for both lineset and line. More...
 
class  PosInfo::Survey2D
 Repository for 2D line geometries. More...
 
class  ProgressMeter
 is an interface where processes can report their progress. More...
 
class  ProgressRecorder
 ProgressMeter that helps unifying different tasks. More...
 
class  TextStreamProgressMeter
 Textual progress indicator for batch programs. More...
 
class  PtrManBase< T >
 
class  PtrMan< T >
 
class  ConstPtrMan< T >
 
class  ArrPtrMan< T >
 
class  ConstArrPtrMan< T >
 
class  RefMan< T >
 
class  ConstRefMan< T >
 
class  OD::PythonAccess
 
class  QueueEntry< T >
 One single queue entry. More...
 
class  ObjQueue< T >
 Queue of objects. More...
 
class  TypeQueue< T >
 Queue of basic data types. More...
 
class  BasicInterval< T >
 Base class for Interval. Has no virtual functions and can hence be used in places where no virtual functions are allowed (e.g. large memcpy operations. Does not have sort, clone and scale functions. If you need then, use the Interval<T> instead. More...
 
class  Interval< T >
 Interval of values. More...
 
class  StepInterval< T >
 Interval with step. More...
 
class  IntervalND< T >
 Class to store ranges in N dimensions. More...
 
class  ReferenceCounter
 
class  Repos::FileProvider
 
class  Repos::IOPar
 IOPar with its Repos Source. More...
 
class  Repos::IOParSet
 Set of Repos::IOPar with each a unique name for user recognistion. More...
 
class  RowCol
 IdxPair used for its row() and col(). More...
 
class  SafeFileIO
 Protects file IO when you can't afford to have partly written things after write errors or have a file garbled by multiple access. More...
 
class  SamplingData< T >
 Holds the fundamental sampling info: start and interval. More...
 
class  Selector< T >
 Interface for classes that select on basis of a key. More...
 
class  SingleSelector< T >
 Selector selecting only a single value. More...
 
class  RangeSelector< T >
 Selector based on range specification (an Interval). More...
 
class  ArraySelector< T >
 Selector based on array. More...
 
class  SeparString
 List encoded in a string. More...
 
class  FileMultiString
 SeparString with backquotes as separators, use in most ascii files. More...
 
class  Settings
 Settings class holds the user settings. It is an IOPar. More...
 
class  SettingsAccess
 Functionality to access specific user settings and/or environment variables from different parts of OpendTect in order to avoid duplication of definitions and code. More...
 
class  SharedLibAccess
 Gives access to shared libs on runtime. Plugins should be loaded via the Plugin Manager (see plugins.h). More...
 
class  SignalHandling
 Asynchronous event handling and notification. More...
 
class  StreamData
 Holds data to use and close an iostream. More...
 
class  StreamProvider
 Provides I/O stream for file or system command. More...
 
class  Survey::Geometry
 A Geometry which holds trace positions. More...
 
class  Survey::GeometryManager
 Makes geometries accessible from a geometry ID, or a MultiID. More...
 
class  Survey::GeometryReader
 
class  Survey::GeometryWriter
 
class  Survey::Geometry2D
 Geometry of a 2D Line. More...
 
class  Survey::Geometry3D
 Scaled down survey geometry for an inl/crl geometry. More...
 
class  SurveyInfo
 Holds survey general information. More...
 
class  Task
 Generalization of something (e.g. a computation) that needs to be done in multiple steps. More...
 
class  TaskGroup
 A collection of tasks, that behave as a single task. More...
 
class  SequentialTask
 The generalization of something (e.g. a computation) where the steps must be done in sequence, i.e. not in parallel. More...
 
class  TaskRunner
 Class that can execute a task. More...
 
class  TextTranslateMgr
 
class  TextTranslatorLanguage
 
class  Threads::Mutex
 Is a lock that allows a thread to have exlusive rights to something. More...
 
class  Threads::ConditionVar
 Is an object that faciliates many threads to wait for something to happen. More...
 
class  Threads::ReadWriteLock
 Lock that permits multiple readers to lock the object at the same time, but it will not allow any readers when writelocked, and no writelock is allowed when readlocked. More...
 
class  Threads::MutexLocker
 
class  Threads::ReadLockLocker
 
class  Threads::WriteLockLocker
 
class  Threads::Barrier
 Waits for a number of threads to reach a certain point (i.e. the call to Barrier::waitForAll). Once everyone has arrived, everyone is released. More...
 
class  Threads::Thread
 Is the base class for all threads. Start it by creating it and give it the function or CallBack to execute. More...
 
class  Threads::Lock
 A lock of a type that (hopefully) suits your needs. To use it, you need the Locker class. More...
 
class  Threads::Locker
 Locks the lock, shutting out access from other threads if needed. More...
 
class  Threads::WorkManager
 Takes work and puts it on a queue for execution either in parallel, singlethread or manual. More...
 
class  Threads::Work
 The abstraction of something that can be done. It can be an ordinary CallBack, a static function (must return bool) or a TaskFunction on a CallBackerinheriting class, or a Task. The three examples are shown below. More...
 
class  Time::Counter
 
class  Timer
 Timer class. More...
 
class  TrcKey
 Represents a unique trace position in one of the surveys that OpendTect is managing. More...
 
class  TrcKeySampling
 Horizontal sampling (inline and crossline range and steps). More...
 
class  TrcKeySamplingSet
 
class  TrcKeySamplingIterator
 Finds next BinID in TrcKeySampling; initializes to first position. More...
 
class  TrcKeyValue
 
class  TrcKeyCollection
 
class  SampledTrcKeyCollection
 
class  TableTrcKeySelection
 
class  TrcKeyZSampling
 Hor+Vert sampling in 3D surveys. More...
 
class  TrcKeyZSamplingSet
 
class  TypeSetBase< T, I >
 Base class for TypeSet, usually not used as such. More...
 
class  TypeSet< T >
 Set of (small) copyable elements. More...
 
class  BoolTypeSetType
 Needed because the std lib has a crazy specialisation vector<bool>. More...
 
class  LargeValVec< T >
 Large Value Vector. More...
 
class  uiString
 
class  uiStringSet
 
class  uiRetVal
 
class  uiStrings
 
class  Values::Undef< T >
 Templatized undefined values. More...
 
class  Values::Undef< short >
 Undefined od_int16. More...
 
class  Values::Undef< unsigned short >
 Undefined od_uint16. More...
 
class  Values::Undef< int >
 Undefined od_int32. More...
 
class  Values::Undef< unsigned int >
 Undefined od_uint32. More...
 
class  Values::Undef< int64_t >
 Undefined od_int64. More...
 
class  Values::Undef< uint64_t >
 Undefined od_uint64. More...
 
class  Values::Undef< bool >
 Undefined bool. More...
 
class  Values::Undef< float >
 Undefined float. More...
 
class  Values::Undef< double >
 Undefined double. More...
 
class  Values::Undef< const char * >
 Undefined const char*. More...
 
class  Values::Undef< char * >
 Undefined char*. More...
 
class  Values::Undef< char >
 Undefined char. More...
 
class  ValueSeries< T >
 Interface to a series of values. More...
 
class  OffsetValueSeries< T >
 ValueSeries of offsets. More...
 
class  ArrayValueSeries< RT, AT >
 Series of values from a pointer to some kind of array. If a more advanced conversion between the return type and the array type is wanted, use ConvValueSeries instead. More...
 
class  MultiArrayValueSeries< RT, AT >
 Valueseries that allocates its data in smaller chunks. By doing this, it performs better in environments where the memory is fragmented (i.e. windows 32 bit). Default chunk size for windows 32 bit is 512MB and for all other platforms default is 32 GB. More...
 
class  ValueSeriesGetAll< T >
 Gets ValueSeries. More...
 
class  VectorAccess< T, I >
 Simple vector-based container simplifying index-based work. More...
 
class  ZDomain::Def
 Definition of z-domain. More...
 
class  ZDomain::Info
 Information of z-domain. More...
 
class  std::fixedstreambuf
 Adapter to use a fixed buffer as a stream. More...
 
class  qstreambuf
 Adapter to use a qprocess as a stream. More...
 
class  iqstream
 Does everything a std::istream does, but also deletes the streambuf. More...
 
class  oqstream
 Does everything a std::ostream does, but also deletes the streambuf. More...
 
class  std::winfilebuf
 Adapter to seek in filebuffers on win64. More...
 
class  std::winifstream
 Adapter for input streams on win64. More...
 
class  std::winofstream
 Adapter for output streams on win64. More...
 

Macros

#define mCBCapsuleGet(T, var, cb)   CBCapsule<T>* var = dynamic_cast< CBCapsule<T>* >( cb );
 Unpacking data from capsule. More...
 
#define mDoArrayPtrOperation(type, arr, operation, arrsz, ptrinc)
 
#define mDeclareEnumUtils(enm)
 Some utilities surrounding the often needed enum <-> string table. More...
 
#define mLockerClassImpl(mod, clssnm, clss, lockfn, unlockfn, trylockfn)
 Is an object that is convenient to use when a mutex should be locked and unlocked automatically when returning. More...
 

Detailed Description

Basic, general purpose utilities.

Introduction

This module handles all things that are so basic to all other modules that they can be seen as a layer of common services to the entire system. One of the tasks is to provide platform-independence of file, date&time, threads, and more.

The difference with the 'General' module was, traditionally, that Basic utilities could in principle be insteresting outside OpendTect. This distinction is not enforced (see e.g. the survey info class). We place things in Basic that feel more basic than General. Note that General depends on Basic, not vice versa. Basic algorithm-type things go in Algo.

You'll find that many of these tools can be found in other packages in some form or another. But, the problems of management of dependencies are usually much bigger than having to maintain a bunch of lean-and-mean specially made objects that do selected things in a way that fits our system.

Content

We'll just name a few groups of services. There are many more isolated useful objects, defines, functions and so forth.

Reference Counting

Reference counter is an integer that tracks how many references have been made to a class. When a reference-counted object is created, the reference count is 0. When the ref() function is called, it is incremented, and when unRef() is called it is decremented. If it then reaches 0, the object is deleted.

Example usage

A refcount class is set up by:

class A
{
public:
//Your class stuff
};

This expands to a number of class variables and functions:

public:
void A::ref() const;
void A::unRef() const;
void A::unRefNoDelete() const;
//For debugging only Don't use
bool A::refIfReffed() const;
int A::nrRefs() const;
private:
virtual void A::refNotify() const {}
virtual void A::unRefNotify() const {}
virtual void A::unRefNoDeleteNotify() const {}
mutable ReferenceCounter A::refcount_;
protected:
A::~A();

The macro will define a protected destructor, so you have to implement one (even if it's a dummy {}).

If you don't want a destructor on your class use the mRefCountImplNoDestructor instead:

class A
{
public:
//Your class stuff
};

unRefNoDelete

The unRefNoDelete() is only used when you want to bring the class back to the original state of refcount==0. Such an example may be a static create function:

A* createA()
{
A* res = new A;
res->ref(); //refcount goes to 1
fillAWithData( res ); //May do several refs, unrefs
res->unRefNoDelete(); //refcount goes back to 0
return res;
}

ObjectSet with reference counted objects

ObjectSets with ref-counted objects can be modified by either:

Smart pointers ot reference counted objects.

A pointer management is handled by the class RefMan, which has the same usage as PtrMan.

Reference counted objects on the stack

Reference counted object cannot be used directly on the stack, as they have no public destructor. Instead, use the RefMan:

RefMan<A> variable = new A;

Macro Definition Documentation

#define mCBCapsuleGet (   T,
  var,
  cb 
)    CBCapsule<T>* var = dynamic_cast< CBCapsule<T>* >( cb );

Unpacking data from capsule.

If you have a pointer to a capsule cb, this:

1 mCBCapsuleUnpack(const uiMouseEvent&,ev,cb)

would result in the availability of:

1 const uiMouseEvent& ev

If you're interested in the caller, you'll need to get the capsule itself:

1 mCBCapsuleGet(const uiMouseEvent&,caps,cb)

would result in the availability of:

1 CBCapsule<const uiMouseEvent&>* caps
#define mDeclareEnumUtils (   enm)
Value:
public: \
static const EnumDefImpl<enm>& enm##Def(); \
static const char** enm##Names();\
static bool parseEnum##enm(const char*,enm&); /*legacy */ \
static bool parseEnum(const char*,enm&); \
static bool parseEnum(const IOPar&,const char*,enm&); \
static enm parseEnum##enm(const char*); \
static const char* toString(enm); \
static uiString toUiString(enm); \
static const char* get##enm##String(enm); /*legacy */ \
protected: \
static const char* enm##Keys_[]; \
static ConstPtrMan<EnumDefImpl<enm> > enm##Definition_; \
public:
Export_Basic uiString toUiString(ViewStyle)
Definition: uistring.h:89
Definition: enums.h:86
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
Export_Basic bool parseEnum(const IOPar &, const char *, ViewStyle &)
Export_Basic const char * toString(ViewStyle)
Definition: ptrman.h:101

Some utilities surrounding the often needed enum <-> string table.

The function EnumDef::convert returns the enum (integer) value from a text string. The first arg is string you wish to convert to the enum, the second is the array with enum names. Then, the integer value of the first enum value (also returned when no match is found) and the number of characters to be matched (0=all). Make absolutely sure the char** definition has a closing ' ... ,0 };'.

Normally, you'll have a class with an enum member. In that case, you'll want to use the EnumDef classes. These are normally almost hidden by a few simple macros: mDeclareEnumUtils(enm) will make sure the enum will have a string conversion mDefineEnumUtils(clss,enm,prettynm) defines the names. For namespaces, you can use mDeclareNameSpaceEnumUtils only

The 'Declare' macros should be placed in the public section of the class. Example of usage:

in myclass.h:

1 #include <enums.h>
2 
3 class MyClass
4 {
5 public:
6  enum State { Good, Bad, Ugly };
7  mDeclareEnumUtils(State)
8  enum Type { Yes, No, Maybe };
9  mDeclareEnumUtils(Type)
10 
11  // rest of class
12 };

in myclass.cc:

1 #include <myclass.h>
2 
3 mDefineEnumUtils(MyClass,State,"My class state")
4  { "Good", "Bad", "Not very handsome", 0 };
5 mDefineEnumUtils(MyClass,Type,"My class type")
6  { "Yes", "No", "Not sure", 0 };

Note the '1' in the first one telling the EnumDef that only one character needs to be matched when converting string -> enum. The '0' in the second indicates that the entire string must match.

This will expand to (added newlines, removed some superfluous stuff:

1 class MyClass
2 {
3 public:
4 
5  enum State { Good, Bad, Ugly };
6  static const EnumDef& StateDef();
7  static const char** StateNames();
8  static bool parseEnum(const char*, State& );
9  static bool parseEnum(const IOPar&,const char*key,State&);
10  static int parseEnumState(const char*);
11  static const char* toString(State);
12  static uiString toUiString(State);
13 
14 protected:
15 
16  static const char* StateKeys_[];
17  static const EnumDef StateDefinition_;
18 
19 // similar for Type
20 
21 };

and, in myclass.cc:

1 const EnumDef& MyClass::StateDef() { return StateDefinition_; }
2 
3 const EnumDef MyClass::StateDefinition_("My class state",
4  MyClass::Statenames,1);
5 
6 bool MyClass::parseEnum(const char* txt, State& res ) \
7 { \
8  const int idx = StateDef().isValidName( txt ) \
9  ? StateDef().convert( txt ) \
10  : -1; \
11  if ( idx<0 ) \
12  return false; \
13  \
14  res = (State) idx; \
15  return true; \
16 } \
17 bool MyClass::parseEnum( const IOPar& par, const char* key, State& res ) \
18 { return parseEnum( par.find( key ), res ); } \
19 MyClass::State MyClass::parseEnumState(const char* txt) \
20 { \
21  return (MyClass::State) StateDef().convert( txt ); \
22 } \
23 
24 const char* MyClass::StateKeys_[] =
25  { "Good", "Bad", "Not very handsome", 0 };
26 
27 
28 const EnumDef& MyClass::TypeDef() { return TypeDefinition_; }
29 const EnumDef MyClass::TypeDefinition_("My class type",MyClass::Typenames, 0);
30 bool MyClass::parseEnum(const char* txt, Type& res ) \
31 { \
32  const int idx = TypeDef().isValidName( txt ) \
33  ? TypeDef().convert( txt ) \
34  : -1; \
35  if ( idx<0 ) \
36  return false; \
37  \
38  res = (Type) idx; \
39  return true; \
40 } \
41 bool MyClass::parseEnum( const IOPar& par, const char* key, Type& res ) \
42 { return parseEnum( par.find( key ), res ); } \
43 MyClass::Type MyClass::parseEnumType(const char* txt) \
44 { \
45  return (MyClass::Type) TypeDef().convert( txt ); \
46 } \
47 
48 const char* MyClass::TypeKeys_[] =
49  { "Yes", "No", "Not sure", 0 };

Localization is separated from the selection. Hence, if you wish to add translated enum-strings, you can implement your own init() function:

1 template <>
2 void EnumDefImpl<MyClass::Type>::init()
3 {
4  uistrings_ += tr("Yes");
5  uistrings_ += tr("No");
6  uistrings_ += tr("Not sure");
7 }

Note that the selection will still be done on the non-translated string.

#define mDoArrayPtrOperation (   type,
  arr,
  operation,
  arrsz,
  ptrinc 
)
Value:
{ \
type* __curptr = arr; \
for ( const type* __stopptr = __curptr + arrsz; \
__curptr!=__stopptr; \
__curptr ptrinc ) \
{ \
*__curptr operation; \
} \
}

\ . Quicker than for-loops.

Instead of:

1 for ( int idx=0; idx<arrsz; idx++ )
2  arr[idx] /= 5;

You can do:

1 mDoArrayPtrOperation( float, arr, /= 5, arrsz, ++ );

Note that the last '++' is applied to the 'current' pointer called __curptr.

#define mLockerClassImpl (   mod,
  clssnm,
  clss,
  lockfn,
  unlockfn,
  trylockfn 
)
Value:
mExpClass(mod) clssnm \
{ \
public: \
clssnm( clss& thelock, bool wait=true ) \
: lock_( thelock ) \
, islocked_( true ) \
{ \
if ( wait ) thelock.lockfn; \
else islocked_ = thelock.trylockfn; \
} \
\
~clssnm() { if ( islocked_ ) lock_.unlockfn; } \
bool isLocked() const { return islocked_; } \
\
void unLock() { islocked_ = false; lock_.unlockfn; } \ \
void lock() { islocked_ = true; lock_.lockfn; } \ \
\
protected: \
\
clss& lock_; \
bool islocked_; \
};
#define mExpClass(module)
Definition: commondefs.h:160

Is an object that is convenient to use when a mutex should be locked and unlocked automatically when returning.

Example:

int function() { MutexLocker lock( myMutex ); Do whatever you want to do }


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