syscls.odl

00001 /* 
00002    EyeDB Object Database Management System
00003    Copyright (C) 1994-1999,2004,2005 SYSRA
00004    
00005    EyeDB is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009    
00010    EyeDB is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014    
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with this library; if not, write to the Free Software
00017    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA 
00018 */
00019 
00020 /*
00021    Author: Eric Viara <viara@sysra.com>
00022 */
00023 
00024 
00025 //
00026 //
00027 // syscls.odl
00028 //
00029 // All system classes which are part of eyedb kernel, but that are not
00030 // defined in the native mode:
00031 //
00032 //  executable (method, trigger)
00033 //  constraint (key, notnull, checkconstraint)
00034 //  class variables
00035 //  index
00036 //  protection
00037 //
00038 //
00039 
00040 #define INDEX
00041 
00042 class attribute_component [AttributeComponent] {
00043   string name;
00044   string attrpath;
00045   class *class_owner;
00046   bool #propagate;
00047   %C++{
00048     virtual Status m_trace(FILE *, int, unsigned int, const RecMode *) const;
00049     Status checkUnique(const char *, const char *);
00050     Status find(Database *db, const Class *cls,
00051                 AttributeComponent *&);
00052     virtual AttributeComponent *xclone(Database *, const Class *);
00053     std::string makeAttrpath(const Class *cls);
00054     void userInitialize();
00055     void userCopy(const Object &);
00056     void userGarbage();
00057     virtual int getInd() const;
00058     %}
00059 };
00060 
00061 class attribute_component_set [AttributeComponentSet] {
00062   string attrname;
00063   set<attribute_component *> comps;
00064   class *class_owner;
00065   %C++{
00066     void userInitialize();
00067     void userCopy(const Object &);
00068     void userGarbage();
00069 
00070     Status find(const char *, Index *&);
00071     Status find(const char *, NotNullConstraint *&);
00072     Status find(const char *, UniqueConstraint *&);
00073     Status find(const char *, CollAttrImpl *&);
00074     Status find(const char *, CardinalityConstraint_Test *&);
00075     Status getAttrComponents(const Class *, LinkedList &);
00076     Status hasIndex(bool &has_index, std::string &idx_str);
00077 
00078   private:
00079     struct Cache {
00080       unsigned int comp_count;
00081       unsigned int comp_alloc;
00082       struct Comp {
00083         char *attrpath;
00084         AttributeComponent *comp;
00085         Comp();
00086         ~Comp();
00087       } *comps;
00088       Cache();
00089       void add(AttributeComponent *);
00090       void getComponents(const char *, int, LinkedList &);
00091       AttributeComponent *find(const char *attrpath);
00092       ~Cache();
00093     };
00094 
00095     Status makeCache();
00096     void invalidateCache();
00097 
00098     Cache *index_cache, *notnull_cache, *unique_cache, *card_cache, *collimpl_cache;
00099     friend class Attribute;
00100     %}
00101 };
00102 
00103 // ---------------------------------------------------------------------------
00104 //
00105 // Class & Agregat Components
00106 //
00107 // ---------------------------------------------------------------------------
00108 
00109 class class_component [ClassComponent] {
00110   class *class_owner;
00111   string name;
00112 
00113   %C++{
00114     virtual Status check(Class *) const;
00115     virtual Bool   isInherit() const;
00116     virtual Status m_trace(FILE *, int, unsigned int, const RecMode *) const;
00117     virtual int getInd() const;
00118     virtual Status make(Class *);
00119     virtual Status realize(const RecMode* = NoRecurs);
00120     virtual Status remove(const RecMode* = NoRecurs);
00121     virtual Status realize_for_update();
00122     virtual Status remove_for_update();
00123     %}
00124 };
00125 
00126 class agregat_class_component [AgregatClassComponent] extends class_component {
00127 };
00128 
00129 class class_variable [ClassVariable]  extends class_component {
00130   string vname;
00131   object *val;
00132 
00133   %C++{
00134     Status check(Class *) const;
00135     Bool   isInherit() const;
00136     Status m_trace(FILE *, int, unsigned int, const RecMode *) const;
00137     int getInd() const;
00138     Status m_trace(FILE *, int, unsigned int, const RecMode *);
00139     %}
00140 };
00141 
00142 // ---------------------------------------------------------------------------
00143 //
00144 // Indexes
00145 //
00146 // ---------------------------------------------------------------------------
00147 
00148 class #index [Index] extends attribute_component {
00149   oid idx_oid;
00150   short dspid;
00151   bool is_string;
00152   int impl_hints[];
00153 
00154   %C++{
00155     Index(Database *, const char *, const char *);
00156     virtual   Status realize(const RecMode* = NoRecurs);
00157     virtual   Status remove(const RecMode* = NoRecurs);
00158     virtual   Status s_trace(FILE *, Bool, unsigned int flags = 0) const;
00159     Idx    *idx;
00160     Status makeDataspace(Database *db, const Dataspace *&) const;
00161 
00162     void userInitialize();
00163     void userCopy(const Object &);
00164     void userGarbage();
00165     Status move(const Dataspace *) const;
00166     short get_dspid() const;
00167     Bool compareHints(Index *idx);
00168     int getInd() const;
00169 
00170     // utility methods
00171     Status getCount(unsigned int &count);
00172     Status getStats(std::string &, Bool dspImpl = True,
00173                     Bool full = False, const char *indent = "");
00174     Status getStats(IndexStats *&stats);
00175     Status simulate(const IndexImpl &, std::string &,
00176                     Bool dspImpl = True, Bool full = False,
00177                     const char *indent = "");
00178     Status simulate(const IndexImpl &, IndexStats *&stats);
00179 
00180     Status reimplement(const IndexImpl &, Index *&);
00181     virtual Status setImplementation(const IndexImpl *) {return Success;}
00182     virtual Status getImplementation(IndexImpl *&, Bool remote = False) const {return 0;}
00183     Status getDefaultDataspace(const Dataspace *&) const;
00184     Status setDefaultDataspace(const Dataspace *);
00185     Status getObjectLocations(ObjectLocationArray &);
00186     virtual Status report(eyedbsm::DbHandle *sedbh, const Oid &idxoid);
00187     %}
00188 };
00189 
00190 class #hashindex [HashIndex] extends #index {
00191   be_method_C *hash_method;
00192   int key_count;
00193 
00194   %C++{
00195     HashIndex(Database *, Class *, const char *attrpath,
00196               Bool propagate, Bool is_string,
00197               const Dataspace * = 0, int key_count = 0,
00198               BEMethod_C * = 0,
00199               const int *impl_hints = 0, int impl_hints_cnt = 0);
00200     HashIndex(Database *, Class *, const char *attrpath,
00201               Bool propagate, Bool is_string,
00202               const IndexImpl *idximpl);
00203     static Status make(Database *, Class *, const char *attrpath,
00204                        Bool propagate, Bool is_string,
00205                        const char *hints, HashIndex *&);
00206     Status setImplementation(const IndexImpl *);
00207     Status getImplementation(IndexImpl *&, Bool remote = False) const;
00208     virtual AttributeComponent *xclone(Database *, const Class *);
00209     Status check(Class *) const;
00210     Status make(Class *);
00211     Status realize(const RecMode* = NoRecurs);
00212     Status remove(const RecMode* = NoRecurs);
00213     Status s_trace(FILE *, Bool, unsigned int flags = 0) const;
00214     Status m_trace(FILE *, int, unsigned int, const RecMode *) const;
00215     Bool compareHashMethod(HashIndex *idx);
00216     const char *genName() const;
00217     virtual Status report(eyedbsm::DbHandle *sedbh, const Oid &idxoid);
00218     %}
00219 };
00220 
00221 class #btreeindex [BTreeIndex] extends #index {
00222   int degree;
00223 
00224   %C++{
00225     BTreeIndex(Database *, Class *,
00226                const char *attrpath, Bool propagate, Bool is_string,
00227                const Dataspace * = 0, int degree = 0,
00228                const int *impl_hints = 0, int impl_hints_cnt = 0);
00229     BTreeIndex(Database *, Class *,  const char *pathattr,
00230                Bool propagate, Bool is_string,
00231                const IndexImpl *idximpl);
00232     static Status make(Database *, Class *, const char *attrpath,
00233                        Bool propagate, Bool is_string,
00234                        const char *hints, BTreeIndex *&);
00235     Status setImplementation(const IndexImpl *);
00236     Status getImplementation(IndexImpl *&, Bool remote = False) const;
00237     virtual AttributeComponent *xclone(Database *, const Class *);
00238     Status check(Class *) const;
00239     Status realize(const RecMode* = NoRecurs);
00240     Status remove(const RecMode* = NoRecurs);
00241     Status s_trace(FILE *, Bool, unsigned int flags = 0) const;
00242     Status m_trace(FILE *, int, unsigned int, const RecMode *) const;
00243     const char *genName() const; 
00244     virtual Status report(eyedbsm::DbHandle *sedbh, const Oid &idxoid);
00245     %}
00246 };
00247 
00248 // ---------------------------------------------------------------------------
00249 //
00250 // Collection implementation
00251 //
00252 // ---------------------------------------------------------------------------
00253 
00254 enum index_type [IndexType] {
00255   HASH_INDEX_TYPE [HashIndexType] = 0x20,
00256     BTREE_INDEX_TYPE [BTreeIndexType] = 0x40
00257     };
00258 
00259 class collection_attribute_implementation [CollAttrImpl] extends attribute_component {
00260   int idxtype;
00261   short dspid;
00262   int key_count_or_degree;
00263   be_method_C *hash_method;
00264   int impl_hints[];
00265 
00266   %C++{
00267     CollAttrImpl(Database *, Class *, const char *attrpath,
00268                  Bool propagate, const Dataspace * = 0,
00269                  IndexImpl::Type = IndexImpl::Hash,
00270                  int key_count_or_degree = 0,
00271                  BEMethod_C * = 0,
00272                  const int *impl_hints = 0, int impl_hints_cnt = 0);
00273     CollAttrImpl(Database *, Class *, const char *attrpath,
00274                  Bool propagate, const IndexImpl *idximpl);
00275 
00276     Status makeDataspace(Database *db, const Dataspace *&) const;
00277     static Status make(Database *, Class *, const char *attrpath,
00278                        Bool propagate,
00279                        IndexImpl::Type, const char *hints,
00280                        CollAttrImpl *&);
00281     Status getImplementation(Database *, const IndexImpl *&);
00282     virtual AttributeComponent *xclone(Database *, const Class *);
00283     Status realize(const RecMode* = NoRecurs);
00284     Status remove(const RecMode* = NoRecurs);
00285     Status s_trace(FILE *, Bool, unsigned int flags = 0) const;
00286     Status m_trace(FILE *, int, unsigned int, const RecMode *) const;
00287     const char *genName() const;
00288     int getInd() const;
00289 
00290     void userInitialize();
00291     void userCopy(const Object &);
00292     void userGarbage();
00293 
00294     const Dataspace *dsp;
00295     IndexImpl *idximpl;
00296     %}
00297 };
00298 
00299 // ---------------------------------------------------------------------------
00300 //
00301 // Executables
00302 //
00303 // ---------------------------------------------------------------------------
00304 
00305 enum executable_lang [ExecutableLang] {
00306   C_LANG [C_LANG] = 0x1,
00307     OQL_LANG [OQL_LANG] = 0x2,
00308     SYSTEM_EXEC [SYSTEM_EXEC] = 0x100
00309     };
00310 
00311 enum argtype_type [ArgType_Type] {
00312   ANY_TYPE [ANY_TYPE] = 0,
00313     VOID_TYPE [VOID_TYPE],
00314     INT16_TYPE [INT16_TYPE],
00315     INT32_TYPE [INT32_TYPE],
00316     INT64_TYPE [INT64_TYPE],
00317     STRING_TYPE [STRING_TYPE],
00318     CHAR_TYPE [CHAR_TYPE],
00319     FLOAT_TYPE [FLOAT_TYPE],
00320     OID_TYPE [OID_TYPE],
00321     OBJ_TYPE [OBJ_TYPE],
00322     RAW_TYPE [RAW_TYPE],
00323     BYTE_TYPE [BYTE_TYPE],
00324     ARRAY_TYPE [ARRAY_TYPE] = 0x0100,
00325     IN_ARG_TYPE [IN_ARG_TYPE] = 0x1000,
00326     OUT_ARG_TYPE [OUT_ARG_TYPE] = 0x2000,
00327     INOUT_ARG_TYPE [INOUT_ARG_TYPE] = 0x3000 // IN_ARG_TYPE | OUT_ARG_TYPE
00328     };
00329 
00330 class argtype [ArgType] {
00331   argtype_type #type;
00332   string clname;
00333   %C++{
00334     Bool operator==(const ArgType &) const;
00335 
00336     Bool operator!=(const ArgType &) const;
00337     static ArgType *make(Schema *m, const char *s);
00338     static int getBasicType(const char *s);
00339     void declare(FILE *, Schema *, const char *name);
00340     void init(FILE *, Schema *, const char *prefix, const char *name,
00341               const char *indent);
00342     void ret(FILE *, Schema *, const char *prefix, const char *name);
00343     const char *getCType(Schema *) const;
00344     void getCPrefix(FILE *fd, Schema *, const char *prefix,
00345                     const char *name, Bool fullcast) const;
00346     %}
00347 };
00348 
00349 enum executable_localisation [ExecutableLocalisation] {
00350   BACKEND [BACKEND] = 1,
00351     FRONTEND [FRONTEND],
00352     STATIC_EXEC [STATIC_EXEC] = 0x100
00353     };
00354 
00355 enum executable_type [ExecutableType] {
00356   METHOD_C_TYPE [METHOD_C_TYPE]       = 0x02,
00357     METHOD_OQL_TYPE [METHOD_OQL_TYPE]   = 0x12,
00358     TRIGGER_C_TYPE [TRIGGER_C_TYPE]     = 0x08,
00359     TRIGGER_OQL_TYPE [TRIGGER_OQL_TYPE] = 0x18
00360     };
00361 
00362 #define TriggerBEFORE 0x01
00363 #define TriggerAFTER  0x02
00364 
00365 #define TriggerCREATE 0x10
00366 #define TriggerUPDATE 0x20
00367 #define TriggerLOAD   0x40
00368 #define TriggerREMOVE 0x80
00369 
00370 #define MK(X,W) ((X)|(W))
00371 
00372 enum trigger_type [TriggerType] {
00373   TRIGGER_CREATE_BEFORE [TriggerCREATE_BEFORE]
00374     = MK(TriggerCREATE, TriggerBEFORE),
00375 
00376     TRIGGER_CREATE_AFTER [TriggerCREATE_AFTER]
00377     = MK(TriggerCREATE, TriggerAFTER),
00378 
00379     TRIGGER_UPDATE_BEFORE [TriggerUPDATE_BEFORE]
00380     = MK(TriggerUPDATE, TriggerBEFORE),
00381 
00382     TRIGGER_UPDATE_AFTER [TriggerUPDATE_AFTER]
00383     = MK(TriggerUPDATE, TriggerAFTER),
00384 
00385     TRIGGER_LOAD_BEFORE [TriggerLOAD_BEFORE]  
00386     = MK(TriggerLOAD,   TriggerBEFORE),
00387 
00388     TRIGGER_LOAD_AFTER [TriggerLOAD_AFTER]   
00389     = MK(TriggerLOAD,   TriggerAFTER),
00390 
00391     TRIGGER_REMOVE_BEFORE [TriggerREMOVE_BEFORE]
00392     = MK(TriggerREMOVE, TriggerBEFORE),
00393 
00394     TRIGGER_REMOVE_AFTER [TriggerREMOVE_AFTER] 
00395     = MK(TriggerREMOVE, TriggerAFTER)
00396     };
00397 
00398 class signature [Signature] {
00399   argtype rettype;
00400   int nargs;
00401   argtype types [];
00402   %C++{
00403     Bool operator ==(const Signature &) const;
00404     Bool operator !=(const Signature &) const;
00405     const char *getArg(int i);
00406     static const char *getPrefix(const char *prefix, int i);
00407     static Bool isVoid(const ArgType *type);
00408     void listArgs(FILE *, Schema *);
00409     void declArgs(FILE *, Schema *);
00410     void initArgs(FILE *, Schema *, const char *prefix, const char *preret,
00411                   const char *indent);
00412     void setArgs(FILE *, Schema *, int type, const char *prefix,
00413                  const char *preret, const char *indent);
00414     void retArgs(FILE *, Schema *, const char *prefix, const char *preret,
00415                  const char *indent);
00416     %}
00417 };
00418  
00419 class executable [Executable] {
00420   string exname; /* executable name, limited to 64 chars */
00421   executable_lang lang;
00422   executable_localisation loc;
00423   signature sign;
00424   string intname; /* internal name including signature */
00425   string extref_body; /* external reference or body */
00426 
00427   %C++{
00428     void initExec(const char *exname,
00429                   ExecutableLang lang,
00430                   Bool isSystem,
00431                   ExecutableLocalisation loc,
00432                   Signature *sign, Class * = 0);
00433     static const char *makeInternalName(const char *exname,
00434                                         const Signature *sign,
00435                                         Bool isClassMethod,
00436                                         const char *clname = 0);
00437     const char *_getPrototype(const Class *, Bool scope) const;
00438     static const char *makeExtRef(const char *extref);
00439     static const char *getSOTag();
00440     static const char *getSOFile(const char *extref);
00441     static void *_dlopen(const char *extref);
00442     int isStaticExec() const;
00443     void *dl;
00444     void userInitialize();
00445     void userCopy(const Object &);
00446     virtual Status execCheck();
00447     Status checkRealize(const char *, const char *, void **);
00448     static Status checkRealize(const char *extref, const char *intname,
00449                                void **pdl, void **pcsym);
00450     %}
00451 
00452   constraint <notnull> on exname;
00453 };
00454 
00455 class agregat_class_executable [AgregatClassExecutable] extends agregat_class_component {
00456   executable ex; // because no multiple inheritance
00457 
00458 #ifdef INDEX
00459   index <propagate=off> on ex.exname;
00460   index <propagate=off> on ex.intname;
00461 #endif
00462 };
00463 
00464 class #method [Method] extends agregat_class_executable {
00465   %C++{
00466     virtual Status applyTo(Database *, Object *, ArgArray &,
00467                            Argument &retarg, Bool checkArgs);
00468     Status realize(const RecMode* = NoRecurs);
00469     Status remove(const RecMode* = NoRecurs);
00470 
00471     static Status get(Database *, Class *, const char *name,
00472                       const Signature *, Bool isClassMethod,
00473                       Method * &);
00474 
00475     static Status getSignature(Database *, Class *,
00476                                const char *sign_str, Signature *&,
00477                                char *&fname);
00478 
00479     static Status get(Database *, Class *,
00480                       const char *sign_str, Bool isClassMethod,
00481                       Method * &);
00482 
00483     const char *getPrototype(Bool scope = True) const;
00484 
00485     Status check(Class *) const;
00486     Bool   isInherit() const;
00487     Status m_trace(FILE *, int, unsigned int, const RecMode *) const;
00488     int getInd() const;
00489     virtual Status execCheck();
00490     %}
00491 
00492 #ifdef INDEX
00493   index <propagate=off> on ex.exname;
00494   index <propagate=off> on ex.intname;
00495 #endif
00496 };
00497 
00498 class fe_method [FEMethod] extends #method {
00499 #ifdef INDEX
00500   index <propagate=off> on ex.exname;
00501   index <propagate=off> on ex.intname;
00502 #endif
00503 };
00504 
00505 class fe_method_C [FEMethod_C] extends fe_method {
00506   %C++{
00507     Status (*csym)(Database *, FEMethod_C *, Object *,
00508                    ArgArray &array, Argument &retarg);
00509     FEMethod_C(Database *, Class *, const char *name,
00510                Signature *, Bool isClassMethod,
00511                Bool isSystem, const char *extref);
00512     Status execCheck();
00513     Status applyTo(Database *, Object *, ArgArray &, Argument &retarg, Bool checkArgs);
00514     void userInitialize();
00515     void userCopy(const Object &);
00516     %}
00517 #ifdef INDEX
00518   index <propagate=off> on ex.exname;
00519   index <propagate=off> on ex.intname;
00520 #endif
00521 };
00522 
00523 class be_method [BEMethod] extends #method {
00524 #ifdef INDEX
00525   index <propagate=off> on ex.exname;
00526   index <propagate=off> on ex.intname;
00527 #endif
00528 };
00529 
00530 class be_method_C [BEMethod_C] extends be_method {
00531   %C++{
00532     Status (*csym)(Database *, BEMethod *, Object *,
00533                    ArgArray &array, Argument &retarg);
00534     BEMethod_C(Database *, Class *, const char *name,
00535                Signature *, Bool isClassMethod,
00536                Bool isSystem, const char *extref);
00537     Status execCheck();
00538     Status applyTo(Database *, Object *, ArgArray &, Argument &retarg, Bool checkArgs);
00539     %}
00540 #ifdef INDEX
00541   index <propagate=off> on ex.exname;
00542   index <propagate=off> on ex.intname;
00543 #endif
00544 };
00545 
00546 class be_method_OQL [BEMethod_OQL] extends be_method {
00547 
00548   %C++{
00549     BEMethod_OQL(Database *, Class *, const char *name,
00550                  Signature *, Bool isClassMethod,
00551                  Bool isSystem, const char *body);
00552 
00553     Status execCheck();
00554     Status setBody(const char *);
00555     Status applyTo(Database *, Object *, ArgArray &,
00556                    Argument &retarg, Bool checkArgs);
00557 
00558     static std::string makeExtrefBody(const Class *cls, const char *oql,
00559                                       const char *fname,
00560                                       char *typnames[],
00561                                       char *varnames[],
00562                                       unsigned int param_cnt,
00563                                       std::string &oqlConstruct);
00564     Status runtimeInit();
00565 
00566     Bool isRTInitialized;
00567     char **varnames;
00568     int param_cnt;
00569     char *funcname;
00570     char *body;
00571     char *fullBody;
00572     char *tmpbuf;
00573     void *entry;
00574 
00575     void userInitialize();
00576     void userGarbage();
00577     void userCopy(const Object &);
00578     %}
00579 #ifdef INDEX
00580   index <propagate=off> on ex.exname;
00581   index <propagate=off> on ex.intname;
00582 #endif
00583 };
00584 
00585 class #trigger [Trigger] extends agregat_class_executable {
00586   trigger_type #type;
00587   int light;
00588   char suffix[16];
00589   %C++{
00590     Trigger(Database *, Class *, TriggerType,
00591             ExecutableLang, Bool isSystem, const char *suffix,
00592             Bool light, const char *extref);
00593     Status (*csym)(TriggerType, Database *, const Oid &,
00594                    Object *);
00595     Status apply(const Oid &, Object *);
00596     Status realize(const RecMode* = NoRecurs);
00597     Status remove(const RecMode* = NoRecurs);
00598     const char *getPrototype(Bool scope = True) const;
00599     const char *getCSym() const;
00600     static const char *getStrTriggerType(TriggerType);
00601     Bool   isInherit() const;
00602     Status m_trace(FILE *, int, unsigned int, const RecMode *) const;
00603     int getInd() const;
00604 
00605     static std::string makeExtrefBody(const Class *cls, const char *oql,
00606                                       const char *fname,
00607                                       std::string &oqlConstruct);
00608     Status runtimeInit();
00609 
00610     Bool isRTInitialized;
00611     char *funcname;
00612     char *body;
00613     char *fullBody;
00614     char *tmpbuf;
00615     void *entry;
00616 
00617     void userInitialize();
00618     void userGarbage();
00619     void userCopy(const Object &);
00620     %}
00621 
00622 #ifdef INDEX
00623   index <propagate=off> on ex.exname;
00624   index <propagate=off> on ex.intname;
00625 #endif
00626 };
00627 
00628 // ---------------------------------------------------------------------------
00629 //
00630 // Constraint Classes
00631 //
00632 // ---------------------------------------------------------------------------
00633 
00634 class unique_constraint [UniqueConstraint] extends attribute_component {
00635   %C++{
00636     UniqueConstraint(Database *, Class *, const char *attrpath,
00637                      Bool propagate);
00638     Status m_trace(FILE *, int, unsigned int, const RecMode *) const;
00639     Status realize(const RecMode* = NoRecurs);
00640     Status remove(const RecMode* = NoRecurs);
00641     virtual AttributeComponent *xclone(Database *, const Class *);
00642     const char *genName() const; 
00643     int getInd() const;
00644     %}
00645 };
00646 
00647 class notnull_constraint [NotNullConstraint] extends attribute_component {
00648   %C++{
00649     NotNullConstraint(Database *, Class *, const char *attrpath,
00650                       Bool propagate);
00651     Status m_trace(FILE *, int, unsigned int, const RecMode *) const;
00652     Status realize(const RecMode* = NoRecurs);
00653     Status remove(const RecMode* = NoRecurs);
00654     virtual AttributeComponent *xclone(Database *, const Class *);
00655     const char *genName() const; 
00656     int getInd() const;
00657     %}
00658 };
00659 
00660 class cardinality_description [CardinalityDescription] {
00661   int bottom;
00662   int bottom_excl;
00663   int top;
00664   int top_excl;
00665   %C++{
00666     const char *getString(Bool = True) const;
00667     Bool compare(CardinalityDescription *);
00668     %}
00669 };
00670 
00671 class cardinality_constraint [CardinalityConstraint] extends agregat_class_component {
00672   string attrname;
00673   cardinality_description card_desc;
00674 
00675   %C++{
00676     CardinalityConstraint(Database *, Class *,
00677                           const char *attrname, int, int, int, int);
00678     Status check(Class *) const;
00679     const char *genName() const;
00680     Bool   isInherit() const;
00681     Status make(Class *);
00682     Status m_trace(FILE *, int, unsigned int, const RecMode *) const;
00683     int getInd() const;
00684     static int maxint;
00685     %}
00686 };
00687 
00688 // ---------------------------------------------------------------------------
00689 //
00690 // Classes for component propagation tests
00691 //
00692 // _Test suffix will disapear
00693 //
00694 // ---------------------------------------------------------------------------
00695 
00696 class cardinality_constraint_test [CardinalityConstraint_Test] extends attribute_component {
00697   cardinality_description card_desc;
00698 
00699   %C++{
00700     CardinalityConstraint_Test(Database *, Class *,
00701                                const char *attrpath,
00702                                int, int, int, int);
00703     Status realize(const RecMode* = NoRecurs);
00704     Status remove(const RecMode* = NoRecurs);
00705     const char *genName() const;
00706     Status m_trace(FILE *, int, unsigned int, const RecMode *) const;
00707     static int maxint;
00708     int getInd() const;
00709     %}
00710 };
00711 
00712 // ---------------------------------------------------------------------------
00713 //
00714 // Protection Classes
00715 //
00716 // ---------------------------------------------------------------------------
00717 
00718 enum protection_mode [ProtectionMode] {
00719   PROT_READ [ProtRead] = 0x100,
00720     PROT_RW [ProtRW] = 0x101
00721     };
00722       
00723 class protection_user [ProtectionUser] {
00724   object *user;
00725   protection_mode mode;
00726 };
00727 
00728 class protection [Protection] {
00729   string name;
00730   protection_user pusers[];
00731   oid poid;
00732 
00733   %C++{
00734     Status realize(const RecMode* = NoRecurs);
00735     Status remove(const RecMode* = NoRecurs);
00736     %}
00737 };
00738 
00739 // ---------------------------------------------------------------------------
00740 //
00741 // Internal Classes
00742 //
00743 // ---------------------------------------------------------------------------
00744 
00745 class unreadable_object [UnreadableObject] {
00746   %C++{
00747     Status trace_realize(FILE*, int, unsigned int, const RecMode *) const;
00748     static Bool isUnreadableObject(const Object *);
00749     static Bool isUnreadableObject(const Class *);
00750     %}
00751 };
00752 
00753 // ---------------------------------------------------------------------------
00754 //
00755 // Schema Flexibility Classes
00756 //
00757 // ---------------------------------------------------------------------------
00758 
00759 enum class_update_type [ClassUpdateType] {
00760   ADD_ATTR [ADD_ATTR],
00761     RMV_ATTR [RMV_ATTR],
00762     CNV_ATTR [CNV_ATTR],
00763     MIG_ATTR [MIG_ATTR],
00764     RMV_CLASS [RMV_CLASS]
00765     };
00766 
00767 enum attribute_convert_type [AttributeConvertType] {
00768   // numeric conversions
00769   INT16_TO_INT16 [INT16_TO_INT16],
00770     INT16_TO_INT32 [INT16_TO_INT32],
00771     INT16_TO_INT64 [INT16_TO_INT64],
00772     INT16_TO_FLOAT [INT16_TO_FLOAT],
00773     INT16_TO_BYTE [INT16_TO_BYTE],
00774     INT16_TO_CHAR [INT16_TO_CHAR],
00775     INT16_TO_ENUM [INT16_TO_ENUM],
00776 
00777     INT32_TO_INT32 [INT32_TO_INT32],
00778     INT32_TO_INT16 [INT32_TO_INT16],
00779     INT32_TO_INT64 [INT32_TO_INT64],
00780     INT32_TO_FLOAT [INT32_TO_FLOAT],
00781     INT32_TO_BYTE [INT32_TO_BYTE],
00782     INT32_TO_CHAR [INT32_TO_CHAR],
00783     INT32_TO_ENUM [INT32_TO_ENUM],
00784 
00785     INT64_TO_INT64 [INT64_TO_INT64],
00786     INT64_TO_INT16 [INT64_TO_INT16],
00787     INT64_TO_INT32 [INT64_TO_INT32],
00788     INT64_TO_FLOAT [INT64_TO_FLOAT],
00789     INT64_TO_BYTE [INT64_TO_BYTE],
00790     INT64_TO_CHAR [INT64_TO_CHAR],
00791     INT64_TO_ENUM [INT64_TO_ENUM],
00792   
00793     FLOAT_TO_FLOAT [FLOAT_TO_FLOAT],
00794     FLOAT_TO_INT16 [FLOAT_TO_INT16],
00795     FLOAT_TO_INT32 [FLOAT_TO_INT32],
00796     FLOAT_TO_INT64 [FLOAT_TO_INT64],
00797     FLOAT_TO_BYTE [FLOAT_TO_BYTE],
00798     FLOAT_TO_CHAR [FLOAT_TO_CHAR],
00799     FLOAT_TO_ENUM [FLOAT_TO_ENUM],
00800   
00801     CHAR_TO_CHAR [CHAR_TO_CHAR],
00802     CHAR_TO_INT16 [CHAR_TO_INT16],
00803     CHAR_TO_INT32 [CHAR_TO_INT32],
00804     CHAR_TO_INT64 [CHAR_TO_INT64],
00805     CHAR_TO_FLOAT [CHAR_TO_FLOAT],
00806     CHAR_TO_BYTE [CHAR_TO_BYTE],
00807     CHAR_TO_ENUM [CHAR_TO_ENUM],
00808   
00809     BYTE_TO_BYTE [BYTE_TO_BYTE],
00810     BYTE_TO_INT16 [BYTE_TO_INT16],
00811     BYTE_TO_INT32 [BYTE_TO_INT32],
00812     BYTE_TO_INT64 [BYTE_TO_INT64],
00813     BYTE_TO_FLOAT [BYTE_TO_FLOAT],
00814     BYTE_TO_CHAR [BYTE_TO_CHAR],
00815     BYTE_TO_ENUM [BYTE_TO_ENUM],
00816   
00817     ENUM_TO_ENUM [ENUM_TO_ENUM],
00818     ENUM_TO_INT16 [ENUM_TO_INT16],
00819     ENUM_TO_INT32 [ENUM_TO_INT32],
00820     ENUM_TO_INT64 [ENUM_TO_INT64],
00821     ENUM_TO_FLOAT [ENUM_TO_FLOAT],
00822     ENUM_TO_CHAR [ENUM_TO_CHAR],
00823     ENUM_TO_BYTE [ENUM_TO_BYTE],
00824 
00825     // string conversions
00826     CHAR_TO_STRING [CHAR_TO_STRING],
00827     STRING_TO_CHAR [STRING_TO_CHAR],
00828     INT16_TO_STRING [INT16_TO_STRING],
00829     STRING_TO_INT16 [STRING_TO_INT16],
00830     INT32_TO_STRING [INT32_TO_STRING],
00831     STRING_TO_INT32 [STRING_TO_INT32],
00832     INT64_TO_STRING [INT64_TO_STRING],
00833     STRING_TO_INT64 [STRING_TO_INT64],
00834     FLOAT_TO_STRING [FLOAT_TO_STRING],
00835     STRING_TO_FLOAT [STRING_TO_FLOAT],
00836     BYTE_TO_STRING [BYTE_TO_STRING],
00837     STRING_TO_BYTE [STRING_TO_BYTE],
00838 
00839     // collection conversions
00840     SET_TO_BAG [SET_TO_BAG],
00841     SET_TO_ARRAY [SET_TO_ARRAY],
00842     SET_TO_LIST [SET_TO_LIST],
00843   
00844     BAG_TO_SET [BAG_TO_SET],
00845     BAG_TO_ARRAY [BAG_TO_ARRAY],
00846     BAG_TO_LIST [BAG_TO_LIST],
00847   
00848     ARRAY_TO_BAG [ARRAY_TO_BAG],
00849     ARRAY_TO_SET [ARRAY_TO_SET],
00850     ARRAY_TO_LIST [ARRAY_TO_LIST],
00851   
00852     LIST_TO_BAG [LIST_TO_BAG],
00853     LIST_TO_ARRAY [LIST_TO_ARRAY],
00854     LIST_TO_SET [LIST_TO_SET],
00855   
00856     // class conversion
00857     CLASS_TO_CLASS [CLASS_TO_CLASS],
00858   
00859     // user conversions
00860     USER_CNV [USER_CNV],
00861 
00862     // no data conversion
00863     NIL_CNV [NIL_CNV]
00864     };
00865 
00866 class class_conversion [ClassConversion] {
00867 
00868   class_update_type updtype;
00869   attribute_convert_type cnvtype;
00870 
00871   // class name
00872   string clsname;
00873   // attribute name
00874   string attrname;
00875   // attribute num
00876   int attrnum;
00877   
00878   // old class
00879   oid oid_o; // entry point (indexed)
00880   // new class
00881   oid oid_n;
00882 
00883   // relative old class
00884   oid roid_o;
00885 
00886   // if updtype == CNV_ATTR, sync update ?
00887   int sync;
00888 
00889   // with_check, concerns:
00890   //   <coll>_TO_SET
00891   //   <numeric>_TO_ENUM
00892   int with_check;
00893 
00894   // conversion details:
00895   // concerning STRING_TO_STRING
00896   int src_dim;
00897   int dest_dim;
00898 
00899   // offset details
00900   int offset_o;
00901   int offset_n;
00902   int size_o;
00903   int size_n;
00904 
00905   BEMethod_C *cnv_mth;
00906 
00907   %C++{
00908     struct Context {
00909       const Class *cls;
00910       ObjectArray obj_arr;
00911       Context *next;
00912       Context();
00913       ~Context();
00914     };
00915 
00916     const Class *cls_;
00917     const Attribute *attr_;
00918     static Status getClass_(Database *, const Oid &ocloid,
00919                             const Class *&,
00920                             ClassConversion::Context *&,
00921                             Bool class_to_class = False);
00922     static Status convert(Database *, const ClassConversion::Context *,
00923                           Data in_idr, Size in_size);
00924     Status convert(Database *db, Data in_idr, Size &in_size);
00925     static Size computeSize(ClassConversion::Context *conv_ctx,
00926                             Size start_size);
00927     void computeSize(Size &cur_size);
00928 
00929     static void init();
00930     static void _release();
00931 
00932     void userInitialize();
00933     void userCopy(const Object &);
00934     void userGarbage();
00935     %}
00936 
00937 #ifdef INDEX
00938   index <propagate=off> on clsname;
00939   index <propagate=off> on oid_o;
00940   index <propagate=off> on oid_n;
00941 #endif
00942 };

Generated on Mon Dec 22 18:16:10 2008 for eyedb by  doxygen 1.5.3