[OpendTect_Developers] IOObjs, IOM() and IOObjContext

Bert Bril bert at opendtect.org
Wed Dec 15 11:15:55 CET 2010


Hi all,


First of all, sorry for the spam yesterday. It came through because it
they used my e-mail address as 'From' (the bastards). We have now
tightened the moderation so everyone is being moderated, even the list
moderators (that's Nanne and me) ...


Anyway - if you need to access objects in the data store, you'll often
get in contact with the infamous 'IOObj'. This is one of the oldest
objects in OpendTect. I just did some re-working and clean-up there the
past days, but it will never become a modern, vibrant object. (BTW don't
include 'ioobject.h', but 'ioobj.h' - 'ioobject.h' will merge into
'ioobj.h' in 4.3.)

The idea behind the IOObj system is to store stuff about actual data,
rather than the data itself. It's put in a (sort-of) flat-files database
(the '.omf' files). Stored is stuff like format, file name, object type,
etc. For objects stored in data files, the 'IOStream' subclass holds
what's needed. You can also subclass IOObj yourself if you need to
access, for example, databases. Then, there is no file name but maybe
username/password and table keys.

Every object has a unique key, a MultiID. For example "100010.23" or
"808080.3". You can get the key with IOObj::key(). When you need a
'text' reference to an object, this is what you use. You usually get an
IOObj instance from uiIOObjSel et al (uiIo/uiiobjsel.h), but if you have
a MultiID key, you turn to the IOM() (the single-instance manager object):

IOObj* ioobj = IOM().get( the_key );
// use IOObj here
delete ioobj;

The 'database' is subdivided in different subdirectories, like
'Seismics', 'WellInfo', 'Surfaces', etc. Each have their own base of the
MultiID, for example Seismics is "100010". To select objects of a
certain type, you have to give this ID and other context to the IOObj
selector. The class for that is IOObjContext. Many things can be set,
like what sub-types to include or exclude, whether it's for read or for
write, and so forth. Such contexts are never made from scratch, you
always ask a 'TranslatorGroup' to make it. Example:

#include "emsurfacetr.h"
#include "uiioobjsel.h"

IOObjContext ctxt( mIOObjContext(EMHorizon3D) );
ctxt.forread = true;
horselfld_ = new uiIOObjSel( 0, ctxt );


That sets up a field that allows the user to select a 3D horizon. You
get the IOObj you need with:

const IOObj* horioobj = horselfld_->ioobj();
if ( !horioobj ) return false;

(how to then get the actual horizon can be seen in the uiTut plugin).



time to stop.

/Bert

-- 
-- Bert Bril / OpendTect developer at dGB
-- mailto:Bert.Bril at opendtect.org , http://opendtect.org





More information about the Developers mailing list