Commit c68d706c authored by claes's avatar claes

Classeditor: if attribute or type renamed, change in class definition is made

parent b5c89192
/*
* Proview $Id: wb_adrep.cpp,v 1.19 2005-10-07 05:57:28 claes Exp $
* Proview $Id: wb_adrep.cpp,v 1.20 2007-09-20 15:09:18 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -341,3 +341,8 @@ void *wb_adrep::body( void *p)
return m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, p);
}
bool wb_adrep::renameAttribute( pwr_tStatus *sts, wb_name &name)
{
return m_orep->vrep()->renameObject( sts, m_orep, name);
}
/*
* Proview $Id: wb_adrep.h,v 1.18 2005-09-06 10:43:30 claes Exp $
* Proview $Id: wb_adrep.h,v 1.19 2007-09-20 15:09:18 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -90,6 +90,7 @@ public:
const char *subName() const;
wb_name longName();
void *body( void *p = 0);
bool renameAttribute( pwr_tStatus *sts, wb_name &name);
wb_vrep *vrep() const;
};
......
/*
* Proview $Id: wb_tdrep.cpp,v 1.9 2005-09-06 10:43:32 claes Exp $
* Proview $Id: wb_tdrep.cpp,v 1.10 2007-09-20 15:09:18 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -46,7 +46,7 @@ wb_tdrep::wb_tdrep() : m_nRef(0), m_orep(0), m_sts(LDH__NOCLASS)
wb_tdrep::wb_tdrep( wb_mvrep *mvrep, pwr_tTid tid) : m_nRef(0)
{
pwr_tOid oid = cdh_TypeIdToObjid( tid);
m_orep = (wb_orepdbs *) mvrep->object( &m_sts, oid);
m_orep = mvrep->object( &m_sts, oid);
if ( EVEN(m_sts)) throw wb_error( m_sts);
m_orep->ref();
......@@ -60,7 +60,7 @@ wb_tdrep::wb_tdrep( wb_mvrep *mvrep, wb_name name) : m_nRef(0)
strcpy( str, "Type-");
strcat( str, name.object());
wb_name n = wb_name( str);
m_orep = (wb_orepdbs *) mvrep->object( &m_sts, n);
m_orep = mvrep->object( &m_sts, n);
if ( EVEN(m_sts)) throw wb_error( m_sts);
m_orep->ref();
......@@ -71,7 +71,7 @@ wb_tdrep::wb_tdrep( wb_mvrep *mvrep, wb_name name) : m_nRef(0)
wb_tdrep::wb_tdrep( wb_mvrep *mvrep, const wb_adrep& a) : m_nRef(0)
{
pwr_tOid oid = cdh_TypeIdToObjid( a.type());
m_orep = (wb_orepdbs *) mvrep->object( &m_sts, oid);
m_orep = mvrep->object( &m_sts, oid);
if ( EVEN(m_sts)) throw wb_error( m_sts);
m_orep->ref();
......@@ -105,7 +105,7 @@ void wb_tdrep::init()
{
pwr_sTypeDef body;
m_orep->m_vrep->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &body);
m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &body);
if ( EVEN(sts)) throw wb_error(sts);
m_size = body.Size;
......@@ -118,7 +118,7 @@ void wb_tdrep::init()
{
pwr_sTypeDef body;
m_orep->m_vrep->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &body);
m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &body);
if ( EVEN(sts)) throw wb_error(sts);
m_size = body.Size;
......@@ -142,3 +142,7 @@ wb_name wb_tdrep::longName()
return m_orep->longName();
}
bool wb_tdrep::renameType( pwr_tStatus *sts, wb_name &name)
{
return m_orep->vrep()->renameObject( sts, m_orep, name);
}
/*
* Proview $Id: wb_tdrep.h,v 1.8 2005-09-06 10:43:32 claes Exp $
* Proview $Id: wb_tdrep.h,v 1.9 2007-09-20 15:09:18 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -26,13 +26,13 @@
class wb_adrep;
class wb_mrepdbs;
class wb_orepdbs;
class wb_orep;
class wb_mvrep;
class wb_tdrep
{
int m_nRef;
wb_orepdbs *m_orep;
wb_orep *m_orep;
int m_sts;
pwr_eType m_type;
......@@ -58,6 +58,7 @@ public:
const char *name() const;
wb_name longName();
bool renameType( pwr_tStatus *sts, wb_name &name);
pwr_tStatus sts() { return m_sts;}
......
/*
* Proview $Id: wb_vrepmem.cpp,v 1.24 2007-09-19 15:18:34 claes Exp $
* Proview $Id: wb_vrepmem.cpp,v 1.25 2007-09-20 15:09:18 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -1171,15 +1171,8 @@ bool wb_vrepmem::renameObject(pwr_tStatus *sts, wb_orep *orep, wb_name &name)
return LDH__NAMALREXI;
}
if ( m_classeditor && memo->m_cid == pwr_eClass_ClassDef) {
pwr_tCid cid = cdh_ClassObjidToId( memo->m_oid);
wb_cdrep *cdrep = m_merep->cdrep( sts, cid);
if ( cdrep) {
cdrep->renameClass( sts, name);
printf( "cdrep: %s\n", cdrep->name());
}
}
if ( m_classeditor)
classeditorRenameObject( memo, old_name, name);
memo->m_ohtime = time;
......@@ -1934,6 +1927,74 @@ bool wb_vrepmem::abort(pwr_tStatus *sts)
}
void wb_vrepmem::classeditorRenameObject( mem_object *memo, char *oldname,
wb_name &name)
{
pwr_tStatus sts;
switch ( memo->m_cid) {
case pwr_eClass_ClassDef: {
pwr_tCid cid = cdh_ClassObjidToId( memo->m_oid);
try {
wb_cdrep *cdrep = m_merep->cdrep( &sts, cid);
if ( cdrep) {
cdrep->renameClass( &sts, name);
delete cdrep;
}
} catch ( wb_error &e) {
}
break;
}
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: {
if ( !memo->fth || !memo->fth->fth)
break;
pwr_tCid cid = cdh_ClassObjidToId( memo->fth->fth->m_oid);
try {
wb_cdrep *cdrep = m_merep->cdrep( &sts, cid);
if ( !cdrep)
break;
wb_bdrep *bdrep = cdrep->bdrep( &sts, memo->fth->m_name);
delete cdrep;
if ( !bdrep)
break;
wb_adrep *adrep = bdrep->adrep( &sts, oldname);
delete bdrep;
if ( !adrep)
break;
adrep->renameAttribute( &sts, name);
delete adrep;
} catch ( wb_error &e) {
}
break;
}
case pwr_eClass_TypeDef: {
pwr_tTid tid = cdh_TypeObjidToId( memo->m_oid);
try {
wb_tdrep *tdrep = m_merep->tdrep( &sts, tid);
if ( tdrep) {
tdrep->renameType( &sts, name);
delete tdrep;
}
} catch ( wb_error &e) {
}
break;
}
default: ;
}
}
bool wb_vrepmem::classeditorCheck( ldh_eDest dest_code, mem_object *dest, pwr_tCid cid,
pwr_tOix *oix, char *name, pwr_tStatus *sts,
bool import_paste)
......
/*
* Proview $Id: wb_vrepmem.h,v 1.19 2007-09-19 15:18:34 claes Exp $
* Proview $Id: wb_vrepmem.h,v 1.20 2007-09-20 15:09:18 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -374,6 +374,8 @@ public:
bool classeditorCheckMove( mem_object *memo, ldh_eDest dest_code,
mem_object *dest, pwr_tStatus *sts);
void classeditorCommit();
void classeditorRenameObject( mem_object *memo, char *oldname,
wb_name &name);
private:
bool nameCheck( mem_object *memo);
......
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