Commit a05a935b authored by lw's avatar lw

Update attribute referenses at meta data updates

parent c46a9f2b
/**
* Proview $Id: co_time.c,v 1.10 2006-05-21 22:30:49 lw Exp $
* Proview $Id: co_time.c,v 1.11 2006-12-10 14:33:34 lw Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -137,6 +137,26 @@ validateTm (
}
return TIME__SUCCESS;
}
//! Compare two timespecs.
/*! Returns \n
1 if t1 > t2 \n
0 if t1 == t2 \n
-1 if t1 < t2 \n
If argument 't2' is NULL the comparison will
be done as if t2 == 0.
*/
int
time_IsNull (
pwr_tTime *t1
)
{
assertAbs(t1);
return (t1->tv_sec == pwr_cNTime.tv_sec) && (t1->tv_nsec == pwr_cNTime.tv_nsec);
}
//! Add an absolute time and a delta time.
/*! Add two timespecs, result = t + d, where:
......@@ -170,7 +190,7 @@ time_Aadd (
return r;
}
//! Compare two timespecs.
/*! Returns \n
1 if t1 > t2 \n
......
/**
* Proview $Id: co_time.h,v 1.7 2006-05-21 22:30:49 lw Exp $
* Proview $Id: co_time.h,v 1.8 2006-12-10 14:33:34 lw Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -92,6 +92,7 @@ typedef enum {
);
#endif
int time_IsNull (pwr_tTime *t1);
pwr_tTime * time_Aabs (pwr_tTime*, pwr_tTime*);
pwr_tTime * time_Aadd (pwr_tTime*, pwr_tTime*, pwr_tDeltaTime*);
int time_Acomp (pwr_tTime*, pwr_tTime*);
......
/**
* Proview $Id: co_tree.c,v 1.3 2005-09-01 14:57:52 claes Exp $
* Proview $Id: co_tree.c,v 1.4 2006-12-10 14:33:34 lw Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -849,6 +849,12 @@ buildTree(tree_sTable *tp, tree_sNode *fp, int count, int *hight, int *key)
#endif
int
tree_Cardinality(pwr_tStatus *sts, tree_sTable *tp)
{
return tp->nNode;
}
tree_sTable *
tree_CloneTable(pwr_tStatus *sts, tree_sTable *tp)
{
......
/**
* Proview $Id: co_tree.h,v 1.3 2005-09-01 14:57:52 claes Exp $
* Proview $Id: co_tree.h,v 1.4 2006-12-10 14:33:34 lw Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -82,6 +82,9 @@ struct tree_s_Table {
Function prototypes to exported functions.
*/
int
tree_Cardinality(pwr_tStatus *sts, tree_sTable *tp);
tree_sTable *
tree_CloneTable(pwr_tStatus *sts, tree_sTable *tp);
......
/*
* Proview $Id: wb_bdrep.cpp,v 1.17 2005-09-06 10:43:30 claes Exp $
* Proview $Id: wb_bdrep.cpp,v 1.18 2006-12-10 14:34:13 lw Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -249,6 +249,25 @@ size_t wb_bdrep::size()
return body.Size;
}
pwr_sAttrRef wb_bdrep::aref()
{
pwr_tStatus sts;
pwr_sObjBodyDef body;
m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &body);
if ( EVEN(sts)) throw wb_error(sts);
pwr_sAttrRef aref;
aref.Objid = pwr_cNOid;
aref.Body = cdh_oixToBix( m_orep->oid().oix);
aref.Offset = 0;
aref.Size = body.Size;
aref.Flags.m = 0; // ?? Is this right?
return aref;
}
int wb_bdrep::nAttribute()
{
pwr_tStatus sts;
......
/*
* Proview $Id: wb_bdrep.h,v 1.14 2005-09-06 10:43:30 claes Exp $
* Proview $Id: wb_bdrep.h,v 1.15 2006-12-10 14:34:13 lw Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -42,7 +42,8 @@ public:
void unref();
wb_bdrep *ref();
pwr_sAttrRef aref() { pwr_sAttrRef a; return a;} // Fix
//pwr_sAttrRef aref() { pwr_sAttrRef a; return a;} // Fix
pwr_sAttrRef aref();
size_t size();
int nAttribute();
pwr_eBix bix();
......
/*
* Proview $Id: wb_db.cpp,v 1.35 2006-05-26 11:57:28 lw Exp $
* Proview $Id: wb_db.cpp,v 1.36 2006-12-10 14:34:13 lw Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -45,13 +45,6 @@ void wb_db_info::get(wb_db_txn *txn)
{
int index = 1;
int ret;
#if 0
m_key.set_data(&index);
m_key.set_size(sizeof(index));
m_data.set_data(&m_volume);
m_data.set_ulen(sizeof(m_volume));
m_data.set_flags(DB_DBT_USERMEM);
#endif
Dbt key(&index, sizeof(index));
Dbt data(&m_volume, sizeof(m_volume));
data.set_ulen(sizeof(m_volume));
......@@ -61,7 +54,7 @@ void wb_db_info::get(wb_db_txn *txn)
ret = m_db->m_t_info->get(txn, &key, &data, 0);
printf("info get: %d\n", ret);
} catch (DbException &e) {
printf("Fel, %d\n", ret);
printf("info get Error, %d\n", ret);
m_db->m_t_info->err(ret, "m_db->m_t_info->get(txn, &key, &data, 0)");
cout << e.what();
}
......@@ -122,8 +115,6 @@ bool wb_db_class::succ(pwr_tOid oid)
memcpy( &m_k, *data, sizeof(m_k));
}
return ret == 0;
// return false;
}
bool wb_db_class::succClass(pwr_tCid cid)
......@@ -168,7 +159,7 @@ int wb_db_class::del(wb_db_txn *txn)
return m_db->m_t_class->del(txn, &m_key, 0);
}
void wb_db_class::iter(void (*print)(pwr_tOid oid, pwr_tCid cid))
void wb_db_class::iter(void (*func)(pwr_tOid oid, pwr_tCid cid))
{
int rc = 0;
......@@ -181,20 +172,26 @@ void wb_db_class::iter(void (*print)(pwr_tOid oid, pwr_tCid cid))
m_key.set_ulen(sizeof(m_k));
m_key.set_flags(DB_DBT_USERMEM);
/* Walk through the database and print out the key/data pairs. */
/* Walk through the database. */
while ((rc = m_dbc->get(&m_key, &m_data, DB_NEXT)) == 0) {
print(m_k.oid, m_k.cid);
func(m_k.oid, m_k.cid);
}
m_dbc->close();
m_dbc = 0;
}
void wb_db_class::iter(wb_convert_volume *cp)
wb_db_class::~wb_db_class()
{
int rc = 0;
if (m_dbc)
m_dbc->close();
}
m_db->m_t_class->cursor(m_db->m_txn, &m_dbc, 0);
wb_db_class_iterator::wb_db_class_iterator(wb_db *db) :
m_db(db), m_key(&m_k, sizeof(m_k)), m_data(0, 0), m_dbc(0), m_atEnd(false), m_rc(0)
{
m_rc = m_db->m_t_class->cursor(m_db->m_txn, &m_dbc, 0);
/* Initialize the key/data pair so the flags aren't set. */
memset(&m_k, 0, sizeof(m_k));
......@@ -203,23 +200,93 @@ void wb_db_class::iter(wb_convert_volume *cp)
m_key.set_ulen(sizeof(m_k));
m_key.set_flags(DB_DBT_USERMEM);
/* Walk through the database and print out the key/data pairs. */
m_atEnd = (m_rc != 0);
}
while ((rc = m_dbc->get(&m_key, &m_data, DB_NEXT)) == 0) {
if (cp->m_update)
cp->updateObject(m_k.oid, m_k.cid);
else
cp->checkObject(m_k.oid, m_k.cid);
wb_db_class_iterator::wb_db_class_iterator(wb_db *db, pwr_tCid cid) :
m_db(db), m_key(&m_k, sizeof(m_k)), m_data(0, 0), m_dbc(0), m_atEnd(false), m_rc(0)
{
m_rc = m_db->m_t_class->cursor(m_db->m_txn, &m_dbc, 0);
/* Initialize the key/data pair so the flags aren't set. */
memset(&m_k, 0, sizeof(m_k));
m_key.set_data(&m_k);
m_key.set_ulen(sizeof(m_k));
m_key.set_flags(DB_DBT_USERMEM);
m_atEnd = (m_rc != 0);
m_k.oid = pwr_cNOid;
m_k.cid = cid;
}
wb_db_class_iterator::wb_db_class_iterator(wb_db *db, pwr_tCid cid, pwr_tOid oid) :
m_db(db), m_key(&m_k, sizeof(m_k)), m_data(0, 0), m_dbc(0), m_atEnd(false), m_rc(0)
{
m_rc = m_db->m_t_class->cursor(m_db->m_txn, &m_dbc, 0);
/* Initialize the key/data pair so the flags aren't set. */
memset(&m_k, 0, sizeof(m_k));
m_key.set_data(&m_k);
m_key.set_ulen(sizeof(m_k));
m_key.set_flags(DB_DBT_USERMEM);
m_atEnd = (m_rc != 0);
m_k.oid = oid;
m_k.cid = cid;
}
bool wb_db_class_iterator::first()
{
m_k.oid = pwr_cNOid;
m_k.cid = pwr_cNCid;
//m_rc = m_dbc->get(&m_key, 0, DB_FIRST);
m_rc = m_dbc->get(&m_key, &m_data, DB_FIRST);
m_atEnd = (m_rc != 0);
return !m_atEnd;
}
bool wb_db_class_iterator::succObject()
{
if (!m_atEnd) {
m_rc = m_dbc->get(&m_key, &m_data, DB_NEXT);
m_atEnd = (m_rc != 0);
}
m_dbc->close();
m_dbc = 0;
return !m_atEnd;
}
wb_db_class::~wb_db_class()
bool wb_db_class_iterator::succClass()
{
m_k.oid = pwr_cNOid;
m_k.cid++;
m_rc = m_dbc->get(&m_key, &m_data, DB_SET_RANGE);
m_atEnd = (m_rc != 0);
return !m_atEnd;
}
bool wb_db_class_iterator::succClass(pwr_tCid cid)
{
m_k.oid = pwr_cNOid;
m_k.cid = cid + 1;
m_rc = m_dbc->get(&m_key, &m_data, DB_SET_RANGE);
m_atEnd = (m_rc != 0);
return !m_atEnd;
}
wb_db_class_iterator::~wb_db_class_iterator()
{
if (m_dbc)
m_dbc->close();
m_dbc = 0;
}
wb_db_name::wb_db_name(wb_db *db, wb_db_txn *txn) :
......@@ -259,11 +326,6 @@ wb_db_name::wb_db_name(wb_db *db, wb_db_txn *txn, pwr_tOid poid, wb_name &name)
m_d.oid = pwr_cNOid;
}
//wb_db_name::wb_db_name(wb_db *db, pwr_tOid, char *name) :
// m_db(db), m_key(&m_k, sizeof(m_k)), m_data(&m_d, sizeof(m_d))
//{
//}
wb_db_name::wb_db_name(wb_db *db, pwr_tOid poid, const char *name) :
m_db(db), m_key(&m_k, sizeof(m_k)), m_data(&m_d, sizeof(m_d))
{
......@@ -274,12 +336,6 @@ wb_db_name::wb_db_name(wb_db *db, pwr_tOid poid, const char *name) :
strcpy(m_k.normname, name);
}
//wb_db_name::wb_db_name(wb_db *db, wb_db_txn *txn, pwr_tOid poid, wb_name name) :
// m_db(db), m_key(&m_k, sizeof(m_k)), m_data(&m_d, sizeof(m_d))
//{
//}
int wb_db_name::get(wb_db_txn *txn)
{
m_data.set_ulen(sizeof(m_d));
......@@ -304,7 +360,7 @@ void wb_db_name::name(wb_name &name)
strcpy(m_k.normname, name.normName(cdh_mName_object));
}
void wb_db_name::iter(void (*print)(pwr_tOid poid, pwr_tObjName name, pwr_tOid oid))
void wb_db_name::iter(void (*func)(pwr_tOid poid, pwr_tObjName name, pwr_tOid oid))
{
int rc = 0;
......@@ -314,9 +370,6 @@ void wb_db_name::iter(void (*print)(pwr_tOid poid, pwr_tObjName name, pwr_tOid o
memset(&m_k, 0, sizeof(m_k));
memset(&m_d, 0, sizeof(m_d));
//printf("sizeof(m_k): %d\n", sizeof(m_k));
//printf("sizeof(m_d): %d\n", sizeof(m_d));
m_key.set_data(&m_k);
m_key.set_ulen(sizeof(m_k));
m_key.set_flags(DB_DBT_USERMEM);
......@@ -327,15 +380,9 @@ void wb_db_name::iter(void (*print)(pwr_tOid poid, pwr_tObjName name, pwr_tOid o
/* Walk through the database and print out the key/data pairs. */
//int rc = m_dbc->get(&m_key, &m_data, DB_FIRST);
while ((rc = m_dbc->get(&m_key, &m_data, DB_NEXT)) == 0) {
//printf("k: %d, d: %d\n", (int)m_key.get_size(), (int)m_data.get_size());
//volatile int a = m_key.get_size();
//a = m_data.get_size();
print(m_k.poid, m_k.normname, m_d.oid);
func(m_k.poid, m_k.normname, m_d.oid);
}
m_dbc->close();
......@@ -459,7 +506,7 @@ void wb_db_ohead::clear()
memset(&m_o, 0, sizeof(m_o));
}
void wb_db_ohead::iter(void (*print)(pwr_tOid oid, db_sObject *op))
void wb_db_ohead::iter(void (*func)(pwr_tOid oid, db_sObject *op))
{
int rc = 0;
......@@ -481,7 +528,7 @@ void wb_db_ohead::iter(void (*print)(pwr_tOid oid, db_sObject *op))
/* Walk through the database and print out the key/data pairs. */
while ((rc = m_dbc->get(&m_key, &m_data, DB_NEXT)) == 0) {
print(m_oid, &m_o);
func(m_oid, &m_o);
}
m_dbc->close();
......
/*
* Proview $Id: wb_db.h,v 1.20 2006-05-21 22:30:50 lw Exp $
* Proview $Id: wb_db.h,v 1.21 2006-12-10 14:34:13 lw Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -23,11 +23,8 @@
#include "pwr.h"
#include "db_cxx.h"
#include "wb_import.h"
#include "wb_convert_volume.h"
class wb_name;
class wb_convert_volume;
typedef struct {
pwr_tOid oid; /**< object identifier */
......@@ -234,7 +231,7 @@ public:
void clear();
void iter(void (*print)(pwr_tOid oid, db_sObject *op));
void iter(void (*func)(pwr_tOid oid, db_sObject *op));
void iter(wb_import &i);
};
......@@ -307,8 +304,42 @@ public:
pwr_tCid cid() { return m_k.cid;}
pwr_tOid oid() { return m_k.oid;}
void iter(void (*print)(pwr_tOid oid, pwr_tCid cid));
void iter(wb_convert_volume *cp);
void iter(void (*func)(pwr_tOid oid, pwr_tCid cid));
};
class wb_db_class_iterator
{
struct
{
pwr_tCid cid;
pwr_tOid oid;
} m_k;
wb_db *m_db;
Dbt m_key;
Dbt m_data;
Dbc *m_dbc;
bool m_atEnd;
int m_rc;
public:
wb_db_class_iterator(wb_db *db);
wb_db_class_iterator(wb_db *db, pwr_tCid cid);
wb_db_class_iterator(wb_db *db, pwr_tCid cid, pwr_tOid oid);
~wb_db_class_iterator();
bool atEnd() {return m_atEnd;}
bool first();
bool succObject();
bool succClass();
bool succClass(pwr_tCid cid);
pwr_tOid oid() {return m_k.oid;}
pwr_tCid cid() {return m_k.cid;}
void oid(pwr_tOid oid) {m_k.oid = oid;}
void cid(pwr_tCid cid) {m_k.cid = cid;}
};
class wb_db_dbody
......
This diff is collapsed.
/*
* Proview $Id: wb_vrepdb.h,v 1.31 2006-05-26 11:57:28 lw Exp $
* Proview $Id: wb_vrepdb.h,v 1.32 2006-12-10 14:34:13 lw Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -27,7 +27,7 @@
#include "db_cxx.h"
#include "co_tree.h"
class wb_vrepdb : public wb_vrep, public wb_convert_volume
class wb_vrepdb : public wb_vrep
{
private:
bool deleteFamilyMember(pwr_tOid oid, wb_db_txn *txn);
......@@ -72,14 +72,19 @@ private:
protected:
wb_erep *m_erep;
wb_merep *m_merep;
wb_merep *m_merepCheck;
//wb_merep *m_merepCheck;
unsigned int m_nRef;
char m_fileName[512];
public:
char guard[500];
tree_sTable *m_attribute_th;
tree_sTable *m_aref_th;
tree_sTable *m_class_th;
public:
wb_db *m_db;
wb_db_ohead m_ohead;
......@@ -184,6 +189,12 @@ public:
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);
......@@ -227,8 +238,8 @@ public:
// virtual void checkClassList(pwr_tOid oid, pwr_tCid cid, bool update);
virtual pwr_tStatus updateObject(pwr_tOid oid, pwr_tCid cid);
virtual pwr_tStatus checkObject(pwr_tOid oid, pwr_tCid cid);
int updateObject(pwr_tOid oid, pwr_tCid cid);
//pwr_tStatus checkObject(pwr_tOid oid, pwr_tCid cid);
};
#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