Commit a3f49c08 authored by claes's avatar claes

Db classeditor step 1

parent 3900af6b
/*
* Proview $Id: wb_db.cpp,v 1.39 2007-11-22 15:10:23 claes Exp $
* Proview $Id: wb_db.cpp,v 1.40 2007-11-23 14:25:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -497,7 +497,7 @@ void wb_db_ohead::name(pwr_tOid &oid)
{
memset(m_o.name, 0, sizeof(m_o.name));
memset(m_o.normname, 0, sizeof(m_o.normname));
sprintf(m_o.name, "O%d", oid.oix);
sprintf(m_o.name, "O%u", oid.oix);
strcpy(m_o.normname, m_o.name);
}
......@@ -1137,6 +1137,7 @@ pwr_tOid wb_db::new_oid(wb_db_txn *txn, pwr_tOid oid)
try {
wb_db_ohead o(this, txn, woid);
return pwr_cNOid;
} catch (DbException &e) {
pwr_tOix nextoix;
int rc = 0;
......@@ -1155,8 +1156,6 @@ pwr_tOid wb_db::new_oid(wb_db_txn *txn, pwr_tOid oid)
}
return woid;
}
cout << " Old oix found, force new " << woid.oix << " !\n";
return new_oid(txn);
}
int wb_db::del_family(wb_db_txn *txn, Dbc *cp, pwr_tOid poid)
......@@ -1207,7 +1206,10 @@ bool wb_db::commit(pwr_tStatus *sts)
if (rc)
printf("wb_db::commit, CHECK, rc %d\n", rc);
m_env->txn_begin(0, (DbTxn **)&m_txn, 0);
*sts = rc;
if ( rc)
*sts = LDH__DB;
else
*sts = LDH__SUCCESS;
printstat(m_env, "after commit");
return true;
}
......
/*
* Proview $Id: wb_dbms.cpp,v 1.3 2007-10-26 06:26:15 claes Exp $
* Proview $Id: wb_dbms.cpp,v 1.4 2007-11-23 14:25:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -332,6 +332,7 @@ pwr_tOid wb_dbms::new_oid(wb_dbms_txn *txn, pwr_tOid oid)
try {
wb_dbms_ohead o(this, txn, woid);
return pwr_cNOid;
} catch (wb_dbms_error &e) {
pwr_tOix nextoix;
int rc = 0;
......@@ -350,8 +351,6 @@ pwr_tOid wb_dbms::new_oid(wb_dbms_txn *txn, pwr_tOid oid)
}
return woid;
}
cout << " Old oix found, force new " << woid.oix << " !\n";
return new_oid(txn);
}
int wb_dbms::del_family(wb_dbms_txn *txn, wb_dbms_cursor *cp, pwr_tOid poid)
......@@ -399,7 +398,10 @@ bool wb_dbms::commit(pwr_tStatus *sts)
printf("wb_dbms::commit, rc %d\n", rc);
m_env->txn_begin(0, (wb_dbms_txn **)&m_txn);
*sts = rc;
if ( rc)
*sts = LDH__DB;
else
*sts = LDH__SUCCESS;
return true;
}
......@@ -1371,7 +1373,7 @@ void wb_dbms_ohead::name(pwr_tOid &oid)
{
memset(m_o.name, 0, sizeof(m_o.name));
memset(m_o.normname, 0, sizeof(m_o.normname));
sprintf(m_o.name, "O%d", oid.oix);
sprintf(m_o.name, "O%u", oid.oix);
strcpy(m_o.normname, m_o.name);
}
......
/*
* Proview $Id: wb_erep.cpp,v 1.51 2007-08-24 13:39:43 claes Exp $
* Proview $Id: wb_erep.cpp,v 1.52 2007-11-23 14:25:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelösund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -27,6 +27,7 @@
#include "wb_vrepdbs.h"
#include "wb_vrepdb.h"
//#include "wb_vrepdbms.h"
#include "wb_vrepced.h"
#include "wb_vrepref.h"
#include "wb_vrepext.h"
#include "wb_cdrep.h"
......@@ -578,8 +579,9 @@ void wb_erep::loadMeta( pwr_tStatus *status, char *db)
MsgWindow::message( 'E', "Unable to open volume", vname, e.what().c_str());
}
}
else if ( (cdh_NoCaseStrcmp( vol_array[2], "ClassVolume") == 0) ||
(strcmp( vol_array[3], "load") == 0)) {
else if ( (cdh_NoCaseStrcmp( vol_array[2], "ClassVolume") == 0 &&
strcmp( vol_array[0], "ClaesClassVolume") != 0) ||
(strcmp( vol_array[3], "load") == 0)) {
if ( nr != 4)
cout << "Syntax error in file: " << fname << endl;
......@@ -741,12 +743,26 @@ void wb_erep::loadMeta( pwr_tStatus *status, char *db)
}
}
else {
// Ced Test !!!
if ( strcmp( vol_array[0], "ClaesClassVolume") == 0) {
wb_vrepdb *vrepdb = new wb_vrepdb( this, vname);
wb_vrepced *vrepced = new wb_vrepced( this, vrepdb);
vrepced->name(vol_array[0]);
addDb( &sts, vrepced);
MsgWindow::message( 'I', "Classvolume Database opened", vname);
vol_cnt++;
}
else {
// End Ced Test !!!
// Open db
wb_vrepdb *vrepdb = new wb_vrepdb( this, vname);
vrepdb->name(vol_array[0]);
addDb( &sts, vrepdb);
MsgWindow::message( 'I', "Database opened", vname);
vol_cnt++;
}
}
}
}
......
/*
* Proview $Id: wb_ldh.cpp,v 1.62 2007-10-25 11:07:12 claes Exp $
* Proview $Id: wb_ldh.cpp,v 1.63 2007-11-23 14:25:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -1605,7 +1605,8 @@ ldh_RevertSession(ldh_tSession session)
{
wb_session *sp = (wb_session*)session;
return sp->abort();
sp->abort();
return sp->sts();
}
/* Save all changes to objects done in the session. */
......@@ -1615,7 +1616,8 @@ ldh_SaveSession(ldh_tSession session)
{
wb_session *sp = (wb_session*)session;
return sp->commit();
sp->commit();
return sp->sts();
}
ldh_tVolume
......
/*
* Proview $Id: wb_lfu.cpp,v 1.7 2007-09-17 07:09:23 claes Exp $
* Proview $Id: wb_lfu.cpp,v 1.8 2007-11-23 14:25:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -917,25 +917,59 @@ pwr_tStatus lfu_SaveDirectoryVolume(
break;
}
case pwr_cClass_ClassVolumeConfig : {
// Check wbload-file...
FILE *wblfile;
sprintf( fname, "$pwrp_db/%s.wb_load", volume_name);
cdh_ToLower( fname, fname);
dcli_translate_filename( fname, fname);
wblfile = fopen( fname, "r");
if ( wblfile == 0) {
wblfile = fopen( fname, "w");
if ( wblfile == 0) {
// Ced Test !!!!!!!!!!! TODO
if ( strcmp( volume_name, "ClaesClassVolume") == 0) {
/* Check if the databas is created */
sprintf( filename, "$pwrp_db/%s.db/info", volume_name);
cdh_ToLower( filename, filename);
dcli_translate_filename( filename, filename);
sts = dcli_search_file( filename, found_file, DCLI_DIR_SEARCH_INIT);
dcli_search_file( filename, found_file, DCLI_DIR_SEARCH_END);
if (EVEN(sts)) {
if ( wow) {
lfu_sCreaDb *data;
data = (lfu_sCreaDb *) calloc( 1, sizeof(*data));
strcpy( data->name, volumelist_ptr->volume_name);
data->vid = volumelist_ptr->volume_id;
data->cid = pwr_eClass_ClassVolume;
data->ldhses = ldhses;
sprintf( text, " ClassVolume '%s' is not yet created.\n \n\
Do you want to create this volume.\n",
volume_name);
wow->DisplayQuestion( NULL,
"Create Classvolume", text,
lfu_creadb_qb_yes, NULL, (void *)data);
}
}
else {
char msg[200];
sprintf( msg, "Error, unable to create file %s, ", fname);
sprintf( msg, "Error, Volume '%s' is not yet created.",
volume_name);
MsgWindow::message( 'E', msg, msgw_ePop_Default);
break;
}
}
}
else {
// Check wbload-file...
FILE *wblfile;
sprintf( fname, "$pwrp_db/%s.wb_load", volume_name);
cdh_ToLower( fname, fname);
dcli_translate_filename( fname, fname);
wblfile = fopen( fname, "r");
if ( wblfile == 0) {
wblfile = fopen( fname, "w");
if ( wblfile == 0) {
char msg[200];
sprintf( msg, "Error, unable to create file %s, ", fname);
MsgWindow::message( 'E', msg, msgw_ePop_Default);
break;
}
fprintf( wblfile, "Volume %s pwr_eClass_ClassVolume %s\nEndVolume\n",
volume_name, cdh_VolumeIdToString( 0, volumelist_ptr->volume_id, 0, 0));
fclose( wblfile);
fprintf( wblfile, "Volume %s pwr_eClass_ClassVolume %s\nEndVolume\n",
volume_name, cdh_VolumeIdToString( 0, volumelist_ptr->volume_id, 0, 0));
fclose( wblfile);
}
}
break;
}
......
/*
* Proview $Id: wb_orepced.cpp,v 1.1 2007-11-23 14:25:09 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.
**/
#include "wb_orepced.h"
wb_orepced::wb_orepced( wb_vrepced *v, wb_orep *n): m_vrep(v), m_orep(n)
{}
wb_orepced::~wb_orepced()
{
}
//
// Operations declared in wb_Orep
//
pwr_tOid wb_orepced::oid() const
{
return m_orep->oid();
}
pwr_tVid wb_orepced::vid() const
{
return m_orep->vid();
}
pwr_tOix wb_orepced::oix() const
{
return m_orep->oix();
}
pwr_tOix wb_orepced::cid() const
{
return m_orep->cid();
}
pwr_tOid wb_orepced::poid() const
{
return m_orep->poid();
}
pwr_tOid wb_orepced::foid() const
{
return m_orep->foid();
}
pwr_tOid wb_orepced::loid() const
{
return m_orep->loid();
}
pwr_tOid wb_orepced::boid() const
{
return m_orep->boid();
}
pwr_tOid wb_orepced::aoid() const
{
return m_orep->aoid();
}
const char * wb_orepced::name() const
{
return m_orep->name();
}
wb_name wb_orepced::longName()
{
return m_orep->longName();
}
pwr_tTime wb_orepced::ohTime() const
{
return m_orep->ohTime();
}
pwr_tTime wb_orepced::rbTime() const
{
return m_orep->rbTime();
}
pwr_tTime wb_orepced::dbTime() const
{
return m_orep->dbTime();
}
pwr_mClassDef wb_orepced::flags() const
{
return m_orep->flags();
}
bool wb_orepced::isOffspringOf(const wb_orep *o) const
{
return m_orep->isOffspringOf( o);
}
wb_orep *wb_orepced::ancestor(pwr_tStatus *sts)
{
return m_orep->ancestor( sts);
}
wb_orep *wb_orepced::parent(pwr_tStatus *sts)
{
return m_orep->parent( sts);
}
wb_orep *wb_orepced::after(pwr_tStatus *sts)
{
return m_orep->after( sts);
}
wb_orep *wb_orepced::before(pwr_tStatus *sts)
{
return m_orep->before( sts);
}
wb_orep *wb_orepced::first(pwr_tStatus *sts)
{
return m_orep->first( sts);
}
wb_orep *wb_orepced::child(pwr_tStatus *sts, wb_name &name)
{
return m_orep->child( sts, name);
}
wb_orep *wb_orepced::last(pwr_tStatus *sts)
{
return m_orep->last( sts);
}
wb_orep *wb_orepced::next(pwr_tStatus *sts)
{
return m_orep->next( sts);
}
wb_orep *wb_orepced::previous(pwr_tStatus *sts)
{
return m_orep->previous( sts);
}
wb_adrep *wb_orepced::attribute(pwr_tStatus* sts, const char *aname)
{
return m_orep->attribute( sts, aname);
}
wb_adrep *wb_orepced::attribute(pwr_tStatus* sts)
{
return m_orep->attribute( sts);
}
bool wb_orepced::docBlock( char **block, int *size) const
{
return m_orep->docBlock( block, size);
}
bool wb_orepced::docBlock( char *block)
{
return m_orep->docBlock( block);
}
/*
* Proview $Id: wb_orepced.h,v 1.1 2007-11-23 14:25:09 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_orepced_h
#define wb_orepced_h
#include "wb_orep.h"
#include "wb_vrepced.h"
#include "pwr.h"
class wb_orepced : public wb_orep
{
wb_vrepced *m_vrep;
unsigned int m_refCount;
wb_orep *m_orep;
public:
wb_orepced(int oix);
wb_orepced( wb_vrepced *v, wb_orep *n);
~wb_orepced();
// void* operator new(size_t size, wb_vrepced *v);
// void operator delete(void *p, size_t size, wb_vrepced *v);
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
wb_orep *ancestor(pwr_tStatus *sts); //< get object at top of hierarchy
wb_orep *parent(pwr_tStatus *sts);
wb_orep *after(pwr_tStatus *sts); //< get next sibling
wb_orep *before(pwr_tStatus *sts); //< get previous sibling
wb_orep *first(pwr_tStatus *sts); //< get first child
wb_orep *child(pwr_tStatus *sts, wb_name &name); //< get named child
wb_orep *last(pwr_tStatus *sts); //< get last child
wb_orep *next(pwr_tStatus *sts); //< get next in list of objects of same class in one volume
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_Ced;}
virtual bool docBlock( char **block, int *size) const;
virtual bool docBlock( char *block);
};
#endif
/*
* Proview $Id: wb_vrep.h,v 1.27 2006-06-08 13:39:33 claes Exp $
* Proview $Id: wb_vrep.h,v 1.28 2007-11-23 14:25:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -93,7 +93,7 @@ public:
virtual wb_orep *object(pwr_tStatus *sts, const wb_orep *parent, wb_name &name) = 0;
virtual wb_orep *object(pwr_tStatus *sts, pwr_tCid cid) = 0;
virtual wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name) = 0;
virtual wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name, pwr_tOix oix = 0) = 0;
virtual wb_orep *copyObject(pwr_tStatus *sts, const wb_orep *orep, wb_destination &d, wb_name &name) = 0;
virtual bool copyOset(pwr_tStatus *sts, wb_oset *oset, wb_destination &d) = 0;
......
/*
* Proview $Id: wb_vrepced.cpp,v 1.1 2007-11-23 14:25:09 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.
**/
#include <iostream>
#include <fstream>
#include <sys/stat.h>
#include "wb_vrepced.h"
#include "wb_orepced.h"
#include "wb_ldh_msg.h"
#include "wb_dbs.h"
#include "wb_bdrep.h"
#include "wb_cdrep.h"
#include "wb_attribute.h"
#include "wb_erep.h"
#include "wb_merep.h"
#include "wb_tdrep.h"
#include "wb_ldh_msg.h"
#include "wb_vrepwbl.h"
#include "wb_vrepref.h"
#include "wb_print_wbl.h"
#include "wb_volume.h"
#include "wb_palfile.h"
#include "pwr_baseclasses.h"
#include "co_msgwindow.h"
#include "co_tree.h"
#include "co_dcli.h"
typedef struct sTypeBuild
{
tree_sNode node;
pwr_tTid tid;
int built;
int build_started;
} sTypeBuild;
typedef struct sClassBuild
{
tree_sNode node;
pwr_tCid cid;
int built;
int build_started;
} sClassBuild;
wb_vrepced::~wb_vrepced()
{
m_vrep->unref();
m_erep->resetRefMerep();
}
void wb_vrepced::unref()
{
if (--m_nRef == 0)
delete this;
}
void wb_vrepced::name( const char *n)
{
strcpy( m_name, n);
m_vrep->name( n);
}
wb_vrep *wb_vrepced::ref()
{
m_nRef++;
return this;
}
wb_orep *wb_vrepced::createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name, pwr_tOix oix)
{
wb_orep *dest;
ldh_eDest code = d.code();
pwr_tObjName name_str;
pwr_tOix soix = 0;
dest = m_vrep->object( sts, d.oid());
if ( !dest) {
*sts = LDH__BADDEST;
return 0;
}
classeditorCheck( code, dest, cdef.cid(), &soix, name_str, sts, false);
if ( EVEN( *sts)) return 0;
wb_name n( name_str);
return m_vrep->createObject( sts, cdef, d, n, soix);
}
wb_orep *wb_vrepced::copyObject(pwr_tStatus *sts, const wb_orep *orep, wb_destination &d, wb_name &name)
{
return m_vrep->copyObject( sts, orep, d, name);
}
bool wb_vrepced::moveObject(pwr_tStatus *sts, wb_orep *orep, wb_destination &d)
{
return m_vrep->moveObject( sts, orep, d);
}
bool wb_vrepced::deleteObject(pwr_tStatus *sts, wb_orep *orep)
{
return m_vrep->deleteObject( sts, orep);
}
bool wb_vrepced::deleteFamily(pwr_tStatus *sts, wb_orep *orep)
{
return m_vrep->deleteFamily( sts, orep);
}
bool wb_vrepced::renameObject(pwr_tStatus *sts, wb_orep *orep, wb_name &name)
{
return m_vrep->renameObject( sts, orep, name);
}
bool wb_vrepced::writeAttribute(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, size_t offset, size_t size, void *p)
{
return m_vrep->writeAttribute( sts, o, bix, offset, size, p);
}
bool wb_vrepced::writeBody(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, void *p)
{
return m_vrep->writeBody( sts, o, bix, p);
}
bool wb_vrepced::createSnapshot(const char *fileName, const pwr_tTime *time)
{
return m_vrep->createSnapshot( fileName, time);
}
bool wb_vrepced::commit(pwr_tStatus *sts)
{
m_typebuild_th = tree_CreateTable(sts, sizeof(pwr_tTid), offsetof(sTypeBuild, tid),
sizeof(sTypeBuild), 1000, tree_Comp_tid);
m_classbuild_th = tree_CreateTable(sts, sizeof(pwr_tCid), offsetof(sClassBuild, cid),
sizeof(sClassBuild), 1000, tree_Comp_cid);
wb_orep *to = m_vrep->object( sts, pwr_eClass_TypeDef);
while ( ODD(*sts)) {
to->ref();
pwr_tTid tid = cdh_TypeObjidToId( to->oid());
tree_Insert( sts, m_typebuild_th, &tid);
wb_orep *to_next = to->next( sts);
to->unref();
to = to_next;
}
wb_orep *co = m_vrep->object( sts, pwr_eClass_ClassDef);
while ( ODD(*sts)) {
co->ref();
pwr_tCid cid = cdh_ClassObjidToId( co->oid());
tree_Insert( sts, m_classbuild_th, &cid);
wb_orep *co_next = co->next( sts);
co->unref();
co = co_next;
}
m_errorCount = 0;
for (
sTypeBuild *tp = (sTypeBuild *)tree_Minimum( sts, m_typebuild_th);
tp != NULL;
tp = (sTypeBuild *)tree_Successor( sts, m_typebuild_th, tp)
) {
if ( !tp->built) {
wb_orep *to = m_vrep->object( sts, cdh_TypeIdToObjid( tp->tid));
if ( !buildType( sts, to))
return false;
}
}
for (
sClassBuild *cp = (sClassBuild *)tree_Minimum( sts, m_classbuild_th);
cp != NULL;
cp = (sClassBuild *)tree_Successor( sts, m_classbuild_th, cp)
) {
if ( !cp->built) {
wb_orep *co = m_vrep->object( sts, cdh_ClassIdToObjid( cp->cid));
if ( !buildClass( sts, co))
return false;
}
}
if ( m_errorCount) {
char msg[80];
sprintf( msg, "ClassVolume syntax error, %d errors found", m_errorCount);
MsgWindow::message( 'E', msg, msgw_ePop_Yes);
}
tree_DeleteTable(sts, m_classbuild_th);
m_vrep->commit( sts);
*sts = LDH__SUCCESS;
return true;
}
bool wb_vrepced::abort(pwr_tStatus *sts)
{
return m_vrep->abort( sts);
}
bool wb_vrepced::nextCix( pwr_tStatus *sts, pwr_tOix *cix)
{
pwr_tOid oid;
oid.vid = m_vid;
oid.oix = 0;
wb_orep *o = m_vrep->object( sts, oid);
if ( EVEN(*sts)) return false;
o->ref();
m_vrep->readAttribute( sts, o, pwr_eBix_sys, offsetof( pwr_sClassVolume, NextCix),
sizeof(*cix), cix);
if ( ODD(*sts)) {
(*cix)++;
m_vrep->writeAttribute( sts, o, pwr_eBix_sys, offsetof( pwr_sClassVolume, NextCix),
sizeof(*cix), cix);
}
o->unref();
return ODD(*sts);
}
bool wb_vrepced::nextTix( pwr_tStatus *sts, pwr_tOix *tix)
{
pwr_tOid oid;
oid.vid = m_vid;
oid.oix = 0;
wb_orep *o = m_vrep->object( sts, oid);
if ( EVEN(*sts)) return false;
o->ref();
m_vrep->readAttribute( sts, o, pwr_eBix_sys, offsetof( pwr_sClassVolume, NextTix),
sizeof(*tix), tix);
if ( ODD(*sts)) {
(*tix)++;
m_vrep->writeAttribute( sts, o, pwr_eBix_sys, offsetof( pwr_sClassVolume, NextTix),
sizeof(*tix), tix);
}
o->unref();
return ODD(*sts);
}
bool wb_vrepced::nextAix( pwr_tStatus *sts, wb_orep *co, pwr_tOix *aix)
{
m_vrep->readAttribute( sts, co, pwr_eBix_sys, offsetof( pwr_sObjBodyDef, NextAix),
sizeof(*aix), aix);
if ( ODD(*sts)) {
(*aix)++;
m_vrep->writeAttribute( sts, co, pwr_eBix_sys, offsetof( pwr_sObjBodyDef, NextAix),
sizeof(*aix), aix);
}
return ODD(*sts);
}
bool wb_vrepced::classeditorCheck( ldh_eDest dest_code, wb_orep *dest, pwr_tCid cid,
pwr_tOix *oix, char *name, pwr_tStatus *sts,
bool import_paste)
{
wb_orep *fth;
// Get father
switch ( dest_code) {
case ldh_eDest_After:
case ldh_eDest_Before:
fth = dest->parent( sts);
break;
case ldh_eDest_IntoFirst:
case ldh_eDest_IntoLast:
fth = dest;
break;
default:
return false;
}
if ( fth)
fth->ref();
if ( fth) {
switch ( fth->cid()) {
case pwr_eClass_ObjBodyDef:
switch ( cid) {
case pwr_eClass_Param:
case pwr_eClass_Intern:
case pwr_eClass_Input:
case pwr_eClass_Output:
case pwr_eClass_ObjXRef:
case pwr_eClass_AttrXRef:
case pwr_eClass_Buffer:
break;
default:
*sts = LDH__CLASSMISPLACED;
return false;
}
break;
case pwr_eClass_ClassDef:
switch ( cid) {
case pwr_eClass_ObjBodyDef:
case pwr_eClass_GraphPlcNode:
case pwr_eClass_GraphPlcConnection:
case pwr_eClass_GraphPlcWindow:
case pwr_eClass_GraphPlcProgram:
case pwr_eClass_RtMenu:
case pwr_eClass_Menu:
case pwr_eClass_RtMethod:
case pwr_eClass_Method:
case pwr_eClass_DbCallBack:
case pwr_cClass_PlcTemplate:
break;
default:
*sts = LDH__CLASSMISPLACED;
return false;
}
break;
case pwr_eClass_ClassHier:
switch ( cid) {
case pwr_eClass_ClassDef:
break;
default:
*sts = LDH__CLASSMISPLACED;
return false;
}
break;
case pwr_eClass_TypeHier:
switch ( cid) {
case pwr_eClass_Type:
case pwr_eClass_TypeDef:
break;
default:
*sts = LDH__CLASSMISPLACED;
return false;
}
break;
case pwr_eClass_TypeDef:
switch ( cid) {
case pwr_eClass_Bit:
case pwr_eClass_Value:
break;
default:
*sts = LDH__CLASSMISPLACED;
return false;
}
break;
default: ;
}
}
switch ( cid) {
case pwr_eClass_ClassHier: {
// Top object, named Class
if ( fth && fth->oid().oix != 0) {
*sts = LDH__CLASSMISPLACED;
return false;
}
if ( !import_paste) {
strcpy( name, "Class");
}
*oix = 0;
break;
}
case pwr_eClass_TypeHier: {
// Top object, named Type
if ( fth && fth->oid().oix != 0) {
*sts = LDH__CLASSMISPLACED;
return false;
}
if ( !import_paste) {
strcpy( name, "Type");
}
*oix = 0;
break;
}
case pwr_eClass_ClassDef: {
// Child to ClassHier, oix from cix
pwr_tOix cix;
if ( !fth || fth->cid() != pwr_eClass_ClassHier) {
*sts = LDH__CLASSMISPLACED;
return false;
}
// Get next cix
nextCix( sts, &cix);
if ( EVEN(*sts)) return false;
while ( 1) {
pwr_tOid oid;
wb_orep *o;
*oix = cdh_cixToOix( cix, 0, 0);
if ( EVEN(*sts)) return false;
oid.oix = *oix;
oid.vid = m_vid;
if ( (o = m_vrep->object( sts, oid))) {
// oix already exist, try next cix
o->ref();
o->unref();
nextCix( sts, &cix);
if ( EVEN(*sts)) return false;
}
else
break;
}
if ( !import_paste)
sprintf( name, "O%u", *oix);
break;
}
case pwr_eClass_TypeDef: {
// Child to TypeHier, oix from tix
pwr_tOix tix;
if ( !fth || fth->cid() != pwr_eClass_TypeHier) {
*sts = LDH__CLASSMISPLACED;
return false;
}
// Get next tix
nextTix( sts, &tix);
if ( EVEN(*sts)) return false;
while ( 1) {
pwr_tOid oid;
wb_orep *o;
*oix = cdh_tixToOix( tix, 0);
if ( EVEN(*sts)) return false;
oid.oix = *oix;
oid.vid = m_vid;
if ( (o = m_vrep->object( sts, oid))) {
// oix already exist, try next tix
o->ref();
o->unref();
nextTix( sts, &tix);
if ( EVEN(*sts)) return false;
}
else
break;
}
if ( !import_paste)
sprintf( name, "O%u", *oix);
break;
}
case pwr_eClass_ObjBodyDef: {
// Child to ClassDef, oix from bix, named RtBody or DevBody
if ( !fth || fth->cid() != pwr_eClass_ClassDef) {
*sts = LDH__CLASSMISPLACED;
return false;
}
if ( !import_paste) {
bool rtbody_found = false;
bool devbody_found = false;
wb_orep *child = fth->first( sts);
while ( ODD(*sts)) {
child->ref();
if ( child->cid() == pwr_eClass_ObjBodyDef) {
if ( cdh_oixToBix( child->oid().oix) == pwr_eBix_rt)
rtbody_found = true;
else if ( cdh_oixToBix( child->oid().oix) == pwr_eBix_dev)
devbody_found = true;
}
wb_orep *next_child = child->after( sts);
child->unref();
child = next_child;
}
if ( !rtbody_found) {
*oix = cdh_cixToOix( cdh_oixToCix(fth->oid().oix), pwr_eBix_rt, 0);
pwr_tOid woid;
woid.oix = *oix;
woid.vid = m_vid;
wb_orep *check = m_vrep->object( sts, woid);
if ( ODD(sts)) {
*sts = LDH__CLASSMISPLACED;
check->ref();
check->unref();
return false;
}
strcpy( name, "RtBody");
}
else if ( !devbody_found) {
*oix = cdh_cixToOix( cdh_oixToCix(fth->oid().oix), pwr_eBix_dev, 0);
wb_orep *check = m_vrep->object( sts, *oix);
if ( ODD(sts)) {
*sts = LDH__CLASSMISPLACED;
check->ref();
check->unref();
return false;
}
strcpy( name, "DevBody");
}
else {
*sts = LDH__CLASSMISPLACED;
return false;
}
}
else {
// Use the name to choose oix
if ( strcmp( name, "DevBody") == 0)
*oix = cdh_cixToOix( cdh_oixToCix(fth->oid().oix), pwr_eBix_dev, 0);
else
*oix = cdh_cixToOix( cdh_oixToCix(fth->oid().oix), pwr_eBix_rt, 0);
pwr_tOid woid;
woid.oix = *oix;
woid.vid = m_vid;
wb_orep *check = m_vrep->object( sts, woid);
if ( ODD(sts)) {
*sts = LDH__CLASSMISPLACED;
check->ref();
check->unref();
return false;
}
}
break;
}
case pwr_eClass_Param:
case pwr_eClass_Input:
case pwr_eClass_Output:
case pwr_eClass_Intern:
case pwr_eClass_ObjXRef:
case pwr_eClass_AttrXRef:
case pwr_eClass_Buffer: {
// Child to ObjBodyDef, oix from aix
if ( !fth || fth->cid() != pwr_eClass_ObjBodyDef) {
*sts = LDH__CLASSMISPLACED;
return false;
}
pwr_tOix aix;
nextAix( sts, fth, &aix);
if ( EVEN(*sts)) return false;
while( 1) {
*oix = cdh_cixToOix( cdh_oixToCix(fth->oid().oix), cdh_oixToBix(fth->oid().oix),
aix);
pwr_tOid woid;
woid.oix = *oix;
woid.vid = m_vid;
wb_orep *check = m_vrep->object( sts, woid);
if ( EVEN(*sts))
break;
else {
check->ref();
check->unref();
nextAix( sts, fth, &aix);
if ( EVEN(*sts)) return false;
}
}
if ( !import_paste)
sprintf( name, "O%u", *oix);
break;
}
case pwr_cClass_PlcTemplate: {
// Child to ClassDef, named Code
if ( !fth || fth->cid() != pwr_eClass_ClassDef) {
*sts = LDH__CLASSMISPLACED;
return false;
}
if ( !import_paste) {
strcpy( name, "Code");
}
*oix = 0;
break;
}
case pwr_eClass_GraphPlcNode: {
// Child to ClassDef, named GraphPlcNode
if ( !fth || fth->cid() != pwr_eClass_ClassDef) {
*sts = LDH__CLASSMISPLACED;
return false;
}
if ( !import_paste) {
strcpy( name, "GraphPlcNode");
}
*oix = 0;
break;
}
default:
*oix = 0;
}
if ( fth)
fth->unref();
*sts = LDH__SUCCESS;
return true;
}
void wb_vrepced::error( char *msg, wb_orep *o)
{
char text[400];
sprintf( text, "%s, %s", msg, o->longName().c_str());
MsgWindow::message( 'E', text, msgw_ePop_No, o->oid());
m_errorCount++;
}
bool wb_vrepced::buildType( pwr_tStatus *sts, wb_orep *to)
{
pwr_tTid typeref;
pwr_tInt32 type;
pwr_tUInt32 elements;
pwr_tUInt32 size;
pwr_tTid totid = cdh_TypeObjidToId( to->oid());
sTypeBuild *tp = (sTypeBuild *)tree_Find( sts, m_typebuild_th, &totid);
if ( !tp) return false;
if ( tp->build_started) {
error( "Circular type dependency detected", to);
return false;
}
tp->build_started = 1;
m_vrep->readAttribute( sts, to, pwr_eBix_sys, offsetof( pwr_sTypeDef, TypeRef),
sizeof(typeref), &typeref);
if ( EVEN(*sts)) return false;
m_vrep->readAttribute( sts, to, pwr_eBix_sys, offsetof( pwr_sTypeDef, Elements),
sizeof(elements), &elements);
if ( EVEN(*sts)) return false;
// Check if typeref in this volume
if ( cdh_TidToVid( typeref) == m_vid) {
sTypeBuild *tpt = (sTypeBuild *)tree_Find( sts, m_typebuild_th, &typeref);
if ( !tpt) {
error( "Error in TypeRef", to);
return false;
}
wb_orep *tot = m_vrep->object( sts, cdh_TypeIdToObjid( typeref));
if ( !tot)
return false;
if ( !tpt->built) {
if ( !buildType( sts, tot))
return false;
}
m_vrep->readAttribute( sts, tot, pwr_eBix_sys, offsetof( pwr_sTypeDef, Size),
sizeof(size), &size);
if ( EVEN(*sts)) return false;
m_vrep->readAttribute( sts, tot, pwr_eBix_sys, offsetof( pwr_sTypeDef, Type),
sizeof(type), &type);
if ( EVEN(*sts)) return false;
size = size * elements;
}
else {
wb_tdrep *td = m_vrep->merep()->tdrep( sts, typeref);
if ( EVEN(*sts)) {
error( "Error in TypeRef", to);
return false;
}
if ( elements < 1)
elements = 1;
size = td->size() * elements;
type = td->type();
delete td;
}
// Store data in typedef object
m_vrep->writeAttribute( sts, to, pwr_eBix_sys, offsetof( pwr_sTypeDef, Size),
sizeof(size), &size);
if ( EVEN(*sts)) return false;
m_vrep->writeAttribute( sts, to, pwr_eBix_sys, offsetof( pwr_sTypeDef, Elements),
sizeof(elements), &elements);
if ( EVEN(*sts)) return false;
m_vrep->writeAttribute( sts, to, pwr_eBix_sys, offsetof( pwr_sTypeDef, Type),
sizeof(type), &type);
if ( EVEN(*sts)) return false;
tp->built = 1;
return true;
}
bool wb_vrepced::buildClass( pwr_tStatus *sts, wb_orep *co)
{
pwr_tOid oid;
pwr_tStatus asts;
pwr_tUInt32 numofobjbodies = 0;
bool has_rtbody = false;
bool has_objxref = false;
bool has_objref = false;
bool has_attrref = false;
bool has_attrxref = false;
pwr_tCid cocid = cdh_ClassObjidToId( co->oid());
sClassBuild *cp = (sClassBuild *)tree_Find( sts, m_classbuild_th, &cocid);
if ( !cp) return false;
if ( cp->build_started) {
error( "Circular class dependency detected", co);
return false;
}
cp->build_started = 1;
for ( int i = 0; i < 2; i++) {
pwr_tUInt32 offset = 0;
pwr_tUInt32 paramindex = 0;
pwr_tUInt32 size;
pwr_eBix bix = (i == 0) ? pwr_eBix_rt : pwr_eBix_dev;
oid.vid = m_vid;
oid.oix = cdh_cixToOix( cdh_oixToCix(co->oid().oix), bix, 0);
wb_orep *bo = m_vrep->object( sts, oid);
if ( bo) {
if ( bix == pwr_eBix_rt)
has_rtbody = true;
numofobjbodies++;
wb_orep *ao = bo->first( &asts);
wb_orep *next_ao;
while ( ODD(asts)) {
ao->ref();
switch ( ao->cid()) {
case pwr_eClass_Param:
case pwr_eClass_Input:
case pwr_eClass_Output:
case pwr_eClass_Intern: {
pwr_tTid typeref;
pwr_tInt32 type;
pwr_tUInt32 flags;
pwr_tUInt32 elements;
m_vrep->readAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sParam, TypeRef),
sizeof(typeref), &typeref);
if ( EVEN(*sts)) return false;
m_vrep->readAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sParam, Info.Flags),
sizeof(flags), &flags);
if ( EVEN(*sts)) return false;
m_vrep->readAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sParam, Info.Elements),
sizeof(elements), &elements);
if ( EVEN(*sts)) return false;
if ( elements == 0)
elements = 1;
if ( elements > 1 && !( flags & PWR_MASK_ARRAY)) {
error( "Error in Elements or Flags.Array", ao);
break;
}
if ( !cdh_tidIsCid( typeref)) {
// Type attribute
if ( flags & PWR_MASK_CLASS) {
error( "Error in Flags.Class", ao);
break;
}
if ( flags & PWR_MASK_SUPERCLASS) {
error( "Error in Flags.SuperClass", ao);
break;
}
if ( cdh_TidToVid( typeref) == m_vid) {
sTypeBuild *tpt = (sTypeBuild *)tree_Find( sts, m_typebuild_th, &typeref);
if ( !tpt) {
error( "Error in TypeRef", ao);
return false;
}
wb_orep *tot = m_vrep->object( sts, cdh_TypeIdToObjid( typeref));
if ( !tot)
return false;
if ( !tpt->built) {
if ( !buildType( sts, tot))
return false;
}
m_vrep->readAttribute( sts, tot, pwr_eBix_sys, offsetof( pwr_sTypeDef, Size),
sizeof(size), &size);
if ( EVEN(*sts)) return false;
m_vrep->readAttribute( sts, tot, pwr_eBix_sys, offsetof( pwr_sTypeDef, Type),
sizeof(type), &type);
if ( EVEN(*sts)) return false;
size = size * elements;
}
else {
wb_tdrep *td = m_vrep->merep()->tdrep( sts, typeref);
if ( EVEN(*sts)) {
error( "Error in TypeRef", ao);
break;
}
type = td->type();
size = elements * td->size();
delete td;
}
if ( type == pwr_eType_AttrRef)
has_attrref = true;
else if ( type == pwr_eType_Objid)
has_objref = true;
}
else {
// Class attribute
if ( !(flags & PWR_MASK_CLASS))
flags |= PWR_MASK_CLASS;
if ( paramindex == 0 && strcmp( ao->name(), "Super") == 0 &&
!(flags & PWR_MASK_SUPERCLASS))
flags |= PWR_MASK_SUPERCLASS;
// Check if class in this volume
if ( cdh_CidToVid( typeref) == m_vid) {
sClassBuild *cpt = (sClassBuild *)tree_Find( sts, m_classbuild_th, &typeref);
if ( !cpt) {
error( "Error in TypeRef", ao);
break;
}
wb_orep *cot = m_vrep->object( sts, cdh_ClassIdToObjid( typeref));
if ( !cot)
return false;
if ( !cpt->built) {
if ( !buildClass( sts, cot))
return false;
}
type = typeref;
// Get size from RtBody
pwr_tOid boid;
boid.oix = cdh_cixToOix( cdh_cidToCix(typeref), pwr_eBix_rt, 0);
boid.vid = m_vid;
wb_orep *bot = m_vrep->object( sts, boid);
if ( !bot) {
error( "Error in TypeRef, no RtBody found", ao);
break;
}
m_vrep->readAttribute( sts, bot, pwr_eBix_sys, offsetof( pwr_sObjBodyDef, Size),
sizeof(size), &size);
if ( EVEN(*sts)) return false;
pwr_mClassDef cdflags;
m_vrep->readAttribute( sts, cot, pwr_eBix_sys, offsetof( pwr_sClassDef, Flags),
sizeof(cdflags), &cdflags);
if ( EVEN(*sts)) return false;
size = size * elements;
if ( cdflags.b.ObjRef)
has_objref = true;
if ( cdflags.b.AttrRef)
has_attrref = true;
if ( cdflags.b.ObjXRef)
has_objxref = true;
if ( cdflags.b.AttrXRef)
has_attrref = true;
}
else {
wb_cdrep *cd = m_vrep->merep()->cdrep( sts, typeref);
if ( EVEN(*sts)) {
error( "Error in TypeRef", ao);
break;
}
type = cd->cid();
size = elements * cd->size( pwr_eBix_rt);
if ( cd->flags().b.ObjRef)
has_objref = true;
if ( cd->flags().b.AttrRef)
has_attrref = true;
if ( cd->flags().b.ObjXRef)
has_objxref = true;
if ( cd->flags().b.AttrXRef)
has_attrref = true;
delete cd;
}
}
if ( ao->cid() == pwr_eClass_Input) {
offset += sizeof(pwr_tFloat32*);
}
// Store data in Attribute object
m_vrep->writeAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sParam, Info.Flags),
sizeof(flags), &flags);
if ( EVEN(*sts)) return false;
m_vrep->writeAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sParam, Info.Elements),
sizeof(elements), &elements);
if ( EVEN(*sts)) return false;
m_vrep->writeAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sParam, Info.Size),
sizeof(size), &size);
if ( EVEN(*sts)) return false;
m_vrep->writeAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sParam, Info.Offset),
sizeof(offset), &offset);
if ( EVEN(*sts)) return false;
m_vrep->writeAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sParam, Info.ParamIndex),
sizeof(paramindex), &paramindex);
if ( EVEN(*sts)) return false;
m_vrep->writeAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sParam, Info.Type),
sizeof(type), &type);
if ( EVEN(*sts)) return false;
offset += size;
paramindex++;
break;
}
case pwr_eClass_AttrXRef:
case pwr_eClass_ObjXRef: {
pwr_tTid typeref;
pwr_tInt32 type;
pwr_tUInt32 flags;
pwr_tUInt32 elements;
m_vrep->readAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sParam, TypeRef),
sizeof(typeref), &typeref);
if ( EVEN(*sts)) return false;
m_vrep->readAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sParam, Info.Flags),
sizeof(flags), &flags);
if ( EVEN(*sts)) return false;
m_vrep->readAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sParam, Info.Elements),
sizeof(elements), &elements);
if ( EVEN(*sts)) return false;
if ( elements == 0)
elements = 1;
if ( elements > 1 && !( flags & PWR_MASK_ARRAY)) {
error( "Error in Elements or Flags.Array", ao);
break;
}
if ( ao->cid() == pwr_eClass_ObjXRef)
typeref = pwr_eType_Objid;
else
typeref = pwr_eType_AttrRef;
wb_tdrep *td = m_vrep->merep()->tdrep( sts, typeref);
if ( EVEN(*sts)) {
error( "Error in TypeRef", ao);
break;
}
type = td->type();
size = elements * td->size();
delete td;
if ( ao->cid() == pwr_eClass_ObjXRef)
has_objxref = true;
else if ( ao->cid() == pwr_eClass_AttrXRef)
has_attrxref = true;
// Store data in Attribute object
m_vrep->writeAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sParam, Info.Flags),
sizeof(flags), &flags);
if ( EVEN(*sts)) return false;
m_vrep->writeAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sParam, Info.Elements),
sizeof(elements), &elements);
if ( EVEN(*sts)) return false;
m_vrep->writeAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sParam, Info.Size),
sizeof(size), &size);
if ( EVEN(*sts)) return false;
m_vrep->writeAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sParam, Info.Offset),
sizeof(offset), &offset);
if ( EVEN(*sts)) return false;
m_vrep->writeAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sParam, Info.ParamIndex),
sizeof(paramindex), &paramindex);
if ( EVEN(*sts)) return false;
m_vrep->writeAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sParam, Info.Type),
sizeof(type), &type);
if ( EVEN(*sts)) return false;
offset += size;
paramindex++;
break;
}
case pwr_eClass_Buffer: {
pwr_tCid cid;
pwr_tInt32 type;
pwr_tUInt32 flags;
pwr_tUInt32 elements;
m_vrep->readAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sBuffer, Class),
sizeof(cid), &cid);
if ( EVEN(*sts)) return false;
m_vrep->readAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sBuffer, Info.Flags),
sizeof(flags), &flags);
if ( EVEN(*sts)) return false;
m_vrep->readAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sBuffer, Info.Elements),
sizeof(elements), &elements);
if ( EVEN(*sts)) return false;
if ( elements == 0)
elements = 1;
if ( elements > 1 && !( flags & PWR_MASK_ARRAY)) {
error( "Error in Elements or Flags.Array", ao);
break;
}
if ( !cdh_tidIsCid( cid)) {
error( "Error in Class", ao);
break;
}
wb_cdrep *cd = m_vrep->merep()->cdrep( sts, cid);
if ( EVEN(*sts)) {
error( "Error in Class", ao);
break;
}
if ( !(flags & PWR_MASK_BUFFER))
flags |= PWR_MASK_BUFFER;
type = cd->cid();
size = elements * cd->size( pwr_eBix_rt);
delete cd;
// Store data in Attribute object
m_vrep->writeAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sBuffer, Info.Flags),
sizeof(flags), &flags);
if ( EVEN(*sts)) return false;
m_vrep->writeAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sBuffer, Info.Elements),
sizeof(elements), &elements);
if ( EVEN(*sts)) return false;
m_vrep->writeAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sBuffer, Info.Size),
sizeof(size), &size);
if ( EVEN(*sts)) return false;
m_vrep->writeAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sBuffer, Info.Offset),
sizeof(offset), &offset);
if ( EVEN(*sts)) return false;
m_vrep->writeAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sBuffer, Info.ParamIndex),
sizeof(paramindex), &paramindex);
if ( EVEN(*sts)) return false;
m_vrep->writeAttribute( sts, ao, pwr_eBix_sys, offsetof( pwr_sBuffer, Info.Type),
sizeof(type), &type);
if ( EVEN(*sts)) return false;
offset += size;
paramindex++;
break;
}
default: ;
}
next_ao = ao->after( &asts);
ao->unref();
ao = next_ao;
}
// Store data in Body object
m_vrep->writeAttribute( sts, bo, pwr_eBix_sys, offsetof( pwr_sObjBodyDef, Size),
sizeof(offset), &offset);
if ( EVEN(*sts)) return false;
m_vrep->writeAttribute( sts, bo, pwr_eBix_sys, offsetof( pwr_sObjBodyDef, NumOfParams),
sizeof(paramindex), &paramindex);
if ( EVEN(*sts)) return false;
}
}
// Store data in ClassDef object
m_vrep->writeAttribute( sts, co, pwr_eBix_sys, offsetof( pwr_sClassDef, NumOfObjBodies),
sizeof(numofobjbodies), &numofobjbodies);
if ( EVEN(*sts)) return false;
if ( has_rtbody || has_objref || has_attrref || has_objxref || has_attrxref) {
pwr_mClassDef cflags;
m_vrep->readAttribute( sts, co, pwr_eBix_sys, offsetof( pwr_sClassDef, Flags),
sizeof(cflags), &cflags);
if ( EVEN(*sts)) return false;
if ( has_rtbody)
cflags.b.RtBody = 1;
if ( has_objref)
cflags.b.ObjRef = 1;
if ( has_attrref)
cflags.b.AttrRef = 1;
if ( has_objxref)
cflags.b.ObjXRef = 1;
if ( has_attrxref)
cflags.b.AttrXRef = 1;
m_vrep->writeAttribute( sts, co, pwr_eBix_sys, offsetof( pwr_sClassDef, Flags),
sizeof(cflags), &cflags);
if ( EVEN(*sts)) return false;
}
cp->built = 1;
*sts = LDH__SUCCESS;
return true;
}
void wb_vrepced::printPaletteFile()
{
#if 0
// Print new palette file
pwr_tStatus psts;
int menu_found = 0;
int allclasses_found = 0;
int palette_found = 0;
PalFileMenu *menu = PalFile::config_tree_build( 0, pal_cLocalPaletteFile,
pal_eNameType_All, "", 0);
PalFileMenu *mp, *mp2, *mp3, *mp4;
ced_object *cedch, *cedcd, *cedgn;
// Add menu "NavigatorPalette-AllClasses-'volumename' if not found
for ( mp = menu; mp; mp = mp->next) {
if ( mp->item_type == pal_eMenuType_Palette &&
cdh_NoCaseStrcmp( mp->title, "NavigatorPalette") == 0) {
for ( mp2 = mp->child_list; mp2; mp2 = mp2->next) {
if ( mp2->item_type == pal_eMenuType_Menu &&
cdh_NoCaseStrcmp( mp2->title, "AllClasses") == 0) {
for ( mp3 = mp2->child_list; mp3; mp3 = mp3->next) {
if ( mp3->item_type == pal_eMenuType_ClassVolume &&
cdh_NoCaseStrcmp( mp3->title, volume_name) == 0) {
menu_found = 1;
break;
}
}
allclasses_found = 1;
break;
}
}
palette_found = 1;
break;
}
}
if ( !palette_found) {
// Create palette
mp = new PalFileMenu( "NavigatorPalette", pal_eMenuType_Palette, 0);
mp->next = menu;
menu = mp;
}
if ( !allclasses_found) {
// Create volume menu
mp2 = new PalFileMenu( "AllClasses", pal_eMenuType_Menu, mp);
mp2->next = mp->child_list;
mp->child_list = mp2;
}
if ( !menu_found) {
// Create volume menu
mp3 = new PalFileMenu( volume_name, pal_eMenuType_ClassVolume, mp2);
mp3->next = mp2->child_list;
mp2->child_list = mp3;
}
// Replace menu "PlcEditorPalette-'volumename'-* with function object classes
menu_found = 0;
palette_found = 0;
for ( mp = menu; mp; mp = mp->next) {
if ( mp->item_type == pal_eMenuType_Palette &&
cdh_NoCaseStrcmp( mp->title, "PlcEditorPalette") == 0) {
for ( mp2 = mp->child_list; mp2; mp2 = mp2->next) {
if ( mp2->item_type == pal_eMenuType_Menu &&
cdh_NoCaseStrcmp( mp2->title, volume_name) == 0) {
// Remove
PalFile::config_tree_free( mp2->child_list);
mp2->child_list = 0;
menu_found = 1;
break;
}
}
palette_found = 1;
break;
}
}
if ( !palette_found) {
// Create palette
mp = new PalFileMenu( "PlcEditorPalette", pal_eMenuType_Palette, 0);
mp->next = menu;
menu = mp;
}
if ( !menu_found) {
// Create volume menu
mp2 = new PalFileMenu( volume_name, pal_eMenuType_Menu, mp);
mp2->next = mp->child_list;
mp->child_list = mp2;
}
for ( cedch = root_object; cedch; cedch = cedch->fws) {
if ( cedch->m_cid == pwr_eClass_ClassHier) {
for ( cedcd = cedch->fch; cedcd; cedcd = cedcd->fws) {
for ( cedgn = cedcd->fch; cedgn; cedgn = cedgn->fws) {
if ( cedgn->m_cid == pwr_eClass_GraphPlcNode) {
// Add to menu
mp4 = mp3;
mp3 = new PalFileMenu( cedcd->m_name, pal_eMenuType_Class, mp2);
if ( !mp2->child_list)
mp2->child_list = mp3;
else
mp4->next = mp3;
break;
}
}
}
break;
}
}
PalFile::config_tree_print( pal_cLocalPaletteFile, menu, &psts);
#endif
}
/*
* Proview $Id: wb_vrepced.h,v 1.1 2007-11-23 14:25:09 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_vrepced_h
#define wb_vrepced_h
#include <string>
#include "wb_vrep.h"
#include "wb_erep.h"
#include "wb_attrname.h"
#include "wb_treeimport.h"
#include "co_dbs.h"
#include "co_tree.h"
#include "wb_import.h"
class wb_orepced;
class wb_vrepced : public wb_vrep
{
wb_erep *m_erep;
wb_merep *m_merep;
unsigned int m_nRef;
wb_vrep *m_vrep;
int m_errorCount;
tree_sTable *m_classbuild_th;
tree_sTable *m_typebuild_th;
public:
wb_vrepced( wb_erep *erep, wb_vrep *vrep) :
m_erep(erep), m_merep(erep->merep()), m_nRef(0), m_vrep(vrep) {
m_vid = m_vrep->vid();
m_cid = m_vrep->cid();
}
~wb_vrepced();
virtual ldh_eVolRep type() const { return ldh_eVolRep_Ced;}
pwr_tVid vid() const { return m_vid;}
pwr_tCid cid() const { return m_cid;}
wb_vrep *next() { return m_vrep->next();}
virtual bool createSnapshot(const char *fileName, const pwr_tTime *time);
virtual void unref();
virtual wb_vrep *ref();
virtual void name( const char *n);
wb_erep *erep() {return m_vrep->erep();}
wb_merep *merep() const { return m_vrep->merep();}
virtual pwr_tOid oid(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->oid( sts, o);}
virtual pwr_tVid vid(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->vid( sts, o);}
virtual pwr_tOix oix(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->oix( sts, o);}
virtual pwr_tCid cid(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->cid( sts, o);}
virtual pwr_tOid poid(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->poid( sts, o);}
virtual pwr_tOid foid(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->foid( sts, o);}
virtual pwr_tOid loid(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->loid( sts, o);}
virtual pwr_tOid boid(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->boid( sts, o);}
virtual pwr_tOid aoid(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->aoid( sts, o);}
virtual const char * objectName(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->objectName( sts, o);}
virtual wb_name longName(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->longName( sts, o);}
virtual pwr_tTime ohTime(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->ohTime( sts, o);}
virtual pwr_tTime rbTime(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->rbTime( sts, o);}
virtual pwr_tTime dbTime(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->dbTime( sts, o);}
virtual pwr_mClassDef flags(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->flags( sts, o);}
virtual bool isOffspringOf(pwr_tStatus *sts, const wb_orep *child, const wb_orep *parent) { return m_vrep->isOffspringOf( sts, child, parent);}
wb_orep *object(pwr_tStatus *sts) { return m_vrep->object( sts);}
wb_orep *object(pwr_tStatus *sts, pwr_tOid oid) { return m_vrep->object( sts, oid);}
wb_orep *object(pwr_tStatus *sts, pwr_tCid cid) { return m_vrep->object( sts, cid);}
wb_orep *object(pwr_tStatus *sts, wb_name &name) { return m_vrep->object( sts, name);}
wb_orep *object(pwr_tStatus *sts, const wb_orep *parent, wb_name &name) { return m_vrep->object( sts, parent, name);}
wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name,
pwr_tOix oix = 0);
wb_orep *copyObject(pwr_tStatus *sts, const wb_orep *orep, wb_destination &d, wb_name &name);
bool copyOset(pwr_tStatus *sts, wb_oset *oset, wb_destination &d) { return m_vrep->copyOset( sts, oset, d);}
bool moveObject(pwr_tStatus *sts, wb_orep *orep, wb_destination &d);
bool deleteObject(pwr_tStatus *sts, wb_orep *orep);
bool deleteFamily(pwr_tStatus *sts, wb_orep *orep);
bool deleteOset(pwr_tStatus *sts, wb_oset *oset) { return m_vrep->deleteOset( sts, oset);}
bool renameObject(pwr_tStatus *sts, wb_orep *orep, wb_name &name);
bool commit(pwr_tStatus *sts);
bool abort(pwr_tStatus *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) { return m_vrep->readAttribute( sts, o, bix, offset, size, p);}
virtual void *readBody(pwr_tStatus *sts, const wb_orep *o, pwr_eBix bix, void *p) { return readBody( sts, o, bix, p);}
virtual bool writeBody(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, void *p);
wb_orep *ancestor(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->ancestor( sts, o);}
wb_orep *parent(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->parent( sts, o);}
wb_orep *after(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->after( sts, o);}
wb_orep *before(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->before( sts, o);}
wb_orep *first(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->first( sts, o);}
wb_orep *child(pwr_tStatus *sts, const wb_orep *o, wb_name &name) { return m_vrep->child( sts, o, name);}
wb_orep *last(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->last( sts, o);}
wb_orep *next(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->next( sts, o);}
wb_orep *previous(pwr_tStatus *sts, const wb_orep *o) { return m_vrep->previous( sts, o);}
wb_srep *newSession() {return m_vrep->newSession();}
bool isLocal(const wb_orep *o) { return m_vrep->isLocal( o);}
void objectName(const wb_orep *o, char *str) { m_vrep->objectName( o, str);}
virtual bool exportVolume(wb_import &i) { return m_vrep->exportVolume( i);}
virtual bool exportHead(wb_import &i) { return m_vrep->exportHead( i);}
virtual bool exportRbody(wb_import &i) { return m_vrep->exportRbody( i);}
virtual bool exportDbody(wb_import &i) { return m_vrep->exportDbody( i);}
virtual bool exportDocBlock(wb_import &i) { return m_vrep->exportDocBlock( i);}
virtual bool exportMeta(wb_import &i) { return m_vrep->exportMeta( i);}
virtual bool exportTree(wb_treeimport &i, pwr_tOid oid) { return m_vrep->exportTree( i, oid);}
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 m_vrep->importTreeObject( merep, oid, cid, poid, boid, name, flags, rbSize, dbSize, rbody, dbody);}
virtual bool importTree( bool keepref) { return m_vrep->importTree( keepref);}
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) {
return m_vrep->importPasteObject( destination, destcode, keepoid, oid, cid, poid, boid, name, flags,
rbSize, dbSize, rbody, dbody, roid);}
virtual bool importPaste() { return m_vrep->importPaste();}
virtual void importIgnoreErrors() { return m_vrep->importIgnoreErrors();}
virtual bool accessSupported( ldh_eAccess access) { return m_vrep->accessSupported( access);}
virtual const char *fileName() { return m_vrep->fileName();}
private:
bool nextCix( pwr_tStatus *sts, pwr_tOix *cix);
bool nextTix( pwr_tStatus *sts, pwr_tOix *tix);
bool nextAix( pwr_tStatus *sts, wb_orep *co, pwr_tOix *aix);
bool buildType( pwr_tStatus *sts, wb_orep *to);
bool buildClass( pwr_tStatus *sts, wb_orep *co);
void error( char *msg, wb_orep *o);
bool classeditorCheck( ldh_eDest dest_code, wb_orep *dest, pwr_tCid cid,
pwr_tOix *oix, char *name, pwr_tStatus *sts,
bool import_paste);
void printPaletteFile();
};
#endif
/*
* Proview $Id: wb_vrepdb.cpp,v 1.59 2007-11-07 18:07:51 claes Exp $
* Proview $Id: wb_vrepdb.cpp,v 1.60 2007-11-23 14:25:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -431,7 +431,8 @@ bool wb_vrepdb::copyOset(pwr_tStatus *sts, wb_oset *oset, wb_destination &d)
return false;
}
wb_orep* wb_vrepdb::createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name)
wb_orep* wb_vrepdb::createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d,
wb_name &name, pwr_tOix oix)
{
*sts = LDH__SUCCESS;
wb_db_txn *txn = m_db->begin(m_db->m_txn);
......@@ -440,7 +441,21 @@ wb_orep* wb_vrepdb::createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination
try {
int rs = 0;
pwr_tTime time;
pwr_tOid oid = m_db->new_oid(txn);
pwr_tOid oid;
if ( oix) {
pwr_tOid woid;
woid.oix = oix;
woid.vid = m_vid;
oid = m_db->new_oid(txn, woid);
if ( !oid.oix) {
*sts = LDH__BADOBJID;
return 0;
}
}
else
oid = m_db->new_oid(txn);
wb_db_ohead o(m_db, oid);
clock_gettime(CLOCK_REALTIME, &time);
......@@ -1519,6 +1534,8 @@ bool wb_vrepdb::importPasteObject(pwr_tOid doid, ldh_eDest destcode,
if (keepoid) {
oep->n_oid = m_db->new_oid(m_db->m_txn, oid);
if ( !oep->n_oid.oix)
oep->n_oid = m_db->new_oid(m_db->m_txn);
} else {
oep->n_oid = m_db->new_oid(m_db->m_txn);
}
......@@ -1946,7 +1963,7 @@ int wb_vrepdb::updateArefs(pwr_tOid oid, pwr_tCid cid)
pwr_tStatus wb_vrepdb::updateMeta()
{
int rc = 0;
pwr_tStatus rc = 0;
pwr_tStatus sts = LDH__SUCCESS;
pwr_tStatus db_sts = LDH__SUCCESS;
int nAref = 0;
......@@ -2031,7 +2048,7 @@ pwr_tStatus wb_vrepdb::updateMeta()
commit(&rc);
if (rc) {
if (EVEN(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"),
......
/*
* Proview $Id: wb_vrepdb.h,v 1.35 2007-11-06 13:29:38 claes Exp $
* Proview $Id: wb_vrepdb.h,v 1.36 2007-11-23 14:25:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -130,7 +130,8 @@ public:
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 *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d,
wb_name &name, pwr_tOix oix = 0);
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);
......
/*
* Proview $Id: wb_vrepdbms.cpp,v 1.2 2007-10-19 07:00:02 claes Exp $
* Proview $Id: wb_vrepdbms.cpp,v 1.3 2007-11-23 14:25:09 claes Exp $
* Copyright (C) 2007 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -431,7 +431,8 @@ bool wb_vrepdbms::copyOset(pwr_tStatus *sts, wb_oset *oset, wb_destination &d)
return false;
}
wb_orep* wb_vrepdbms::createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name)
wb_orep* wb_vrepdbms::createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d,
wb_name &name, pwr_tOix oix)
{
*sts = LDH__SUCCESS;
wb_dbms_txn *txn = m_db->subBegin(m_db->m_txn);
......@@ -440,7 +441,20 @@ wb_orep* wb_vrepdbms::createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destinatio
try {
int rs = 0;
pwr_tTime time;
pwr_tOid oid = m_db->new_oid(txn);
if ( oix) {
pwr_tOid woid;
woid.oix = oix;
woid.vid = m_vid;
oid = m_db->new_oid(txn, woid);
if ( !oid.oix) {
*sts = LDH__BADOBJID;
return 0;
}
}
else
pwr_tOid oid = m_db->new_oid(txn);
wb_dbms_ohead o(m_db, oid);
clock_gettime(CLOCK_REALTIME, &time);
......@@ -1533,6 +1547,8 @@ bool wb_vrepdbms::importPasteObject(pwr_tOid doid, ldh_eDest destcode,
if (keepoid) {
oep->n_oid = m_db->new_oid(m_db->m_txn, oid);
if ( !oep->n_oid.oix)
oep->n_oid = m_db->new_oid(m_db->m_txn);
} else {
oep->n_oid = m_db->new_oid(m_db->m_txn);
}
......@@ -1945,7 +1961,7 @@ int wb_vrepdbms::updateArefs(pwr_tOid oid, pwr_tCid cid)
pwr_tStatus wb_vrepdbms::updateMeta()
{
int rc = 0;
pwr_tStatus rc = 0;
pwr_tStatus sts = LDH__SUCCESS;
pwr_tStatus db_sts = LDH__SUCCESS;
int nAref = 0;
......@@ -2029,7 +2045,7 @@ pwr_tStatus wb_vrepdbms::updateMeta()
commit(&rc);
if (rc) {
if ( EVEN(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"),
......
/*
* Proview $Id: wb_vrepdbms.h,v 1.2 2007-10-19 07:00:02 claes Exp $
* Proview $Id: wb_vrepdbms.h,v 1.3 2007-11-23 14:25:09 claes Exp $
* Copyright (C) 2007 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -131,7 +131,8 @@ public:
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 *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d,
wb_name &name, pwr_tOix oix = 0);
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);
......
/*
* Proview $Id: wb_vrepdbs.cpp,v 1.49 2006-06-09 13:16:09 claes Exp $
* Proview $Id: wb_vrepdbs.cpp,v 1.50 2007-11-23 14:25:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -233,7 +233,8 @@ wb_orep *wb_vrepdbs::object(pwr_tStatus *sts, const wb_orep *parent, wb_name &na
}
wb_orep *wb_vrepdbs::createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name)
wb_orep *wb_vrepdbs::createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d,
wb_name &name, pwr_tOix oix)
{
*sts = LDH__NYI;
return 0;
......
/*
* Proview $Id: wb_vrepdbs.h,v 1.37 2006-06-08 13:39:33 claes Exp $
* Proview $Id: wb_vrepdbs.h,v 1.38 2007-11-23 14:25:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -89,7 +89,8 @@ public:
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 *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d,
wb_name &name, pwr_tOix oix = 0);
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);
......
/*
* Proview $Id: wb_vrepext.cpp,v 1.8 2006-09-15 09:33:20 claes Exp $
* Proview $Id: wb_vrepext.cpp,v 1.9 2007-11-23 14:25:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -384,7 +384,8 @@ void *wb_vrepext::readBody(pwr_tStatus *sts, const wb_orep *o, pwr_eBix bix, voi
}
wb_orep *wb_vrepext::createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name)
wb_orep *wb_vrepext::createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d,
wb_name &name, pwr_tOix oix)
{
if ( d.oid().vid != m_vid) {
*sts = LDH__BADOBJID;
......
/*
* Proview $Id: wb_vrepext.h,v 1.9 2006-09-14 14:16:20 claes Exp $
* Proview $Id: wb_vrepext.h,v 1.10 2007-11-23 14:25:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -210,7 +210,8 @@ public:
wb_orep *object(pwr_tStatus *sts, wb_name &name);
wb_orep *object(pwr_tStatus *sts, const wb_orep *parent, wb_name &name) {return 0;}
wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name);
wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name,
pwr_tOix oix = 0);
wb_orep *copyObject(pwr_tStatus *sts, const wb_orep *orep, wb_destination &d, wb_name &name);
bool copyOset(pwr_tStatus *sts, wb_oset *oset, wb_destination &d) {return false;}
......
/*
* Proview $Id: wb_vrepmem.cpp,v 1.29 2007-11-07 08:48:56 claes Exp $
* Proview $Id: wb_vrepmem.cpp,v 1.30 2007-11-23 14:25:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -689,12 +689,13 @@ void wb_vrepmem::freeObject( mem_object *memo)
delete memo;
}
wb_orep *wb_vrepmem::createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name)
wb_orep *wb_vrepmem::createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d,
wb_name &name, pwr_tOix oix)
{
mem_object *dest;
ldh_eDest code = d.code();
char name_str[32];
pwr_tOix oix;
pwr_tOix soix;
pwr_tTime time;
clock_gettime(CLOCK_REALTIME, &time);
......@@ -720,14 +721,14 @@ wb_orep *wb_vrepmem::createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination
}
if ( !m_classeditor) {
oix = nextOix();
soix = nextOix();
if ( name.evenSts())
sprintf( name_str, "O%u", oix);
sprintf( name_str, "O%u", soix);
else
strcpy( name_str, name.object());
}
else {
if ( !classeditorCheck( code, dest, cdef.cid(), &oix, name_str, sts, false))
if ( !classeditorCheck( code, dest, cdef.cid(), &soix, name_str, sts, false))
return 0;
if ( name.oddSts())
......@@ -737,7 +738,7 @@ wb_orep *wb_vrepmem::createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination
mem_object *memo = new mem_object();
strcpy( memo->m_name, name_str);
memo->m_oid.oix = oix;
memo->m_oid.oix = soix;
memo->m_oid.vid = m_vid;
memo->m_cid = cdef.cid();
memo->m_flags = cdef.flags();
......
/*
* Proview $Id: wb_vrepmem.h,v 1.21 2007-10-25 16:05:10 claes Exp $
* Proview $Id: wb_vrepmem.h,v 1.22 2007-11-23 14:25:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -279,7 +279,8 @@ public:
wb_orep *object(pwr_tStatus *sts, wb_name &name);
wb_orep *object(pwr_tStatus *sts, const wb_orep *parent, wb_name &name) {return 0;}
wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name);
wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name,
pwr_tOix oix = 0);
wb_orep *copyObject(pwr_tStatus *sts, const wb_orep *orep, wb_destination &d, wb_name &name);
bool copyOset(pwr_tStatus *sts, wb_oset *oset, wb_destination &d) {return false;}
......
/*
* Proview $Id: wb_vrepref.h,v 1.7 2006-05-11 07:12:20 claes Exp $
* Proview $Id: wb_vrepref.h,v 1.8 2007-11-23 14:25:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -101,7 +101,8 @@ public:
wb_orep *object(pwr_tStatus *sts, pwr_tCid cid) { *sts = LDH__NOSUCHOBJ; return 0;}
wb_orep *object(pwr_tStatus *sts, wb_name &name);
wb_orep *object(pwr_tStatus *sts, const wb_orep *parent, wb_name &name) { *sts = LDH__NOSUCHOBJ; return 0;}
wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name) {return 0;}
wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name,
pwr_tOix oix = 0) {return 0;}
wb_orep *copyObject(pwr_tStatus *sts, const wb_orep *orep, wb_destination &d, wb_name &name) {return 0;}
bool copyOset(pwr_tStatus *sts, wb_oset *oset, wb_destination &d) {return false;}
bool moveObject(pwr_tStatus *sts, wb_orep *orep, wb_destination &d) {return false;}
......
/*
* Proview $Id: wb_vrepwbl.h,v 1.38 2007-10-23 08:54:16 claes Exp $
* Proview $Id: wb_vrepwbl.h,v 1.39 2007-11-23 14:25:09 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -154,7 +154,8 @@ public:
wb_orep *object(pwr_tStatus *sts, wb_name &name);
wb_orep *object(pwr_tStatus *sts, const wb_orep *parent, wb_name &name) {return 0;}
wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name) {return 0;}
wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name,
pwr_tOix oix = 0) {return 0;}
wb_orep *copyObject(pwr_tStatus *sts, const wb_orep *orep, wb_destination &d, wb_name &name) {return 0;}
bool copyOset(pwr_tStatus *sts, wb_oset *oset, wb_destination &d) {return false;}
......
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