23 #include "generalmod.h" 34 #define mdTectKey "dTect" 36 #define mObjSelUnrelated 0 37 #define mObjSelRelated 1 38 #define mObjSelMatch 2 60 TranslatorGroup(
const char* clssnm );
64 virtual Translator* make(
const char*,
bool usrnm)
const;
65 const Translator* getTemplate(
const char*,
bool usrnm)
const;
70 virtual int objSelector(
const char*)
const = 0;
73 bool hasConnType(
const char*)
const;
79 static TranslatorGroup& getGroup(
const char* nm);
80 static bool hasGroup(
const char* nm);
81 static void clearSelHists();
85 static TranslatorGroup& addGroup(TranslatorGroup*);
90 virtual const char* getSurveyDefaultKey(
const IOObj* = 0)
const;
92 virtual const char* translationApplication()
const;
126 Translator(
const char* nm,
const char* usr_nm);
143 virtual const char*
connType()
const;
154 virtual const char*
iconName()
const {
return "od"; }
174 #define mImplTranslatorInitClass( spec, clss, usrnm ) \ 176 spec##clss##Translator* tr = new spec##clss##Translator( #spec, usrnm ); \ 177 clss##TranslatorGroup::theInst().add( tr ); \ 180 #define mImplTranslatorGroupTheInst( clss ) \ 182 mDefineStaticLocalObject(RefMan<TranslatorGroup>, inst, \ 183 = &TranslatorGroup::addGroup( new clss##TranslatorGroup ));\ 189 #define isTranslatorGroupBody(clss) \ 191 ~clss##TranslatorGroup() {} \ 193 static int selector(const char*); \ 194 static void initClass() { theInst(); } \ 195 static const IOObjContext& ioContext(); \ 196 static FixedString sGroupName(); \ 197 static uiString sTypeName(int num=1); \ 198 virtual FixedString groupName() const { return sGroupName(); } \ 199 virtual uiString typeName(int num=1) const \ 200 { return sTypeName(num); } \ 201 virtual const IOObjContext& ioCtxt() const { return ioContext(); } \ 202 virtual int objSelector( const char* s ) const { return selector(s); } \ 203 static TranslatorGroup& theInst() 206 #define isTranslatorGroup( clss ) \ 207 mTextTranslationClass( clss##TranslatorGroup, \ 208 clss##TranslatorGroup::theInst().translationApplication() ) \ 209 isTranslatorGroupBody(clss); 211 #define isTranslatorGroupWithInst( clss ) \ 212 isTranslatorGroupBody( clss ) \ 213 mImplTranslatorGroupTheInst( clss ) 217 #define isTranslatorBody(spec,clss) \ 219 Translator* getNew() const \ 221 Translator* trans = new spec##clss##Translator(typeName().buf(), \ 223 trans->setGroup( group_ ); return trans; \ 225 static spec##clss##Translator* getInstance(); \ 226 static const char* translKey(); \ 227 static void initClass() 230 #define isTranslator( spec, clss ) \ 231 isTranslatorBody( spec, clss ); 233 #define mIsTranslatorWithInitClass( spec, clss, usrnm ) \ 234 isTranslatorBody(spec, clss) \ 235 mImplTranslatorInitClass(spec, clss, usrnm ) 238 #define defineTranslatorGroup(clss,groupname) \ 239 FixedString clss##TranslatorGroup::sGroupName() \ 240 { return groupname; } \ 241 TranslatorGroup& clss##TranslatorGroup::theInst() \ 242 mImplTranslatorGroupTheInst( clss ) 245 #define defineTranslator(spec,clss,usrnm) \ 246 spec##clss##Translator* spec##clss##Translator::getInstance() \ 247 { return new spec##clss##Translator(#clss,usrnm); } \ 248 const char* spec##clss##Translator::translKey() { return usrnm; } \ 249 void spec##clss##Translator::initClass() \ 250 mImplTranslatorInitClass( spec, clss, usrnm ) 255 #define mDefEmptyTranslatorGroupConstructor(clss) \ 256 clss##TranslatorGroup() \ 257 : TranslatorGroup(#clss) {} 261 #define mDefEmptyTranslatorBaseConstructor(clss) \ 262 clss##Translator( const char* nm, const char* unm ) \ 263 : Translator(nm,unm) {} 267 #define mDefEmptyTranslatorConstructor(spec,clss) \ 268 spec##clss##Translator( const char* nm, const char* unm ) \ 269 : clss##Translator(nm,unm) {} 274 #define mDeclEmptyTranslatorBundle(mod,clss,fmt,defext) \ 275 mExpClass(mod) clss##TranslatorGroup : public TranslatorGroup \ 276 { isTranslatorGroup(clss) \ 277 mDefEmptyTranslatorGroupConstructor(clss) \ 278 const char* defExtension() const { return defext; } \ 281 mExpClass(mod) clss##Translator : public Translator \ 283 mDefEmptyTranslatorBaseConstructor(clss) \ 286 mExpClass(mod) fmt##clss##Translator : public clss##Translator \ 287 { isTranslator(fmt,clss) \ 288 mDefEmptyTranslatorConstructor(fmt,clss) \ 294 #define mDefSimpleTranslatorInstances(clss,usrnm,fmt) \ 295 defineTranslatorGroup(clss,usrnm) \ 296 uiString clss##TranslatorGroup::sTypeName(int) { return toUiString(usrnm); } \ 297 defineTranslator(fmt,clss,#fmt) 301 #define mDefSimpleTranslatorSelector(clss) \ 302 int clss##TranslatorGroup::selector( const char* s ) \ 303 { return defaultSelector(clss##TranslatorGroup::sGroupName(),s); } 308 #define mDefSimpleTranslatorioContextWithExtra(clss,stdtyp,extra) \ 309 const IOObjContext& clss##TranslatorGroup::ioContext() \ 311 mDefineStaticLocalObject( PtrMan<IOObjContext>, ctxt, = nullptr ); \ 314 ctxt = new IOObjContext( nullptr ); \ 315 ctxt->stdseltype_ = IOObjContext::stdtyp; \ 318 ctxt->trgroup_ = &theInst(); \ 324 #define mDefSimpleTranslatorioContext(clss,stdtyp) \ 325 mDefSimpleTranslatorioContextWithExtra(clss,stdtyp,) 330 #define mDefSimpleTranslators(clss,usrnm,fmt,stdtyp) \ 331 mDefSimpleTranslatorSelector(clss)\ 332 mDefSimpleTranslatorInstances(clss,usrnm,fmt) \ 333 mDefSimpleTranslatorioContext(clss,stdtyp) 338 #define mDefSimpleTranslatorsWithCtioExtra(clss,usrnm,fmt,stdtyp,extra) \ 339 mDefSimpleTranslatorInstances(clss,usrnm,fmt) \ 340 mDefSimpleTranslatorSelector(clss) \ 341 mDefSimpleTranslatorioContextWithExtra(clss,stdtyp,extra) 347 #define mDefSimpleTranslatorsWithSelKey(clss,usrnm,fmt,stdtyp,selky) \ 348 mDefSimpleTranslatorsWithCtioExtra(clss,usrnm,fmt,stdtyp, \ 349 ctxt->selkey_ = selky) 354 #define mIOObjContext(trgrp) \ 355 trgrp##TranslatorGroup::ioContext() 357 #define mTranslGroupName(trgrp) \ 358 trgrp##TranslatorGroup::sGroupName() 360 #define mTranslTemplInstance(trgrp,tr) \ 361 (*trgrp##TranslatorGroup::theInst() \ 362 .getTemplate(tr##trgrp##Translator::translKey(),true)) 364 #define mTranslCreate(trgrp,tr) \ 365 (trgrp##Translator*)trgrp##TranslatorGroup::theInst().make(tr) 367 #define mTranslKey(trgrp,tr) \ 368 tr##trgrp##Translator::translKey() 370 #define mMkCtxtIOObj(trgrp) \ 371 new CtxtIOObj(trgrp##TranslatorGroup::ioContext()) 373 #define mSelHist(trgrp) \ 374 trgrp##TranslatorGroup::theInst().selHist() #define mRefCountImpl(ClassName)
Macro to setup a class with destructor for reference counting.
Definition: refcount.h:163
#define mExpClass(module)
Definition: commondefs.h:160
virtual bool isUserSelectable(bool forread=true) const
Definition: transl.h:150
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
virtual const char * connType() const
virtual const char * iconName() const
Definition: transl.h:154
static uiString sNoIoobjMsg()
#define mODTextTranslationClass(clss)
Definition: uistring.h:38
#define mGlobal(module)
Definition: commondefs.h:163
OD::String that holds an existing text string.
Definition: fixedstring.h:29
virtual bool implExists(const IOObj *, bool forread) const
virtual void usePar(const IOPar &)
Definition: transl.h:144
virtual Translator * getNew() const =0
const OD::String & typeName() const
Definition: transl.h:129
const OD::String & clssName() const
Definition: transl.h:96
static const ObjectSet< TranslatorGroup > & groups()
Definition: transl.h:78
BufferString clssname_
Definition: transl.h:98
Definition: uistring.h:89
const TranslatorGroup * group() const
Definition: transl.h:131
const OD::String & userName() const
Definition: transl.h:130
BufferString usrname_
Definition: transl.h:161
virtual bool implManagesObjects(const IOObj *) const
ObjectSet< const Translator > templs_
Definition: transl.h:99
Group of Translators. Has a static factory.
Definition: transl.h:56
virtual bool implRemove(const IOObj *) const
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
virtual const char * defExtension() const
Definition: transl.h:74
static uiString sBadConnection()
virtual const char * defExtension() const
Definition: transl.h:145
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:31
TranslatorGroup * group_
Definition: transl.h:162
BufferString typname_
Definition: transl.h:160
virtual bool implSetReadOnly(const IOObj *, bool) const
void setDefTranslIdx(int i)
Definition: transl.h:88
int deftridx_
Definition: transl.h:100
I/O Interpreter class for a certain object type.
Definition: transl.h:123
virtual IOObj * createWriteIOObj(const IOObjContext &, const MultiID &) const
uiString sSelObjectIsWrongType()
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
void setGroup(TranslatorGroup *g)
Definition: transl.h:148
static const Translator * getTemplateInstance(const char *displayname)
int defTranslIdx() const
Definition: transl.h:87
virtual bool implRename(const IOObj *, const char *, const CallBack *cb=0) const
int defaultSelector(const char *, const char *)
const ObjectSet< const Translator > & templates() const
Definition: transl.h:67
CallBacks object-oriented (object + method).
Definition: callback.h:57
IOPar * selhist_
Definition: transl.h:101
virtual mODTextTranslationClass(Translator) public ~Translator()
Definition: transl.h:127
const char * getDisplayName() const
"username [group]"
Compound key consisting of ints.
Definition: multiid.h:25
virtual bool implReadOnly(const IOObj *) const
Holds the context for selecting and/or creating IOObjs.
Definition: ctxtioobj.h:62