Commit 84314bd3 authored by claes's avatar claes

Database mysql

parent 1729c14d
This diff is collapsed.
This diff is collapsed.
/*
* Proview $Id: wb_orepdbms.cpp,v 1.1 2007-10-18 09:11:01 claes Exp $
* Copyright (C) 2007 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#if defined PWRE_CONF_MYSQL
#include "wb_orepdbms.h"
#include "wb_vrepdbms.h"
wb_orepdbms::wb_orepdbms() :
m_o(0), m_oid(pwr_cNOid)
{
}
wb_orepdbms::wb_orepdbms(pwr_tOid oid) :
m_o(0), m_oid(oid)
{
}
wb_orepdbms::wb_orepdbms(dbms_sObject *o) :
m_o(o), m_oid(o->oid)
{
}
wb_orepdbms::~wb_orepdbms()
{
}
void *
wb_orepdbms::operator new(size_t size, wb_vrepdbms *v)
{
return (void *)v->new_wb_orepdbms(size);
}
#if 1
void
wb_orepdbms::operator delete(void *p)
{
wb_orepdbms *o = (wb_orepdbms *)p;
((wb_vrepdbms *)o->m_vrep)->delete_wb_orepdbms(p);
}
#endif
//
// Operations declared in wb_orep
//
pwr_tOid wb_orepdbms::oid() const
{
return m_oid;
}
pwr_tVid wb_orepdbms::cid() const
{
pwr_tStatus sts;
return m_vrep->cid(&sts, (wb_orep*)this);
}
pwr_tVid wb_orepdbms::vid() const
{
pwr_tStatus sts;
return m_vrep->vid(&sts, (wb_orep*)this);
}
pwr_tOix wb_orepdbms::oix() const
{
pwr_tStatus sts;
return m_vrep->oix(&sts, (wb_orep*)this);
}
pwr_tOid wb_orepdbms::poid() const
{
pwr_tStatus sts;
return m_vrep->poid(&sts, (wb_orep*)this);
}
pwr_tOid wb_orepdbms::foid() const
{
pwr_tStatus sts;
return m_vrep->foid(&sts, (wb_orep*)this);
}
pwr_tOid wb_orepdbms::loid() const
{
pwr_tStatus sts;
return m_vrep->loid(&sts, (wb_orep*)this);
}
pwr_tOid wb_orepdbms::boid() const
{
pwr_tStatus sts;
return m_vrep->boid(&sts, (wb_orep*)this);
}
pwr_tOid wb_orepdbms::aoid() const
{
pwr_tStatus sts;
return m_vrep->aoid(&sts, (wb_orep*)this);
}
wb_name wb_orepdbms::longName()
{
pwr_tStatus sts;
return m_vrep->longName(&sts, (wb_orep*)this);
}
const char * wb_orepdbms::name() const
{
pwr_tStatus sts;
return m_vrep->objectName(&sts, (wb_orep*)this);
}
pwr_tTime wb_orepdbms::ohTime() const
{
pwr_tStatus sts;
return m_vrep->ohTime(&sts, (wb_orep*)this);
}
pwr_tTime wb_orepdbms::rbTime() const
{
pwr_tStatus sts;
return m_vrep->rbTime(&sts, (wb_orep*)this);
}
pwr_tTime wb_orepdbms::dbTime() const
{
pwr_tStatus sts;
return m_vrep->dbTime(&sts, (wb_orep*)this);
}
pwr_mClassDef wb_orepdbms::flags() const
{
pwr_tStatus sts;
return m_vrep->flags(&sts, (wb_orep*)this);
}
bool wb_orepdbms::isOffspringOf(const wb_orep *o) const
{
pwr_tStatus sts;
return m_vrep->isOffspringOf(&sts, (wb_orep*)this, o);
}
wb_orep *wb_orepdbms::ancestor(pwr_tStatus *sts)
{
return m_vrep->ancestor(sts, (wb_orep*)this);
}
wb_orep *wb_orepdbms::parent(pwr_tStatus *sts)
{
return m_vrep->parent(sts, (wb_orep*)this);
}
wb_orep *wb_orepdbms::after(pwr_tStatus *sts)
{
return m_vrep->after(sts, (wb_orep*)this);
}
wb_orep *wb_orepdbms::before(pwr_tStatus *sts)
{
return m_vrep->before(sts, (wb_orep*)this);
}
wb_orep* wb_orepdbms::first(pwr_tStatus *sts)
{
return m_vrep->first(sts, (wb_orep*)this);
}
wb_orep *wb_orepdbms::child(pwr_tStatus *sts, wb_name &name)
{
return m_vrep->child(sts, (wb_orep*)this, name);
}
wb_orep *wb_orepdbms::last(pwr_tStatus *sts)
{
return m_vrep->last(sts, (wb_orep*)this);
}
wb_orep *wb_orepdbms::next(pwr_tStatus *sts)
{
return m_vrep->next(sts, (wb_orep*)this);
}
wb_orep *wb_orepdbms::previous(pwr_tStatus *sts)
{
return m_vrep->previous(sts, (wb_orep*)this);
}
wb_adrep *wb_orepdbms::attribute(pwr_tStatus*, const char *aname)
{
return 0;
}
wb_adrep *wb_orepdbms::attribute(pwr_tStatus*)
{
return 0;
}
#endif
/*
* Proview $Id: wb_orepdbms.h,v 1.1 2007-10-18 09:11:01 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#ifndef wb_orepdbms_h
#define wb_orepdbms_h
#if defined PWRE_CONF_MYSQL
#include "pwr.h"
#include "wb_orep.h"
#include "pwr_class.h"
#include "wb_dbms.h"
class wb_vrepdbms;
class wb_orepdbms : wb_orep
{
friend class wb_vrepdbms;
dbms_sObject *m_o;
pwr_tOid m_oid;
public:
wb_orepdbms();
wb_orepdbms(pwr_tOid oid);
wb_orepdbms(dbms_sObject *o);
~wb_orepdbms();
void* operator new(size_t size, wb_vrepdbms *v);
void operator delete(void *p);
virtual pwr_tOid oid() const;
virtual pwr_tVid vid() const;
virtual pwr_tOix oix() const;
virtual pwr_tCid cid() const;
virtual pwr_tOid poid() const;
virtual pwr_tOid foid() const;
virtual pwr_tOid loid() const;
virtual pwr_tOid boid() const;
virtual pwr_tOid aoid() const;
virtual const char * name() const;
virtual wb_name longName();
virtual pwr_tTime ohTime() const;
virtual pwr_tTime rbTime() const;
virtual pwr_tTime dbTime() const;
virtual pwr_mClassDef flags() const;
virtual bool isOffspringOf(const wb_orep *o) const;
// Navigational operations
virtual wb_orep *ancestor(pwr_tStatus *sts); //< get object at top of hierarchy
virtual wb_orep *parent(pwr_tStatus *sts);
virtual wb_orep *after(pwr_tStatus *sts); //< get next sibling
virtual wb_orep *before(pwr_tStatus *sts); //< get previous sibling
virtual wb_orep *first(pwr_tStatus *sts); //< get first child
virtual wb_orep *child(pwr_tStatus *sts, wb_name &name); //< get named child
virtual wb_orep *last(pwr_tStatus *sts); //< get last child
virtual wb_orep *next(pwr_tStatus *sts); //< get next in list of objects of same class in one volume
virtual wb_orep *previous(pwr_tStatus *sts); //< get previous in list of objects of same class in one volume
virtual wb_adrep *attribute(pwr_tStatus*, const char *name);
virtual wb_adrep *attribute(pwr_tStatus*);
wb_erep *erep() const { return m_vrep->erep();}
wb_vrep *vrep() const { return m_vrep;}
virtual ldh_eVolRep vtype() const { return ldh_eVolRep_Dbms;}
};
#endif
#endif
This diff is collapsed.
/*
* Proview $Id: wb_vrepdbms.h,v 1.1 2007-10-18 09:11:01 claes Exp $
* Copyright (C) 2007 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program, if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#ifndef wb_vrepdbms_h
#define wb_vrepdbms_h
#if defined PWRE_CONF_MYSQL
#include "wb_vrep.h"
#include "wb_vrepdbs.h"
#include "wb_orepdbms.h"
#include "wb_dbms.h"
#include "co_tree.h"
class wb_vrepdbms : public wb_vrep
{
private:
bool deleteFamilyMember(pwr_tOid oid, wb_dbms_txn *txn);
typedef union {
struct {
pwr_tBit temporary : 1;
pwr_tBit exist : 1;
} b;
pwr_tBitMask m;
#define mOentry_temporary 1
#define mOentry_exist 2
} mOentry;
typedef struct sOentry
{
tree_sNode node;
pwr_tOid o_oid;
pwr_tOid n_oid;
struct sOentry *parent;
struct sOentry *before;
struct sOentry *after;
struct sOentry *first;
struct sOentry *last;
} sOentry;
sOentry *m_poep;
typedef struct sDestination
{
pwr_tOid oid;
pwr_tOid poid;
pwr_tOid foid;
pwr_tOid loid;
} sDestination;
sDestination m_destination;
protected:
wb_erep *m_erep;
wb_merep *m_merep;
//wb_merep *m_merepCheck;
unsigned int m_nRef;
char m_fileName[512];
char guard[500];
tree_sTable *m_attribute_th;
tree_sTable *m_aref_th;
tree_sTable *m_class_th;
public:
wb_dbms *m_db;
wb_dbms_ohead m_ohead;
wb_vrepdbms(wb_erep *erep, const char *fileName);
wb_vrepdbms(wb_erep *erep, pwr_tVid, pwr_tCid, const char *volumeName, const char *fileName);
tree_sTable *m_oid_th;
virtual void unref();
virtual wb_vrep *ref();
virtual ldh_eVolRep type() const { return ldh_eVolRep_Dbms;}
virtual wb_erep *erep();
virtual wb_merep *merep() const;
virtual wb_vrep *next();
virtual pwr_tTime ohTime(pwr_tStatus *sts, const wb_orep *o);
virtual pwr_tTime rbTime(pwr_tStatus *sts, const wb_orep *o);
virtual pwr_tTime dbTime(pwr_tStatus *sts, const wb_orep *o);
virtual pwr_mClassDef flags(pwr_tStatus *sts, const wb_orep *o);
virtual pwr_tOid oid(pwr_tStatus *sts, const wb_orep *o);
virtual pwr_tVid vid(pwr_tStatus *sts, const wb_orep *o);
virtual pwr_tOix oix(pwr_tStatus *sts, const wb_orep *o);
virtual pwr_tCid cid(pwr_tStatus *sts, const wb_orep *o);
virtual pwr_tOid poid(pwr_tStatus *sts, const wb_orep *o);
virtual pwr_tOid foid(pwr_tStatus *sts, const wb_orep *o);
virtual pwr_tOid loid(pwr_tStatus *sts, const wb_orep *o);
virtual pwr_tOid boid(pwr_tStatus *sts, const wb_orep *o);
virtual pwr_tOid aoid(pwr_tStatus *sts, const wb_orep *o);
virtual const char * objectName(pwr_tStatus *sts, const wb_orep *o);
virtual wb_name longName(pwr_tStatus *sts, const wb_orep *o);
virtual bool isOffspringOf(pwr_tStatus *sts, const wb_orep *child, const wb_orep *parent);
virtual wb_orep *object(pwr_tStatus *sts);
virtual wb_orep *object(pwr_tStatus *sts, pwr_tOid oid);
virtual wb_orep *object(pwr_tStatus *sts, pwr_tCid cid);
virtual wb_orep *object(pwr_tStatus *sts, wb_name &name);
virtual wb_orep *object(pwr_tStatus *sts, const wb_orep *parent, wb_name &name);
virtual wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name);
virtual wb_orep *copyObject(pwr_tStatus *sts, const wb_orep *orep, wb_destination &d, wb_name &name);
virtual bool copyOset(pwr_tStatus *sts, wb_oset *oset, wb_destination &d);
virtual bool moveObject(pwr_tStatus *sts, wb_orep *orep, wb_destination &d);
virtual bool deleteObject(pwr_tStatus *sts, wb_orep *orep);
virtual bool deleteFamily(pwr_tStatus *sts, wb_orep *orep);
virtual bool deleteOset(pwr_tStatus *sts, wb_oset *oset);
virtual bool renameObject(pwr_tStatus *sts, wb_orep *orep, wb_name &name);
virtual bool commit(pwr_tStatus *sts) {return m_db->commit(sts);}
virtual bool abort(pwr_tStatus *sts) {return m_db->abort(sts);}
virtual bool writeAttribute(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, size_t offset, size_t size, void *p);
virtual void *readAttribute(pwr_tStatus *sts, const wb_orep *o, pwr_eBix bix, size_t offset, size_t size, void *p);
virtual void *readBody(pwr_tStatus *sts, const wb_orep *o, pwr_eBix bix, void *p);
virtual bool writeBody(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, void *p);
virtual wb_orep *ancestor(pwr_tStatus *sts, const wb_orep *o);
virtual wb_orep *parent(pwr_tStatus *sts, const wb_orep *o);
virtual wb_orep *after(pwr_tStatus *sts, const wb_orep *o);
virtual wb_orep *before(pwr_tStatus *sts, const wb_orep *o);
virtual wb_orep *first(pwr_tStatus *sts, const wb_orep *o);
virtual wb_orep *child(pwr_tStatus *sts, const wb_orep *o, wb_name &name);
virtual wb_orep *last(pwr_tStatus *sts, const wb_orep *o);
virtual wb_orep *next(pwr_tStatus *sts, const wb_orep *o);
virtual wb_orep *nextClass(pwr_tStatus *sts, const wb_orep *o);
virtual wb_orep *previous(pwr_tStatus *sts, const wb_orep *o);
virtual wb_srep *newSession();
virtual bool isLocal(const wb_orep *o);
virtual bool createSnapshot(const char *fileName, const pwr_tTime *time);
virtual void objectName(const wb_orep *o, char *str);
void objectName(pwr_tOid oid, char *name, int level);
void load();
pwr_tStatus checkMeta();
pwr_tStatus updateMeta();
int updateArefs(pwr_tOid oid, pwr_tCid cid);
int checkClass(pwr_tCid cid);
void checkAttributes(pwr_tCid cid);
void checkSubClass(pwr_tCid cid, unsigned int o_offset, unsigned int n_offset);
//bool classIsChanged(pwr_tCid cid);
virtual bool exportVolume(wb_import &e);
virtual bool exportHead(wb_import &e);
virtual bool exportRbody(wb_import &e);
virtual bool exportDbody(wb_import &e);
virtual bool exportDocBlock(wb_import &e);
virtual bool exportMeta(wb_import &e);
virtual bool exportTree(wb_treeimport &i, pwr_tOid oid);
bool exportTreeHelper(wb_treeimport &i, pwr_tOid oid, bool isRoot);
virtual bool importTree(bool keepref) { return false;}
virtual bool importTreeObject(wb_merep *merep, pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name, pwr_mClassDef flags,
size_t rbSize, size_t dbSize, void *rbody, void *dbody)
{ return false;}
virtual bool importPaste();
virtual bool importPasteObject(pwr_tOid destination, ldh_eDest destcode,
bool keepoid, pwr_tOid oid,
pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name, pwr_mClassDef flags,
size_t rbSize, size_t dbSize, void *rbody, void *dbody,
pwr_tOid *roid);
virtual void importIgnoreErrors() {}
#if 0
int del_family(DbTxn *txn, Dbc *cp, pwr_tOid poid);
#endif
void unadopt(wb_dbms_txn *txn, wb_dbms_ohead &o);
void adopt(wb_dbms_txn *txn, wb_dbms_ohead &o, wb_destination &dest);
wb_orepdbms *new_wb_orepdbms(size_t size);
void delete_wb_orepdbms(void *p);
virtual bool accessSupported( ldh_eAccess access) { return true;}
virtual const char *fileName() { return m_fileName;}
// virtual void checkClassList(pwr_tOid oid, pwr_tCid cid, bool update);
int updateObject(pwr_tOid oid, pwr_tCid cid);
//pwr_tStatus checkObject(pwr_tOid oid, pwr_tCid cid);
};
#endif
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment