Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
a05a935b
Commit
a05a935b
authored
Dec 10, 2006
by
lw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update attribute referenses at meta data updates
parent
c46a9f2b
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
812 additions
and
253 deletions
+812
-253
src/lib/co/src/co_time.c
src/lib/co/src/co_time.c
+22
-2
src/lib/co/src/co_time.h
src/lib/co/src/co_time.h
+2
-1
src/lib/co/src/co_tree.c
src/lib/co/src/co_tree.c
+7
-1
src/lib/co/src/co_tree.h
src/lib/co/src/co_tree.h
+4
-1
wb/lib/wb/src/wb_bdrep.cpp
wb/lib/wb/src/wb_bdrep.cpp
+20
-1
wb/lib/wb/src/wb_bdrep.h
wb/lib/wb/src/wb_bdrep.h
+3
-2
wb/lib/wb/src/wb_db.cpp
wb/lib/wb/src/wb_db.cpp
+98
-51
wb/lib/wb/src/wb_db.h
wb/lib/wb/src/wb_db.h
+38
-7
wb/lib/wb/src/wb_vrepdb.cpp
wb/lib/wb/src/wb_vrepdb.cpp
+599
-179
wb/lib/wb/src/wb_vrepdb.h
wb/lib/wb/src/wb_vrepdb.h
+19
-8
No files found.
src/lib/co/src/co_time.c
View file @
a05a935b
/**
* Proview $Id: co_time.c,v 1.1
0 2006-05-21 22:30:49
lw Exp $
* Proview $Id: co_time.c,v 1.1
1 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
...
...
src/lib/co/src/co_time.h
View file @
a05a935b
/**
* 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
*
);
...
...
src/lib/co/src/co_tree.c
View file @
a05a935b
/**
* 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
)
{
...
...
src/lib/co/src/co_tree.h
View file @
a05a935b
/**
* 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
);
...
...
wb/lib/wb/src/wb_bdrep.cpp
View file @
a05a935b
/*
* Proview $Id: wb_bdrep.cpp,v 1.1
7 2005-09-06 10:43:30 claes
Exp $
* Proview $Id: wb_bdrep.cpp,v 1.1
8 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
;
...
...
wb/lib/wb/src/wb_bdrep.h
View file @
a05a935b
/*
* Proview $Id: wb_bdrep.h,v 1.1
4 2005-09-06 10:43:30 claes
Exp $
* Proview $Id: wb_bdrep.h,v 1.1
5 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
();
...
...
wb/lib/wb/src/wb_db.cpp
View file @
a05a935b
/*
* Proview $Id: wb_db.cpp,v 1.3
5 2006-05-26 11:57:28
lw Exp $
* Proview $Id: wb_db.cpp,v 1.3
6 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,10 +159,10 @@ 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
;
m_db
->
m_t_class
->
cursor
(
m_db
->
m_txn
,
&
m_dbc
,
0
);
/* Initialize the key/data pair so the flags aren't set. */
...
...
@@ -181,20 +172,41 @@ 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
()
{
if
(
m_dbc
)
m_dbc
->
close
();
}
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
)
{
int
rc
=
0
;
m_rc
=
m_db
->
m_t_class
->
cursor
(
m_db
->
m_txn
,
&
m_dbc
,
0
)
;
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
);
}
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
));
...
...
@@ -203,23 +215,78 @@ 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
);
m_k
.
oid
=
pwr_cNOid
;
m_k
.
cid
=
cid
;
}
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
,
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
();
...
...
wb/lib/wb/src/wb_db.h
View file @
a05a935b
/*
* Proview $Id: wb_db.h,v 1.2
0 2006-05-21 22:30:50
lw Exp $
* Proview $Id: wb_db.h,v 1.2
1 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
...
...
wb/lib/wb/src/wb_vrepdb.cpp
View file @
a05a935b
/*
* Proview $Id: wb_vrepdb.cpp,v 1.
49 2006-06-27 05:52:54 claes
Exp $
* Proview $Id: wb_vrepdb.cpp,v 1.
50 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
...
...
@@ -26,6 +26,8 @@
#include "wb_vrepdb.h"
#include "wb_orepdb.h"
#include "wb_cdrep.h"
#include "wb_bdrep.h"
#include "wb_adrep.h"
#include "wb_erep.h"
#include "wb_dbs.h"
#include "db_cxx.h"
...
...
@@ -36,6 +38,52 @@
#include "co_msgwindow.h"
#include "wb_vrepwbl.h"
typedef
struct
sArefKey
{
pwr_tCid
cid
;
pwr_eBix
bix
;
int
offset
;
}
sArefKey
;
typedef
struct
sAref
{
tree_sNode
node
;
sArefKey
key
;
}
sAref
;
typedef
struct
sAttributeInfo
{
pwr_tAttrRef
aref
;
pwr_tAix
aix
;
pwr_tUInt32
nElement
;
}
sAttributeInfo
;
typedef
struct
sAttributeKey
{
pwr_tCid
cid
;
pwr_eBix
bix
;
pwr_tUInt32
oStart
;
pwr_tUInt32
oEnd
;
}
sAttributeKey
;
typedef
struct
sAttribute
{
tree_sNode
node
;
sAttributeKey
key
;
sAttributeInfo
o
;
sAttributeInfo
n
;
}
sAttribute
;
typedef
struct
sClass
{
tree_sNode
node
;
pwr_tCid
cid
;
pwr_tObjName
name
;
pwr_tTime
o_time
;
pwr_tTime
n_time
;
pwr_tUInt32
count
;
}
sClass
;
static
int
comp_attribute
(
tree_sTable
*
tp
,
tree_sNode
*
x
,
tree_sNode
*
y
);
static
int
comp_aref
(
tree_sTable
*
tp
,
tree_sNode
*
x
,
tree_sNode
*
y
);
void
wb_vrepdb
::
unref
()
{
if
(
--
m_nRef
==
0
)
{
...
...
@@ -50,7 +98,6 @@ wb_vrep *wb_vrepdb::ref()
return
this
;
}
wb_vrepdb
::
wb_vrepdb
(
wb_erep
*
erep
,
const
char
*
fileName
)
:
m_erep
(
erep
),
m_nRef
(
0
),
m_ohead
(),
m_oid_th
(
0
)
{
...
...
@@ -66,11 +113,6 @@ wb_vrepdb::wb_vrepdb(wb_erep *erep, const char *fileName) :
m_merep
=
new
wb_merep
(
m_fileName
,
erep
,
this
);
m_merep
->
compareMeta
(
m_name
,
erep
->
merep
());
#if 0
checkMeta();
updateMeta();
#endif
}
wb_vrepdb
::
wb_vrepdb
(
wb_erep
*
erep
,
pwr_tVid
vid
,
pwr_tCid
cid
,
const
char
*
volumeName
,
const
char
*
fileName
)
:
...
...
@@ -248,20 +290,18 @@ wb_orep* wb_vrepdb::object(pwr_tStatus *sts, pwr_tOid oid)
wb_orep
*
wb_vrepdb
::
object
(
pwr_tStatus
*
sts
,
wb_name
&
name
)
{
*
sts
=
LDH__SUCCESS
;
//*sts = LDH__NYI;
// return 0;
pwr_tOid
poid
;
poid
.
vid
=
m_db
->
m_vid
;
poid
.
oix
=
pwr_cNOix
;
*
sts
=
LDH__SUCCESS
;
try
{
for
(
int
i
=
0
;
name
.
hasSegment
(
i
);
i
++
)
{
wb_db_name
n
(
m_db
,
poid
,
name
.
normSegment
(
i
));
int
rc
=
n
.
get
(
m_db
->
m_txn
);
if
(
rc
)
{
*
sts
=
LDH__NOSUCHOBJ
;
return
0
;
*
sts
=
LDH__NOSUCHOBJ
;
return
0
;
}
poid
=
n
.
oid
();
...
...
@@ -1144,8 +1184,8 @@ wb_orep *wb_vrepdb::nextClass(pwr_tStatus *sts, const wb_orep *orp)
wb_db_class
c
(
m_db
,
m_db
->
m_txn
,
m_ohead
.
cid
());
if
(
c
.
succClass
(
m_ohead
.
cid
()))
{
if
(
c
.
cid
()
==
m_ohead
.
cid
())
{
m_ohead
.
get
(
m_db
->
m_txn
,
c
.
oid
());
return
new
(
this
)
wb_orepdb
(
&
m_ohead
.
m_o
);
m_ohead
.
get
(
m_db
->
m_txn
,
c
.
oid
());
return
new
(
this
)
wb_orepdb
(
&
m_ohead
.
m_o
);
}
}
*
sts
=
LDH__NOSUCHOBJ
;
...
...
@@ -1577,222 +1617,435 @@ bool wb_vrepdb::importPaste()
return
true
;
}
pwr_tStatus
wb_vrepdb
::
checkMeta
()
{
wb_db_class
c
(
m_db
);
char
buff
[
256
];
m_merepCheck
=
m_erep
->
merep
();
m_classCount
=
0
;
m_cidChecked
=
pwr_cNCid
;
m_totalInstanceCount
=
0
;
m_needUpdateCount
=
0
;
pwr_tStatus
sts
=
LDH__SUCCESS
;
pwr_tStatus
db_sts
=
LDH__SUCCESS
;
int
totalObjectCount
=
0
;
int
nAref
=
0
;
int
nClass
=
0
;
m_class_th
=
tree_CreateTable
(
&
sts
,
sizeof
(
pwr_tCid
),
offsetof
(
sClass
,
cid
),
sizeof
(
sClass
),
1000
,
tree_Comp_cid
);
m_aref_th
=
tree_CreateTable
(
&
sts
,
sizeof
(
sArefKey
),
offsetof
(
sAref
,
key
),
sizeof
(
sAref
),
1000
,
comp_aref
);
m_attribute_th
=
tree_CreateTable
(
&
sts
,
sizeof
(
sAttributeKey
),
offsetof
(
sAttribute
,
key
),
sizeof
(
sAttribute
),
1000
,
comp_attribute
);
try
{
wb_db_class_iterator
ip
(
m_db
);
setUpdate
(
false
);
for
(
ip
.
first
();
!
ip
.
atEnd
();
ip
.
succClass
())
{
nClass
+=
checkClass
(
ip
.
cid
());
checkAttributes
(
ip
.
cid
());
}
for
(
ip
.
first
();
!
ip
.
atEnd
();
ip
.
succObject
())
{
pwr_tCid
cid
=
ip
.
cid
();
sClass
*
cp
=
(
sClass
*
)
tree_Find
(
&
sts
,
m_class_th
,
&
cid
);
if
(
!
cp
)
continue
;
cp
->
count
++
;
if
(
time_IsNull
(
&
cp
->
n_time
))
continue
;
}
c
.
iter
(
this
);
}
catch
(
DbException
&
e
)
{
printf
(
"***DbException vrepdb: %s
\n
"
,
e
.
what
());
db_sts
=
LDH__DBERROR
;
}
catch
(
wb_error
&
e
)
{
printf
(
"***wb_error vrepdb: %s
\n
"
,
e
.
what
().
c_str
());
db_sts
=
LDH__DBERROR
;
}
if
(
m_classCount
==
0
)
{
MsgWindow
::
message
(
'W'
,
"Classvolumes need update, execute 'Function->UpdateClasses'"
);
return
LDH__SUCCESS
;
for
(
sClass
*
cp
=
(
sClass
*
)
tree_Minimum
(
&
sts
,
m_class_th
);
cp
!=
NULL
;
cp
=
(
sClass
*
)
tree_Successor
(
&
sts
,
m_class_th
,
cp
)
)
{
char
o_timbuf
[
32
];
char
n_timbuf
[
32
];
if
(
cp
->
count
>
0
)
{
char
buff
[
256
];
if
(
time_IsNull
(
&
cp
->
n_time
))
{
time_AtoAscii
(
&
cp
->
o_time
,
time_eFormat_DateAndTime
,
o_timbuf
,
sizeof
(
o_timbuf
));
sprintf
(
buff
,
"Class
\"
%s
\"
[%s], %d object%s, does not exist in global scope"
,
cp
->
name
,
o_timbuf
,
cp
->
count
,
(
cp
->
count
==
1
?
""
:
"s"
));
MsgWindow
::
message
(
'W'
,
buff
);
}
else
{
time_AtoAscii
(
&
cp
->
o_time
,
time_eFormat_NumDateAndTime
,
o_timbuf
,
sizeof
(
o_timbuf
));
time_AtoAscii
(
&
cp
->
n_time
,
time_eFormat_NumDateAndTime
,
n_timbuf
,
sizeof
(
n_timbuf
));
sprintf
(
buff
,
"Class
\"
%s
\"
[%s], %d object%s, can be updated to [%s]"
,
cp
->
name
,
o_timbuf
,
cp
->
count
,
(
cp
->
count
==
1
?
""
:
"s"
),
n_timbuf
);
MsgWindow
::
message
(
'W'
,
buff
,
msgw_ePop_No
);
totalObjectCount
+=
cp
->
count
;
}
}
}
if
(
ODD
(
db_sts
)
&&
tree_Cardinality
(
&
sts
,
m_class_th
)
!=
0
)
{
char
buff
[
256
];
sprintf
(
buff
,
"A total of %d object%s of %d class%s, and %d attribute reference%s can be updated"
,
totalObjectCount
,
(
totalObjectCount
==
1
?
""
:
"s"
),
tree_Cardinality
(
&
sts
,
m_class_th
),
(
tree_Cardinality
(
&
sts
,
m_class_th
)
==
1
?
""
:
"es"
),
nAref
,
(
nAref
==
1
?
""
:
"s"
));
MsgWindow
::
message
(
'W'
,
buff
,
msgw_ePop_No
);
MsgWindow
::
message
(
'W'
,
"Classvolumes need update, execute 'Function->UpdateClasses'"
);
}
sprintf
(
buff
,
"A total of %d object instances of %d classes can to be updated"
,
m_totalInstanceCount
,
m_classCount
);
tree_DeleteTable
(
&
sts
,
m_attribute_th
);
tree_DeleteTable
(
&
sts
,
m_aref_th
);
tree_DeleteTable
(
&
sts
,
m_class_th
);
MsgWindow
::
message
(
'W'
,
buff
,
msgw_ePop_No
);
MsgWindow
::
message
(
'W'
,
"Classvolumes need update, execute 'Function->UpdateClasses'"
);
return
sts
;
}
static
int
comp_attribute
(
tree_sTable
*
tp
,
tree_sNode
*
x
,
tree_sNode
*
y
)
{
sAttribute
*
xp
=
(
sAttribute
*
)
x
;
sAttribute
*
yp
=
(
sAttribute
*
)
y
;
return
LDH__SUCCESS
;
if
(
xp
->
key
.
cid
>
yp
->
key
.
cid
)
return
1
;
if
(
xp
->
key
.
cid
<
yp
->
key
.
cid
)
return
-
1
;
if
(
xp
->
key
.
bix
>
yp
->
key
.
bix
)
return
1
;
if
(
xp
->
key
.
bix
<
yp
->
key
.
bix
)
return
-
1
;
if
(
xp
->
key
.
oStart
>
yp
->
key
.
oEnd
)
return
1
;
if
(
xp
->
key
.
oEnd
<
yp
->
key
.
oStart
)
return
-
1
;
return
0
;
}
pwr_tStatus
wb_vrepdb
::
updateMeta
()
static
int
comp_aref
(
tree_sTable
*
tp
,
tree_sNode
*
x
,
tree_sNode
*
y
)
{
wb_db_class
c
(
m_db
);
sAref
*
xp
=
(
sAref
*
)
x
;
sAref
*
yp
=
(
sAref
*
)
y
;
if
(
xp
->
key
.
cid
>
yp
->
key
.
cid
)
return
1
;
if
(
xp
->
key
.
cid
<
yp
->
key
.
cid
)
return
-
1
;
if
(
xp
->
key
.
bix
>
yp
->
key
.
bix
)
return
1
;
m_merepCheck
=
m_erep
->
merep
();
m_classCount
=
0
;
m_cidChecked
=
pwr_cNCid
;
m_totalInstanceCount
=
0
;
if
(
xp
->
key
.
bix
<
yp
->
key
.
bix
)
return
-
1
;
if
(
xp
->
key
.
offset
>
yp
->
key
.
offset
)
return
1
;
if
(
xp
->
key
.
offset
<
yp
->
key
.
offset
)
return
-
1
;
return
0
;
}
int
wb_vrepdb
::
updateArefs
(
pwr_tOid
oid
,
pwr_tCid
cid
)
{
pwr_tStatus
sts
;
sArefKey
ak
;
int
nAref
[
2
]
=
{
0
,
0
};
int
rbSize
=
0
;
int
dbSize
=
0
;
int
rrc
=
0
;
int
drc
=
0
;
ak
.
cid
=
cid
;
ak
.
bix
=
pwr_eBix__
;
ak
.
offset
=
0
;
char
*
rp
=
0
;
char
*
dp
=
0
;
sAref
*
ap
=
(
sAref
*
)
tree_FindSuccessor
(
&
sts
,
m_aref_th
,
&
ak
);
setUpdate
(
true
);
if
(
ap
==
0
||
ap
->
key
.
cid
!=
cid
)
return
0
;
try
{
c
.
iter
(
this
);
wb_db_ohead
ohead
(
m_db
,
m_db
->
m_txn
,
oid
);
rbSize
=
ohead
.
rbSize
();
dbSize
=
ohead
.
dbSize
();
wb_db_rbody
rb
(
m_db
,
ohead
.
oid
());
wb_db_dbody
db
(
m_db
,
ohead
.
oid
());
if
(
rbSize
)
{
rp
=
(
char
*
)
calloc
(
1
,
rbSize
);
rrc
=
rb
.
get
(
m_db
->
m_txn
,
0
,
rbSize
,
rp
);
}
if
(
dbSize
)
{
dp
=
(
char
*
)
calloc
(
1
,
dbSize
);
drc
=
db
.
get
(
m_db
->
m_txn
,
0
,
dbSize
,
dp
);
}
}
catch
(
DbException
&
e
)
{
printf
(
"vrepdb: %s
\n
"
,
e
.
what
());
return
LDH__DBERROR
;
ap
=
0
;
}
catch
(
wb_error
&
e
)
{
printf
(
"vrepdb: %s
\n
"
,
e
.
what
().
c_str
());
return
LDH__DBERROR
;
ap
=
0
;
}
if
(
m_classCount
!=
0
)
{
char
buff
[
256
];
sprintf
(
buff
,
"A total of %d object instances of %d classes were updated"
,
m_totalInstanceCount
,
m_classCount
);
MsgWindow
::
message
(
'I'
,
buff
);
while
(
ap
!=
0
&&
ap
->
key
.
cid
==
cid
)
{
char
*
p
=
0
;
if
(
ap
->
key
.
bix
==
pwr_eBix_rt
)
p
=
rp
;
else
if
(
ap
->
key
.
bix
==
pwr_eBix_dev
)
p
=
dp
;
else
p
=
0
;
if
(
p
!=
0
)
{
try
{
pwr_sAttrRef
*
arp
=
(
pwr_sAttrRef
*
)(
p
+
ap
->
key
.
offset
);
wb_db_ohead
aohead
(
m_db
,
m_db
->
m_txn
,
arp
->
Objid
);
wb_cdrep
*
n_cdrep
=
m_erep
->
merep
()
->
cdrep
(
&
sts
,
aohead
.
cid
());
if
(
EVEN
(
sts
))
printf
(
"n_cdrep sts %d"
,
sts
);
wb_bdrep
*
n_bdrep
=
n_cdrep
->
bdrep
(
&
sts
,
ap
->
key
.
bix
);
if
(
EVEN
(
sts
))
printf
(
"n_bdrep sts %d"
,
sts
);
sAttributeKey
k
;
k
.
cid
=
aohead
.
cid
();
k
.
bix
=
ap
->
key
.
bix
;
k
.
oStart
=
arp
->
Offset
;
k
.
oEnd
=
arp
->
Offset
+
arp
->
Size
-
1
;
sAttribute
*
cap
=
(
sAttribute
*
)
tree_Find
(
&
sts
,
m_attribute_th
,
&
k
);
if
(
cap
!=
0
)
{
nAref
[
ap
->
key
.
bix
-
1
]
++
;
if
(
arp
->
Size
>
cap
->
o
.
aref
.
Size
)
{
arp
->
Offset
=
0
;
arp
->
Size
=
n_bdrep
->
size
();
}
else
if
(
arp
->
Offset
==
cap
->
o
.
aref
.
Offset
&&
arp
->
Size
==
cap
->
o
.
aref
.
Size
)
{
arp
->
Offset
=
cap
->
n
.
aref
.
Offset
;
arp
->
Size
=
cap
->
n
.
aref
.
Size
;
}
else
if
(
cap
->
o
.
aref
.
Flags
.
b
.
Array
)
{
pwr_tUInt32
oElementSize
=
cap
->
o
.
aref
.
Size
/
cap
->
o
.
nElement
;
pwr_tUInt32
oOffset
=
arp
->
Offset
-
cap
->
o
.
aref
.
Offset
;
pwr_tUInt32
index
=
oOffset
/
oElementSize
;
pwr_tUInt32
nElementSize
=
cap
->
n
.
aref
.
Size
/
cap
->
n
.
nElement
;
if
(
index
>=
cap
->
n
.
nElement
)
{
index
=
cap
->
n
.
nElement
-
1
;
}
arp
->
Offset
=
cap
->
n
.
aref
.
Offset
+
(
index
*
nElementSize
);
arp
->
Size
=
nElementSize
;
}
}
}
catch
(
DbException
&
e
)
{
//printf("DbException vrepdb updateArefs 2: %s, oid: %d.%d, cid: %d \n", e.what(), oid.vid, oid.oix, cid);
}
catch
(
wb_error
&
e
)
{
//printf("wb_error vrepdb updateArefs 2: oid: %d.%d, cid: %d %s\n", oid.vid, oid.oix, cid, e.what().c_str());
}
}
ap
=
(
sAref
*
)
tree_FindSuccessor
(
&
sts
,
m_aref_th
,
&
ap
->
key
);
}
pwr_tStatus
sts
=
0
;
commit
(
&
sts
);
try
{
wb_db_ohead
ohead
(
m_db
,
m_db
->
m_txn
,
oid
);
wb_db_rbody
rb
(
m_db
,
ohead
.
oid
());
wb_db_dbody
db
(
m_db
,
ohead
.
oid
());
if
(
sts
)
{
MsgWindow
::
message
(
co_error
(
sts
),
"Could not save class updates to database"
);
return
LDH__DBERROR
;
if
(
rbSize
&&
nAref
[
0
])
{
rb
.
put
(
m_db
->
m_txn
,
0
,
rbSize
,
rp
);
}
if
(
dbSize
&&
nAref
[
1
])
{
db
.
put
(
m_db
->
m_txn
,
0
,
dbSize
,
dp
);
}
}
catch
(
DbException
&
e
)
{
//printf("DbException vrepdb updateArefs body.put: oid: %d.%d, cid: %d %s\n", oid.vid, oid.oix, cid, e.what());
}
catch
(
wb_error
&
e
)
{
//printf("wb_error vrepdb updateArefs body.put: oid: %d.%d, cid: %d %s\n", oid.vid, oid.oix, cid, e.what().c_str());
}
m_merep
->
copyFiles
(
m_fileName
,
m_erep
->
merep
());
delete
m_merep
;
m_merep
=
new
wb_merep
(
m_fileName
,
m_erep
,
this
);
return
LDH__SUCCESS
;
if
(
rp
)
free
(
rp
);
if
(
dp
)
free
(
dp
);
return
nAref
[
0
]
+
nAref
[
1
];
}
pwr_tStatus
wb_vrepdb
::
checkObject
(
pwr_tOid
oid
,
pwr_tCid
cid
)
pwr_tStatus
wb_vrepdb
::
updateMeta
(
)
{
static
wb_cdrep
*
o_crep
=
0
;
static
wb_cdrep
*
n_crep
=
0
;
static
bool
skip
=
false
;
int
rc
=
0
;
pwr_tStatus
sts
=
LDH__SUCCESS
;
pwr_tStatus
db_sts
=
LDH__SUCCESS
;
int
nAref
=
0
;
int
nObject
=
0
;
int
nClass
=
0
;
int
totalObjectCount
=
0
;
m_aref_th
=
tree_CreateTable
(
&
sts
,
sizeof
(
sArefKey
),
offsetof
(
sAref
,
key
),
sizeof
(
sAref
),
1000
,
comp_aref
);
m_class_th
=
tree_CreateTable
(
&
sts
,
sizeof
(
pwr_tCid
),
offsetof
(
sClass
,
cid
),
sizeof
(
sClass
),
1000
,
tree_Comp_cid
);
m_attribute_th
=
tree_CreateTable
(
&
sts
,
sizeof
(
sAttributeKey
),
offsetof
(
sAttribute
,
key
),
sizeof
(
sAttribute
),
1000
,
comp_attribute
);
pwr_tTime
o_time
=
{
0
,
0
};
pwr_tTime
n_time
=
{
0
,
0
};
if
(
m_cidChecked
!=
cid
)
{
skip
=
false
;
try
{
wb_db_class_iterator
ip
(
m_db
);
for
(
ip
.
first
();
!
ip
.
atEnd
();
ip
.
succClass
())
{
nClass
+=
checkClass
(
ip
.
cid
());
checkAttributes
(
ip
.
cid
());
}
for
(
ip
.
first
();
!
ip
.
atEnd
();
ip
.
succObject
())
{
pwr_tCid
cid
=
ip
.
cid
();
sClass
*
cp
=
(
sClass
*
)
tree_Find
(
&
sts
,
m_class_th
,
&
cid
);
if
(
!
cp
)
continue
;
cp
->
count
++
;
if
(
time_IsNull
(
&
cp
->
n_time
))
continue
;
nAref
+=
updateArefs
(
ip
.
oid
(),
ip
.
cid
());
nObject
+=
updateObject
(
ip
.
oid
(),
ip
.
cid
());
}
}
catch
(
DbException
&
e
)
{
printf
(
"vrepdb::updateMeta: %s
\n
"
,
e
.
what
());
db_sts
=
LDH__DBERROR
;
}
catch
(
wb_error
&
e
)
{
printf
(
"vrepdb::updateMeta: %s
\n
"
,
e
.
what
().
c_str
());
db_sts
=
LDH__DBERROR
;
}
for
(
sClass
*
cp
=
(
sClass
*
)
tree_Minimum
(
&
sts
,
m_class_th
);
cp
!=
NULL
;
cp
=
(
sClass
*
)
tree_Successor
(
&
sts
,
m_class_th
,
cp
)
)
{
char
o_timbuf
[
32
];
char
n_timbuf
[
32
];
while
(
cid
!=
0
)
{
pwr_tStatus
sts
;
if
(
cp
->
count
>
0
)
{
char
buff
[
256
];
char
o_timbuf
[
32
];
char
n_timbuf
[
32
];
if
(
m_cidChecked
!=
pwr_cNCid
)
{
if
(
n_crep
==
0
)
{
o_time
=
o_crep
->
ohTime
();
time_AtoAscii
(
&
o_time
,
time_eFormat_DateAndTime
,
o_timbuf
,
sizeof
(
o_timbuf
));
sprintf
(
buff
,
"Class
\"
%s
\"
[%s], %d instance%s, does not exist in global scope"
,
o_crep
->
name
(),
o_timbuf
,
m_instanceCount
,
(
m_instanceCount
==
1
?
""
:
"s"
));
MsgWindow
::
message
(
'W'
,
buff
);
}
else
{
o_time
=
o_crep
->
ohTime
();
n_time
=
n_crep
->
ohTime
();
if
(
time_Acomp
(
&
o_time
,
&
n_time
)
!=
0
||
m_instanceCount
)
{
time_AtoAscii
(
&
o_time
,
time_eFormat_DateAndTime
,
o_timbuf
,
sizeof
(
o_timbuf
));
time_AtoAscii
(
&
n_time
,
time_eFormat_DateAndTime
,
n_timbuf
,
sizeof
(
n_timbuf
));
sprintf
(
buff
,
"Class
\"
%s
\"
[%s], %d instance%s, can be updated to [%s]"
,
o_crep
->
name
(),
o_timbuf
,
m_instanceCount
,
(
m_instanceCount
==
1
?
""
:
"s"
),
n_timbuf
);
MsgWindow
::
message
(
'W'
,
buff
,
msgw_ePop_No
);
m_totalInstanceCount
+=
m_instanceCount
;
m_needUpdateCount
++
;
}
}
if
(
time_IsNull
(
&
cp
->
n_time
))
{
time_AtoAscii
(
&
cp
->
o_time
,
time_eFormat_DateAndTime
,
o_timbuf
,
sizeof
(
o_timbuf
));
sprintf
(
buff
,
"Class
\"
%s
\"
[%s], %d object%s, does not exist in global scope"
,
cp
->
name
,
o_timbuf
,
cp
->
count
,
(
cp
->
count
==
1
?
""
:
"s"
));
MsgWindow
::
message
(
'W'
,
buff
);
}
else
{
time_AtoAscii
(
&
cp
->
o_time
,
time_eFormat_NumDateAndTime
,
o_timbuf
,
sizeof
(
o_timbuf
));
time_AtoAscii
(
&
cp
->
n_time
,
time_eFormat_NumDateAndTime
,
n_timbuf
,
sizeof
(
n_timbuf
));
sprintf
(
buff
,
"Class
\"
%s
\"
[%s], %d object%s, %s updated to [%s]"
,
cp
->
name
,
o_timbuf
,
cp
->
count
,
(
cp
->
count
==
1
?
""
:
"s"
),
(
cp
->
count
==
1
?
"was"
:
"were"
),
n_timbuf
);
MsgWindow
::
message
(
'I'
,
buff
,
msgw_ePop_No
);
totalObjectCount
+=
cp
->
count
;
}
}
}
if
(
ODD
(
db_sts
)
&&
tree_Cardinality
(
&
sts
,
m_class_th
)
!=
0
&&
totalObjectCount
>
0
)
{
char
buff
[
256
];
o_crep
=
m_merep
->
cdrep
(
&
sts
,
cid
);
n_crep
=
m_merepCheck
->
cdrep
(
&
sts
,
cid
);
commit
(
&
rc
);
if
(
n_crep
==
0
)
{
break
;
}
o_time
=
o_crep
->
ohTime
();
n_time
=
n_crep
->
ohTime
();
if
(
rc
)
{
sprintf
(
buff
,
"A total of %d object%s of %d classe%s %s updated, but could not be saved to database."
,
nObject
,
(
nObject
==
1
?
""
:
"s"
),
tree_Cardinality
(
&
sts
,
m_class_th
),
(
tree_Cardinality
(
&
sts
,
m_class_th
)
==
1
?
""
:
"s"
),
(
nObject
==
1
?
"was"
:
"were"
));
MsgWindow
::
message
(
co_error
(
rc
),
buff
);
db_sts
=
LDH__DBERROR
;
}
else
{
m_merep
->
copyFiles
(
m_fileName
,
m_erep
->
merep
());
delete
m_merep
;
m_merep
=
new
wb_merep
(
m_fileName
,
m_erep
,
this
);
if
(
time_Acomp
(
&
o_time
,
&
n_time
)
==
0
)
{
skip
=
true
;
break
;
}
sprintf
(
buff
,
"A total of %d object%s of %d class%s, and %d attribute reference%s, %s updated"
,
totalObjectCount
,
(
totalObjectCount
==
1
?
""
:
"s"
),
tree_Cardinality
(
&
sts
,
m_class_th
),
(
tree_Cardinality
(
&
sts
,
m_class_th
)
==
1
?
""
:
"es"
),
nAref
,
(
nAref
==
1
?
""
:
"s"
),
(
nAref
==
1
?
"was"
:
"were"
));
m_classCount
++
;
break
;
MsgWindow
::
message
(
'I'
,
buff
);
}
m_cidChecked
=
cid
;
m_instanceCount
=
0
;
}
if
(
skip
)
return
LDH__SUCCESS
;
m_instanceCount
++
;
return
LDH__SUCCESS
;
tree_DeleteTable
(
&
sts
,
m_attribute_th
);
tree_DeleteTable
(
&
sts
,
m_aref_th
);
tree_DeleteTable
(
&
sts
,
m_class_th
);
return
sts
;
}
pwr_tStatus
wb_vrepdb
::
updateObject
(
pwr_tOid
oid
,
pwr_tCid
cid
)
/* Check if class is changed, return 1 if it is. */
int
wb_vrepdb
::
checkClass
(
pwr_tCid
cid
)
{
static
wb_cdrep
*
o_crep
=
0
;
static
wb_cdrep
*
n_crep
=
0
;
static
bool
skip
=
false
;
pwr_tTime
o_time
=
{
0
,
0
};
pwr_tTime
n_time
=
{
0
,
0
};
pwr_tStatus
sts
;
o_crep
=
m_merep
->
cdrep
(
&
sts
,
cid
);
if
(
o_crep
==
0
)
{
// Class does not exist
return
0
;
}
o_time
=
o_crep
->
ohTime
();
if
(
m_cidChecked
!=
cid
)
{
skip
=
false
;
while
(
cid
!=
0
)
{
pwr_tStatus
sts
;
char
buff
[
256
];
char
o_timbuf
[
32
];
char
n_timbuf
[
32
];
if
(
m_cidChecked
!=
pwr_cNCid
)
{
if
(
n_crep
==
0
)
{
o_time
=
o_crep
->
ohTime
();
time_AtoAscii
(
&
o_time
,
time_eFormat_DateAndTime
,
o_timbuf
,
sizeof
(
o_timbuf
));
sprintf
(
buff
,
"Class
\"
%s
\"
[%s], %d instance%s, does not exist in global scope"
,
o_crep
->
name
(),
o_timbuf
,
m_instanceCount
,
(
m_instanceCount
==
1
?
""
:
"s"
));
}
else
if
(
o_crep
!=
0
)
{
o_time
=
o_crep
->
ohTime
();
n_time
=
n_crep
->
ohTime
();
time_AtoAscii
(
&
o_time
,
time_eFormat_DateAndTime
,
o_timbuf
,
sizeof
(
o_timbuf
));
time_AtoAscii
(
&
n_time
,
time_eFormat_DateAndTime
,
n_timbuf
,
sizeof
(
n_timbuf
));
sprintf
(
buff
,
"Class
\"
%s
\"
[%s], %d instance%s, %s updated to [%s]"
,
o_crep
->
name
(),
o_timbuf
,
m_instanceCount
,
(
m_instanceCount
==
1
?
""
:
"s"
),
(
m_instanceCount
==
1
?
"was"
:
"were"
),
n_timbuf
);
m_totalInstanceCount
+=
m_instanceCount
;
}
MsgWindow
::
message
(
'I'
,
buff
);
}
o_crep
=
m_merep
->
cdrep
(
&
sts
,
cid
);
if
(
o_crep
==
0
)
throw
wb_error
(
sts
);
n_crep
=
m_merepCheck
->
cdrep
(
&
sts
,
cid
);
n_crep
=
m_erep
->
merep
()
->
cdrep
(
&
sts
,
cid
);
if
(
n_crep
!=
0
)
n_time
=
n_crep
->
ohTime
();
if
(
n_crep
==
0
)
{
break
;
}
o_time
=
o_crep
->
ohTime
();
n_time
=
n_crep
->
ohTime
();
if
(
time_Acomp
(
&
o_time
,
&
n_time
)
!=
0
)
{
sClass
*
ccp
=
(
sClass
*
)
tree_Insert
(
&
sts
,
m_class_th
,
&
cid
);
ccp
->
o_time
=
o_time
;
ccp
->
n_time
=
n_time
;
strcpy
(
ccp
->
name
,
o_crep
->
name
());
if
(
time_Acomp
(
&
o_time
,
&
n_time
)
==
0
)
{
skip
=
true
;
break
;
}
m_classCount
++
;
break
;
}
m_cidChecked
=
cid
;
m_instanceCount
=
0
;
return
1
;
}
return
0
;
}
if
(
skip
)
{
return
LDH__SUCCESS
;
int
wb_vrepdb
::
updateObject
(
pwr_tOid
oid
,
pwr_tCid
cid
)
{
pwr_tStatus
sts
;
wb_cdrep
*
n_crep
=
m_erep
->
merep
()
->
cdrep
(
&
sts
,
cid
);
if
(
n_crep
==
0
)
{
return
0
;
}
m_instanceCount
++
;
m_ohead
.
get
(
m_db
->
m_txn
,
oid
);
o_time
=
o_crep
->
ohTime
();
n_time
=
n_crep
->
ohTime
();
if
(
time_Acomp
(
&
o_time
,
&
n_time
)
==
0
)
return
LDH__SUCCESS
;
wb_db_rbody
rb
(
m_db
,
m_ohead
.
oid
());
void
*
rp
=
calloc
(
1
,
m_ohead
.
rbSize
());
...
...
@@ -1806,15 +2059,17 @@ pwr_tStatus wb_vrepdb::updateObject(pwr_tOid oid, pwr_tCid cid)
db
.
get
(
m_db
->
m_txn
,
0
,
m_ohead
.
dbSize
(),
dp
);
void
*
rbody
=
0
;
void
*
dbody
=
0
;
void
*
dbody
=
0
;
pwr_tUInt32
rsize
;
pwr_tUInt32
dsize
;
int
rc
=
0
;
n_crep
->
convertObject
(
m_merep
,
rp
,
dp
,
&
rsize
,
&
dsize
,
&
rbody
,
&
dbody
);
free
(
rp
);
free
(
dp
);
if
(
rp
)
free
(
rp
);
if
(
dp
)
free
(
dp
);
pwr_tTime
time
;
clock_gettime
(
CLOCK_REALTIME
,
&
time
);
...
...
@@ -1841,5 +2096,170 @@ pwr_tStatus wb_vrepdb::updateObject(pwr_tOid oid, pwr_tCid cid)
m_ohead
.
ohTime
(
time
);
m_ohead
.
put
(
m_db
->
m_txn
);
return
LDH__SUCCESS
;
return
1
;
}
void
wb_vrepdb
::
checkAttributes
(
pwr_tCid
cid
)
{
pwr_tStatus
sts
;
wb_cdrep
*
o_cdrep
=
m_merep
->
cdrep
(
&
sts
,
cid
);
if
(
EVEN
(
sts
))
{
// This is really weird, should not happen.
printf
(
"This is weird, class does not exist in old meta data, cid: %d, sts: %d
\n
"
,
cid
,
sts
);
return
;
}
wb_cdrep
*
n_cdrep
=
m_erep
->
merep
()
->
cdrep
(
&
sts
,
cid
);
if
(
EVEN
(
sts
))
{
// The class does not exist in the new version of meta data
return
;
}
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
pwr_eBix
bix
=
i
?
pwr_eBix_dev
:
pwr_eBix_rt
;
wb_bdrep
*
n_bdrep
=
n_cdrep
->
bdrep
(
&
sts
,
bix
);
if
(
ODD
(
sts
))
{
wb_bdrep
*
o_bdrep
=
o_cdrep
->
bdrep
(
&
sts
,
bix
);
if
(
ODD
(
sts
))
{
wb_adrep
*
o_adrep
=
o_bdrep
->
adrep
(
&
sts
);
while
(
ODD
(
sts
))
{
if
(
o_adrep
->
type
()
==
pwr_eType_AttrRef
)
{
sArefKey
a
;
a
.
cid
=
cid
;
a
.
bix
=
bix
;
a
.
offset
=
o_adrep
->
offset
();
tree_Insert
(
&
sts
,
m_aref_th
,
&
a
);
}
// Indentify attribute with the same aix
bool
found
=
false
;
wb_adrep
*
n_adrep
=
n_bdrep
->
adrep
(
&
sts
);
while
(
ODD
(
sts
))
{
if
(
o_adrep
->
aix
()
==
n_adrep
->
aix
())
{
found
=
true
;
break
;
}
wb_adrep
*
prev
=
n_adrep
;
n_adrep
=
n_adrep
->
next
(
&
sts
);
delete
prev
;
}
if
(
found
)
{
if
(
(
o_adrep
->
offset
()
!=
n_adrep
->
offset
())
||
(
o_adrep
->
size
()
!=
n_adrep
->
size
())
||
(
o_adrep
->
type
()
!=
n_adrep
->
type
())
||
//(o_adrep->tid() != n_adrep->tid()) ||
(
o_adrep
->
nElement
()
!=
n_adrep
->
nElement
())
||
(
o_adrep
->
index
()
!=
n_adrep
->
index
())
)
{
sAttributeKey
ak
;
sAttribute
*
ap
;
ak
.
cid
=
cid
;
ak
.
bix
=
bix
;
ak
.
oStart
=
o_adrep
->
offset
();
ak
.
oEnd
=
o_adrep
->
offset
()
+
o_adrep
->
size
()
-
1
;
ap
=
(
sAttribute
*
)
tree_Insert
(
&
sts
,
m_attribute_th
,
&
ak
);
ap
->
o
.
aref
=
o_adrep
->
aref
();
ap
->
n
.
aref
=
n_adrep
->
aref
();
ap
->
o
.
aix
=
o_adrep
->
aix
();
ap
->
n
.
aix
=
n_adrep
->
aix
();
ap
->
o
.
nElement
=
o_adrep
->
nElement
();
ap
->
n
.
nElement
=
n_adrep
->
nElement
();
}
if
(
o_adrep
->
isClass
()
&&
n_adrep
->
subClass
()
==
o_adrep
->
subClass
())
{
checkSubClass
(
o_adrep
->
subClass
(),
o_adrep
->
offset
(),
n_adrep
->
offset
());
}
delete
n_adrep
;
}
wb_adrep
*
prev
=
o_adrep
;
o_adrep
=
o_adrep
->
next
(
&
sts
);
delete
prev
;
}
if
(
o_adrep
)
delete
o_adrep
;
}
if
(
o_bdrep
)
delete
o_bdrep
;
}
if
(
n_bdrep
)
delete
n_bdrep
;
}
}
void
wb_vrepdb
::
checkSubClass
(
pwr_tCid
cid
,
unsigned
int
o_offset
,
unsigned
int
n_offset
)
{
pwr_tStatus
sts
;
wb_cdrep
*
o_cdrep
=
m_merep
->
cdrep
(
&
sts
,
cid
);
if
(
EVEN
(
sts
))
throw
wb_error
(
sts
);
wb_cdrep
*
n_cdrep
=
m_erep
->
merep
()
->
cdrep
(
&
sts
,
cid
);
if
(
EVEN
(
sts
))
return
;
pwr_eBix
bix
=
pwr_eBix_rt
;
wb_bdrep
*
n_bdrep
=
n_cdrep
->
bdrep
(
&
sts
,
bix
);
if
(
EVEN
(
sts
))
return
;
wb_bdrep
*
o_bdrep
=
o_cdrep
->
bdrep
(
&
sts
,
bix
);
if
(
EVEN
(
sts
))
return
;
wb_adrep
*
o_adrep
=
o_bdrep
->
adrep
(
&
sts
);
while
(
ODD
(
sts
))
{
bool
found
=
false
;
wb_adrep
*
n_adrep
=
n_bdrep
->
adrep
(
&
sts
);
while
(
ODD
(
sts
))
{
if
(
o_adrep
->
aix
()
==
n_adrep
->
aix
())
{
found
=
true
;
break
;
}
wb_adrep
*
prev
=
n_adrep
;
n_adrep
=
n_adrep
->
next
(
&
sts
);
delete
prev
;
}
if
(
found
)
{
if
(
(
o_adrep
->
offset
()
!=
n_adrep
->
offset
())
||
(
o_adrep
->
size
()
!=
n_adrep
->
size
())
||
(
o_adrep
->
type
()
!=
n_adrep
->
type
())
||
//(o_adrep->tid() != n_adrep->tid()) ||
(
o_adrep
->
nElement
()
!=
n_adrep
->
nElement
())
||
(
o_adrep
->
index
()
!=
n_adrep
->
index
()))
{
sAttributeKey
ak
;
sAttribute
*
ap
;
ak
.
cid
=
cid
;
ak
.
bix
=
bix
;
ak
.
oStart
=
o_adrep
->
offset
()
+
o_offset
;
ak
.
oEnd
=
ak
.
oStart
+
o_adrep
->
size
()
-
1
;
ap
=
(
sAttribute
*
)
tree_Insert
(
&
sts
,
m_attribute_th
,
&
ak
);
ap
->
o
.
aref
=
o_adrep
->
aref
();
ap
->
n
.
aref
=
n_adrep
->
aref
();
ap
->
o
.
aix
=
o_adrep
->
aix
();
ap
->
n
.
aix
=
n_adrep
->
aix
();
ap
->
o
.
nElement
=
o_adrep
->
nElement
();
ap
->
n
.
nElement
=
n_adrep
->
nElement
();
}
if
(
o_adrep
->
isClass
()
&&
o_adrep
->
subClass
()
==
n_adrep
->
subClass
())
{
checkSubClass
(
n_adrep
->
subClass
(),
o_adrep
->
offset
(),
n_adrep
->
offset
());
}
else
if
(
o_adrep
->
type
()
==
pwr_eType_AttrRef
)
{
sArefKey
a
;
a
.
cid
=
cid
;
a
.
bix
=
bix
;
a
.
offset
=
o_adrep
->
offset
();
tree_Insert
(
&
sts
,
m_aref_th
,
&
a
);
}
if
(
n_adrep
)
delete
n_adrep
;
}
wb_adrep
*
prev
=
o_adrep
;
o_adrep
=
o_adrep
->
next
(
&
sts
);
delete
prev
;
}
if
(
o_cdrep
)
delete
o_cdrep
;
if
(
n_cdrep
)
delete
n_cdrep
;
}
wb/lib/wb/src/wb_vrepdb.h
View file @
a05a935b
/*
* Proview $Id: wb_vrepdb.h,v 1.3
1 2006-05-26 11:57:28
lw Exp $
* Proview $Id: wb_vrepdb.h,v 1.3
2 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
);
...
...
@@ -67,19 +67,24 @@ private:
pwr_tOid
loid
;
}
sDestination
;
sDestination
m_destination
;
sDestination
m_destination
;
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment