Commit 373a2936 authored by claes's avatar claes

Changes in tdef, cdef, adef and bdef

parent 1ec29e58
......@@ -6,7 +6,10 @@ wb_adef::wb_adef() : wb_status(LDH__NOSUCHATTR), m_adrep(0)
wb_adef::wb_adef( wb_adrep *adrep) : wb_status(LDH__SUCCESS), m_adrep(adrep)
{
m_adrep->ref();
if ( adrep == 0)
m_sts = LDH__NOSUCHATTR;
else
m_adrep->ref();
}
wb_adef::wb_adef(const wb_adef& x) : wb_status(x.m_sts), m_adrep(x.m_adrep)
......
......@@ -85,3 +85,9 @@ pwr_tCid wb_adrep::cid()
return cid;
}
wb_vrep *wb_adrep::vrep() const
{
if (EVEN(m_sts)) throw wb_error(m_sts);
return m_orep->m_vrep;
}
......@@ -6,6 +6,7 @@
#include "wb_bdrep.h"
class wb_orepdbs;
class wb_vrep;
class wb_adrep
{
......@@ -29,7 +30,7 @@ class wb_adrep
pwr_sAttrRef aref();
size_t size(); // get objects runtime body size
int offset() {return 0;}; // Fix
int type() {return 0;} // Fix
int type() const {return 0;} // Fix
int nElement() {return 0;} // Fix
int index() {return 0;} // Fix
pwr_tOid aoid();
......@@ -41,6 +42,8 @@ class wb_adrep
wb_name name() { wb_name n; return n;} // Fix // get attribute name
wb_name name(ldh_eName type) { wb_name n; return n; } // Fix
wb_vrep *vrep() const;
};
#endif
......
......@@ -19,7 +19,10 @@ wb_attribute::wb_attribute(const wb_attribute& x) : wb_status(x.m_sts),m_orep(x.
wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * const orep) : wb_status(sts),
m_orep(orep), m_adrep(0)
{
m_orep->ref();
if ( orep == 0)
m_sts = LDH__NOSUCHATTR;
else
m_orep->ref();
}
wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * const orep, char *name) :
......
#include "wb_bdef.h"
#include "wb_adef.h"
wb_bdef::wb_bdef()
wb_bdef::wb_bdef() : wb_status(LDH__NOSUCHBODY), m_bdrep(0)
{
}
wb_bdef::wb_bdef(wb_bdrep *b) :
wb_status(b->sts()), m_bdrep(b)
wb_bdef::wb_bdef(wb_bdrep *bdrep) : wb_status(LDH__SUCCESS), m_bdrep(bdrep)
{
m_bdrep->ref();
if ( bdrep == 0)
m_sts = LDH__NOSUCHBODY;
else
m_bdrep->ref();
}
wb_bdef::wb_bdef(const wb_bdef& x) : wb_status(x.m_sts), m_bdrep(x.m_bdrep)
......
......@@ -6,31 +6,49 @@ wb_cdef::wb_cdef() : wb_status(LDH__NOCLASS), m_cdrep(0)
{
}
wb_cdef::wb_cdef( wb_cdrep *cdrep) : wb_status(cdrep->sts()), m_cdrep(cdrep)
wb_cdef::wb_cdef( wb_cdrep *cdrep) : wb_status(LDH__SUCCESS), m_cdrep(cdrep)
{
cdrep->ref();
if ( cdrep == 0)
m_sts = LDH__NOCLASS;
else
cdrep->ref();
}
wb_cdef::wb_cdef( wb_adef& a)
{
wb_adrep *adrep = a;
m_cdrep = new wb_cdrep( adrep);
m_cdrep->ref();
m_sts = m_cdrep->sts();
try {
m_cdrep = new wb_cdrep( adrep);
m_cdrep->ref();
m_sts = m_cdrep->sts();
}
catch ( wb_error& e) {
m_sts = e.sts();
}
}
wb_cdef::wb_cdef(const wb_orep& x)
{
m_cdrep = new wb_cdrep( x);
m_cdrep->ref();
m_sts = m_cdrep->sts();
try {
m_cdrep = new wb_cdrep( x);
m_cdrep->ref();
m_sts = m_cdrep->sts();
}
catch( wb_error& e) {
m_sts = e.sts();
}
}
wb_cdef::wb_cdef(wb_mvrep *mvrep, pwr_tCid cid)
{
m_cdrep = new wb_cdrep( mvrep, cid);
m_cdrep->ref();
m_sts = m_cdrep->sts();
try {
m_cdrep = new wb_cdrep( mvrep, cid);
m_cdrep->ref();
m_sts = m_cdrep->sts();
}
catch ( wb_error& e) {
m_sts = e.sts();
}
}
wb_cdef::~wb_cdef()
......@@ -56,29 +74,38 @@ wb_cdef& wb_cdef::operator=(const wb_cdef& x)
return *this;
}
void wb_cdef::check()
{
if ( !m_cdrep) throw wb_error(m_sts);
}
size_t wb_cdef::size()
{
return m_cdrep->size();
check();
return m_cdrep->size();
}
pwr_tCid wb_cdef::cid()
{
return m_cdrep->cid();
check();
return m_cdrep->cid();
}
wb_name wb_cdef::name()
{
return m_cdrep->name();
check();
return m_cdrep->name();
}
wb_name wb_cdef::name(ldh_eName type)
{
return m_cdrep->name(type);
check();
return m_cdrep->name(type);
}
wb_bdef wb_cdef::bdef( char *bname) // Fix
{
check();
pwr_tStatus sts;
wb_bdrep *bdrep = m_cdrep->bdrep( &sts, bname);
......
......@@ -16,10 +16,10 @@ class wb_mvrep;
class wb_cdef : public wb_status
{
public:
wb_cdrep *m_cdrep;
public:
wb_cdef();
wb_cdef( wb_cdrep *cdrep);
wb_cdef( wb_adef&); // x = other_object
......@@ -43,6 +43,9 @@ public:
wb_bdef bdef(pwr_tOix bix);
wb_bdef bdef(char *bname);
wb_bdef bdef(wb_name bname);
private:
void check();
};
......
......@@ -30,18 +30,19 @@ wb_cdrep::wb_cdrep( wb_mvrep *mvrep, pwr_tCid cid) : m_nRef(0)
{
pwr_tOid oid = cdh_ClassIdToObjid( cid);
m_orep = (wb_orepdbs *) mvrep->object( &m_sts, oid);
m_orep->ref();
if ( EVEN(m_sts)) throw wb_error( m_sts);
m_orep->ref();
m_sts = LDH__SUCCESS;
}
wb_cdrep::wb_cdrep( wb_mvrep *mvrep, const wb_orep& o) : m_nRef(0)
{
pwr_tOid oid = cdh_ClassIdToObjid( o.vid());
pwr_tOid oid = cdh_ClassIdToObjid( o.cid());
m_orep = (wb_orepdbs *) mvrep->object( &m_sts, oid);
if ( EVEN(m_sts)) throw wb_error( m_sts);
m_orep->ref();
m_sts = LDH__SUCCESS;
}
......
......@@ -7,10 +7,13 @@
#include "wb_vrepwbl.h" // Should be wb_vrepdbs.h ...
#include "wb_cdrep.h"
#include "wb_orep.h"
#include "wb_tdrep.h"
#include "wb_adrep.h"
#include "wb_ldh_msg.h"
extern "C" {
#include "co_dcli.h"
#include "co_cdh.h"
#include "rt_load.h"
}
......@@ -273,6 +276,9 @@ void wb_erep::loadCommonMeta( pwr_tStatus *status)
char vol_array[2][80];
int nr;
if ( line[0] == '#')
continue;
nr = dcli_parse( line, " ", "", (char *)vol_array,
sizeof(vol_array)/sizeof(vol_array[0]),
sizeof(vol_array[0]), 0);
......@@ -324,6 +330,9 @@ void wb_erep::loadMeta( pwr_tStatus *status)
char vol_array[5][80];
int nr;
if ( line[0] == '#')
continue;
cout << line << endl;
nr = dcli_parse( line, " ", "", (char *)vol_array,
sizeof(vol_array)/sizeof(vol_array[0]),
......@@ -395,6 +404,15 @@ wb_cdrep *wb_erep::cdrep( pwr_tStatus *sts, const wb_orep& o)
return vrep->merep()->cdrep( sts, o);
}
wb_tdrep *wb_erep::tdrep( pwr_tStatus *sts, const wb_adrep& a)
{
pwr_tVid vid = cdh_TidToVid(a.type());
wb_vrep *vrep = volume(sts, vid);
if ( EVEN(*sts)) return 0;
return vrep->merep()->tdrep( sts, a);
}
......
......@@ -10,6 +10,8 @@ class wb_merep;
class wb_vrep;
class wb_cdrep;
class wb_orep;
class wb_tdrep;
class wb_adrep;
class wb_erep
{
......@@ -46,6 +48,7 @@ public:
void load( pwr_tStatus *sts);
wb_cdrep *cdrep( pwr_tStatus *sts, const wb_orep& o);
wb_tdrep *tdrep( pwr_tStatus *sts, const wb_adrep& a);
private:
void loadDirList( pwr_tStatus *status);
......
......@@ -312,7 +312,7 @@ ldh_CloseSession(ldh_tSession session)
return LDH__SUCCESS;
}
catch (wb_error &e) {
catch (wb_error& e) {
return e.sts();
}
return LDH__SUCCESS;
......@@ -329,7 +329,7 @@ ldh_CloseWB(ldh_tWorkbench workbench)
return LDH__SUCCESS;
}
catch (wb_error e) {
catch (wb_error& e) {
return e.sts();
}
}
......@@ -369,7 +369,7 @@ ldh_CreateObject(ldh_tSession session, pwr_tOid *oid, char *name, pwr_tCid cid,
*oid = o.oid();
return o.sts();
}
catch (wb_error &e) {
catch (wb_error& e) {
return e.sts();
}
}
......@@ -713,7 +713,7 @@ ldh_GetPreviousObject(ldh_tSession session, pwr_tOid oid, pwr_tOid *noid)
return o.sts();
} catch (wb_error &e) {
} catch (wb_error& e) {
return e.sts();
......@@ -732,7 +732,7 @@ ldh_GetPreviousSibling(ldh_tSession session, pwr_tOid oid, pwr_tOid *noid)
return o.sts();
} catch (wb_error &e) {
} catch (wb_error& e) {
return e.sts();
......@@ -925,12 +925,50 @@ pwr_tStatus
ldh_ObjidToName(ldh_tSession session, pwr_tOid oid, ldh_eName type, char *buf, int maxsize, int *size)
{
wb_session *sp = (wb_session *)session;
wb_object o = sp->object(oid);
if (!o) return o.sts();
//o.name(type, buf, maxsize, size);
switch ( type) {
case ldh_eName_Object:
case ldh_eName_Hierarchy:
case ldh_eName_Path:
case ldh_eName_VolPath:
case ldh_eName_Volume:
{
wb_object o = sp->object(oid);
if (!o) return o.sts();
return LDH__NYI;
try {
char name[200];
strcpy( name, o.longName().name( type));
*size = strlen( name);
if ( *size > maxsize - 1)
return LDH__NAMEBUF;
strcpy( buf, name);
}
catch ( wb_error& e) {
return e.sts();
}
break;
}
case ldh_eName_Objid:
case ldh_eName_ObjectIx:
case ldh_eName_OixString:
case ldh_eName_VolumeId:
case ldh_eName_VidString:
{
char str[80];
wb_name n = wb_name( cdh_ObjidToString( NULL, oid, 1));
strcpy( str, n.name( type));
*size = strlen(str);
if ( *size > maxsize - 1)
return LDH__NAMEBUF;
strcpy( buf, str);
break;
}
default:
return LDH__NYI;
}
return LDH__SUCCESS;
}
/* Returns the name of a type identified by its type identifier.
......@@ -972,13 +1010,40 @@ ldh_ClassIdToName(ldh_tSession session, pwr_tCid cid, char *buff, int maxsize, i
pwr_tStatus
ldh_AttrRefToName(ldh_tSession session, pwr_sAttrRef *arp, ldh_eName nametype, char **aname, int *size)
{
static char str[512];
wb_session *sp = (wb_session *)session;
wb_attribute a = sp->attribute(arp);
if (!a) return a.sts();
//wb_name n = a.name(nametype);
switch ( nametype) {
case ldh_eName_Object:
case ldh_eName_Hierarchy:
case ldh_eName_Path:
case ldh_eName_VolPath:
case ldh_eName_Volume:
case ldh_eName_Aref:
case ldh_eName_ArefVol:
{
wb_attribute a = sp->attribute(arp);
if (!a) return a.sts();
//wb_name n = a.name(nametype);
break;
}
case ldh_eName_ArefExport:
case ldh_eName_Objid:
case ldh_eName_ObjectIx:
case ldh_eName_OixString:
case ldh_eName_VolumeId:
case ldh_eName_VidString:
{
wb_name n = wb_name( cdh_ArefToString( NULL, arp, 1));
strcpy( str, n.name( nametype));
*aname = str;
*size = strlen(str);
break;
}
default:
return LDH__NYI;
}
return LDH__SUCCESS;
}
......
......@@ -13,6 +13,10 @@
#include "pwr_class.h"
#endif
#ifndef co_cdh_h
#include "co_cdh.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
......@@ -117,6 +121,23 @@ typedef enum {
ldh_eMenuSet_
} ldh_eMenuSet;
typedef enum {
ldh_eName_Object = cdh_mName_object,
ldh_eName_Default = cdh_mName_object,
ldh_eName_Hierarchy = cdh_mName_pathStrict,
ldh_eName_Path = cdh_mName_path,
ldh_eName_VolPath = cdh_mName_volumeStrict,
ldh_eName_Volume = cdh_mName_volume,
ldh_eName_Objid = cdh_mName_form_id | cdh_mName_idString | cdh_mName_volume | cdh_mName_object,
ldh_eName_ObjectIx = cdh_mName_form_id | cdh_mName_idString | cdh_mName_object,
ldh_eName_OixString = cdh_mName_form_id | cdh_mName_object,
ldh_eName_VolumeId = cdh_mName_form_id | cdh_mName_idString | cdh_mName_volume,
ldh_eName_VidString = cdh_mName_form_id | cdh_mName_volume,
ldh_eName_Aref = cdh_mName_object | cdh_mName_attribute,
ldh_eName_ArefVol = cdh_mName_volume | cdh_mName_object | cdh_mName_attribute,
ldh_eName_ArefExport = cdh_mName_form_id | cdh_mName_volume | cdh_mName_object | cdh_mName_attribute
} ldh_eName;
#if 0
typedef enum { /* Object and attribute name types. */
ldh_eName__ = 0,
ldh_eName_Object, /* Cobj */
......@@ -167,6 +188,7 @@ typedef enum { /* Object and attribute name types. */
ldh_eName_Default, /* Tries to give the most intuitive name. */
ldh_eName_
} ldh_eName;
#endif
typedef enum {
ldh_eUtility__ = 0,
......
......@@ -52,8 +52,6 @@ void wb_merep::removeDbs(pwr_tStatus *sts, wb_mvrep *mvrep)
*sts = LDH__SUCCESS;
}
#define cdh_CidToVid(cid) ((cid) >> 16)
wb_cdrep *wb_merep::cdrep( pwr_tStatus *sts, const wb_orep& o)
{
if ( o.vrep() != m_vrep)
......@@ -78,3 +76,27 @@ wb_cdrep *wb_merep::cdrep( pwr_tStatus *sts, pwr_tCid cid)
}
return it->second->cdrep( cid);
}
wb_tdrep *wb_merep::tdrep( pwr_tStatus *sts, const wb_adrep& a)
{
if ( a.vrep() != m_vrep)
// Fetch from other meta environment
return m_erep->tdrep( sts, a);
map<pwr_tVid, wb_mvrep*>::iterator it = m_mvrepdbs.find( cdh_TidToVid(a.type()));
if ( it == m_mvrepdbs.end()) {
*sts = LDH__NOSUCHVOL;
return 0;
}
*sts = LDH__SUCCESS;
return it->second->tdrep( a);
}
wb_tdrep *wb_merep::tdrep( pwr_tStatus *sts, pwr_tTid tid)
{
map<pwr_tVid, wb_mvrep*>::iterator it = m_mvrepdbs.find( cdh_TidToVid( tid));
if ( it == m_mvrepdbs.end()) {
*sts = LDH__NOSUCHVOL;
return 0;
}
return it->second->tdrep( tid);
}
......@@ -7,6 +7,8 @@
using namespace std;
class wb_vrep;
class wb_tdrep;
class wb_adrep;
class wb_merep {
......@@ -24,6 +26,8 @@ class wb_merep {
wb_cdrep *cdrep( pwr_tStatus *sts, const wb_orep& o);
wb_cdrep *cdrep( pwr_tStatus *sts, pwr_tCid cid);
wb_tdrep *tdrep( pwr_tStatus *sts, const wb_adrep& a);
wb_tdrep *tdrep( pwr_tStatus *sts, pwr_tTid tid);
};
#endif
......@@ -11,3 +11,13 @@ wb_cdrep *wb_mvrep::cdrep( const wb_orep& o)
return new wb_cdrep( this, o);
}
wb_tdrep *wb_mvrep::tdrep( pwr_tTid tid)
{
return new wb_tdrep( this, tid);
}
wb_tdrep *wb_mvrep::tdrep( const wb_adrep& a)
{
return new wb_tdrep( this, a);
}
......@@ -3,6 +3,7 @@
#include "wb_vrep.h"
#include "wb_cdrep.h"
#include "wb_tdrep.h"
#include "wb_bdrep.h"
#include "wb_adrep.h"
......@@ -10,6 +11,8 @@ class wb_mvrep : public wb_vrep {
public:
wb_cdrep *cdrep( const wb_orep& o);
wb_cdrep *cdrep( pwr_tCid cid);
wb_tdrep *tdrep( const wb_adrep& a);
wb_tdrep *tdrep( pwr_tTid tid);
};
#endif
......@@ -762,6 +762,7 @@ char *wb_nrep::normName( int ntype, char *res)
char *wb_nrep::nameName( char *n, int ntype, char *res)
{
static char result[200];
int colon_added = 0;
if ( !res)
res = result;
......@@ -772,17 +773,35 @@ char *wb_nrep::nameName( char *n, int ntype, char *res)
if ( ntype & cdh_mName_volume && ntype & cdh_mName_attribute)
ntype = ntype | cdh_mName_path | cdh_mName_object;
strcpy( res, "");
if ( ntype & cdh_mName_idString) {
if ( ntype & cdh_mName_volume) printf( "wname: volume\n");
if ( ntype & cdh_mName_object) printf( "wname: object\n");
if ( ntype & cdh_mName_attribute) printf( "wname: attribute\n");
if ( !(ntype & cdh_mName_attribute)) {
if ( ntype & cdh_mName_volume && !(ntype & cdh_mName_object))
strcat( res, "_V");
else if ( !(ntype & cdh_mName_volume))
strcat( res, "_X");
else
strcat( res, "_O");
}
else
strcat( res, "_A");
}
if ( ntype & cdh_mName_volume)
volumeName( n, res);
volumeName( n, res + strlen(res));
if ( ntype & cdh_mName_path) {
if ( ntype & cdh_mName_volume && hasVolume())
if ( ntype & cdh_mName_volume && hasVolume()) {
strcat( res, ":");
colon_added = 1;
}
pathName( n, res + strlen(res));
}
if ( ntype & cdh_mName_object) {
if ( ntype & cdh_mName_path && hasPath())
strcat( res, "-");
else if ( ntype & cdh_mName_volume && !hasPath() && hasVolume())
else if ( ntype & cdh_mName_volume && !hasPath() && hasVolume() && !colon_added)
strcat( res, ":");
objectName( n, res + strlen(res));
}
......
......@@ -93,9 +93,9 @@ char *wb_object::name()
return m_orep->name();
}
char *wb_object::name( int type)
wb_name wb_object::longName()
{
return m_orep->name( type);
return m_orep->longName();
}
//
......
......@@ -61,7 +61,7 @@ public:
pwr_tOix aoix(); //< Object index of object after this object
char *name();
char *name( int type);
wb_name longName();
pwr_tTime ohTime(); //< time when this object was last changed
pwr_tTime rbTime(); //< time when run time body of this object was last changed
......
......@@ -2,6 +2,7 @@
#define wb_orep_h
#include "pwr.h"
#include "wb_name.h"
#include "wb_orep.h"
#include "wb_vrep.h"
#include "wb_ldh.h"
......@@ -38,7 +39,7 @@ public:
virtual pwr_tOid aoid() const = 0;
virtual char * const name() = 0;
virtual char * const name( int type) = 0;
virtual wb_name longName() = 0;
virtual pwr_tTime ohTime() const = 0;
virtual bool isOffspringOf(const wb_orep *o) const = 0;
......
......@@ -56,7 +56,7 @@ public:
virtual pwr_tOid aoid() const;
virtual char * const name();
virtual char * const name( int type) {return 0;}
virtual wb_name longName();
virtual pwr_tTime ohTime() const;
virtual bool isOffspringOf(const wb_orep *o) const;
......
......@@ -13,6 +13,8 @@ class wb_orepdbs : public wb_orep
friend class wb_cdrep;
friend class wb_bdrep;
friend class wb_adrep;
friend class wb_tdrep;
public:
......@@ -35,7 +37,7 @@ public:
virtual pwr_tOid aoid() const;
virtual char * const name();
virtual char * const name( int type) { return 0;}
virtual wb_name longName();
virtual pwr_tTime ohTime() const;
virtual bool isOffspringOf(const wb_orep *o) const;
......
#include "wb_orepwbl.h"
wb_orepwbl::wb_orepwbl( wb_vrepwbl *v, wb_wblnode *n): m_vrep(v), m_wblnode(n) {}
wb_orepwbl::wb_orepwbl( wb_vrepwbl *v, wb_wblnode *n): m_vrep(v), m_wblnode(n)
{}
wb_orepwbl::~wb_orepwbl()
{
......@@ -72,9 +73,12 @@ char *const wb_orepwbl::name()
return m_wblnode->name;
}
char *const wb_orepwbl::name( int type)
wb_name wb_orepwbl::longName()
{
return m_wblnode->name; // Fix
char str[200];
m_vrep->objectName( this, str);
return wb_name( str);
}
......
......@@ -14,7 +14,7 @@ class wb_orepwbl : public wb_orep
public:
wb_orepwbl(int oid);
wb_orepwbl(int oix);
wb_orepwbl( wb_vrepwbl *v, wb_wblnode *n);
~wb_orepwbl();
......@@ -33,7 +33,7 @@ public:
virtual pwr_tOid aoid() const;
virtual char * const name();
virtual char * const name( int type);
virtual wb_name longName();
virtual pwr_tTime ohTime() const;
virtual bool isOffspringOf(const wb_orep *o) const;
......
#include "wb_tdef.h"
#include "wb_adef.h"
wb_tdef::wb_tdef() : wb_status(LDH__NOTYPE), m_tdrep(0)
{
}
wb_tdef::wb_tdef( wb_tdrep *tdrep) : wb_status(LDH__SUCCESS), m_tdrep(tdrep)
{
if ( tdrep == 0)
m_sts = LDH__NOTYPE;
else
tdrep->ref();
}
wb_tdef::wb_tdef( wb_adef& a)
{
const wb_adrep *adrep = a;
try {
m_tdrep = new wb_tdrep( *adrep);
m_tdrep->ref();
m_sts = m_tdrep->sts();
}
catch ( wb_error& e) {
m_sts = e.sts();
}
}
wb_tdef::wb_tdef(wb_mvrep *mvrep, pwr_tTid tid)
{
try {
m_tdrep = new wb_tdrep( mvrep, tid);
m_tdrep->ref();
m_sts = m_tdrep->sts();
}
catch ( wb_error& e) {
m_sts = e.sts();
}
}
wb_tdef::~wb_tdef()
{
if ( m_tdrep)
m_tdrep->unref();
}
wb_tdef::wb_tdef(const wb_tdef& x) : wb_status(x.sts()), m_tdrep(x.m_tdrep)
{
if ( m_tdrep)
m_tdrep->ref();
}
wb_tdef& wb_tdef::operator=(const wb_tdef& x)
{
if ( x.m_tdrep)
x.m_tdrep->ref();
if ( m_tdrep)
m_tdrep->unref();
m_tdrep = x.m_tdrep;
m_sts = x.m_sts;
return *this;
}
void wb_tdef::check()
{
if ( !m_tdrep) throw wb_error(m_sts);
}
size_t wb_tdef::size()
{
check();
return m_tdrep->size();
}
pwr_tTid wb_tdef::tid()
{
check();
return m_tdrep->tid();
}
wb_name wb_tdef::name()
{
check();
return m_tdrep->name();
}
wb_name wb_tdef::name(ldh_eName type)
{
check();
return m_tdrep->name(type);
}
......@@ -15,35 +15,26 @@ class wb_tdef : public wb_status
public:
wb_tdrep *m_tdrep;
wb_tdef() : wb_status(LDH__NOTYPE), m_tdrep(0) {}; // Fix
wb_tdef(const wb_tdef& x) : wb_status(x.sts()), m_tdrep(x.m_tdrep) {} // Fix // x = other_object
wb_tdef(const wb_adrep*); //
wb_tdef();
wb_tdef( wb_tdrep *tdrep);
wb_tdef( wb_adef&);
wb_tdef(wb_mvrep *, pwr_tTid);
wb_tdef(const wb_tdef&);
wb_tdef& operator=(const wb_tdef&);
~wb_tdef();
~wb_tdef() {} // Fix
operator bool() const { return (m_tdrep != 0);} // Fix
operator bool() const { return m_tdrep != 0;}
operator wb_tdrep*() const;
bool operator==(wb_tdef&);
size_t size();
int offset();
int type();
pwr_tTid tid();
int nElement();
int index();
pwr_tOid aoid();
pwr_tAix aix();
pwr_tCid cid();
pwr_tOix bix();
pwr_tOid boid();
wb_tdef next();
wb_tdef prev();
wb_name name();
wb_name name(ldh_eName type);
private:
void check();
};
#endif
......
extern "C" {
#include "co_cdh.h"
}
#include "wb_tdrep.h"
#include "wb_merep.h"
#include "wb_ldh_msg.h"
#include "co_dbs.h"
#include "wb_orepdbs.h"
void wb_tdrep::unref()
{
if ( --m_nRef == 0)
delete this;
}
wb_tdrep *wb_tdrep::ref()
{
m_nRef++;
return this;
}
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);
if ( EVEN(m_sts)) throw wb_error( m_sts);
m_orep->ref();
m_sts = LDH__SUCCESS;
}
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);
if ( EVEN(m_sts)) throw wb_error( m_sts);
m_orep->ref();
m_sts = LDH__SUCCESS;
}
wb_tdrep::wb_tdrep( const wb_adrep& a) : m_nRef(0)
{
pwr_tStatus sts;
wb_tdrep *tdrep = a.vrep()->merep()->tdrep( &sts, a);
m_sts = sts;
m_orep = tdrep->m_orep;
m_orep->ref();
delete tdrep;
}
......@@ -2,42 +2,37 @@
#define wb_tdrep_h
#include "pwr.h"
#include "wb_mvrepdbs.h"
#include "wb_cdrep.h"
#include "wb_bdrep.h"
#include "wb_ldh.h"
#include "wb_name.h"
class wb_tdrep
class wb_adrep;
class wb_mrepdbs;
class wb_orepdbs;
class wb_mvrep;
class wb_tdrep
{
int m_nRef;
wb_orepdbs *m_orep;
int m_sts;
public:
wb_mvrepdbs *m_vrep;
dbs_sObject *m_ao;
wb_tdrep();
wb_tdrep(wb_mvrepdbs *vrep, dbs_sObject *ao);
wb_tdrep(const wb_tdrep&); // x = other_object
wb_tdrep& operator=(const wb_tdrep&);
~wb_tdrep();
wb_bdrep *bdef();
wb_cdrep *cdef();
pwr_sAttrRef aref();
size_t size(); // get objects runtime body size
int offset();
int type();
int nElement();
int index();
pwr_tOid aoid();
int aix();
pwr_tCid cid();
int bix();
int flags();
pwr_tOid boid();
wb_name name(); // get attribute name
wb_name name(ldh_eName type);
wb_tdrep( const wb_adrep& a);
wb_tdrep(wb_mvrep *, const wb_adrep&);
wb_tdrep(wb_mvrep *, pwr_tTid);
void unref();
wb_tdrep *ref();
size_t size() { return 0;} // Fix // get objects runtime body size
pwr_tTid tid() { return 0;} // Fix
int nElement() { return 0;} // Fix
wb_name name() { wb_name n; return n;} // Fix // get type name
wb_name name(ldh_eName type) { wb_name n; return n;} // Fix
pwr_tStatus sts() { return m_sts;}
};
#endif
......@@ -110,9 +110,9 @@ wb_object wb_volume::object(pwr_tOid oid) const
wb_object o;
if (oid.vid == m_vrep->vid())
vrep = m_vrep;
vrep = m_vrep;
else
vrep = m_vrep->erep()->volume(&sts, oid.vid);
vrep = m_vrep->erep()->volume(&sts, oid.vid);
if ( !vrep)
return o;
......@@ -123,6 +123,28 @@ wb_object wb_volume::object(pwr_tOid oid) const
return o;
}
wb_object wb_volume::object(char *name) const
{
pwr_tStatus sts;
wb_orep *orep;
wb_vrep *vrep;
wb_object o;
wb_name n = wb_name( name);
if ( !n.hasVolume() || n.volumeIsEqual( m_vrep->name()))
vrep = m_vrep;
else
vrep = m_vrep->erep()->volume(&sts, n.volume());
if ( !vrep)
return o;
// orep = vrep->object(&sts, name); // Fix
o = wb_object(sts, orep);
return o;
}
wb_cdef wb_volume::cdef(wb_object o)
{
pwr_tStatus sts;
......
......@@ -50,7 +50,7 @@ public:
wb_object object() const; // Get root list
wb_object object(pwr_tOid oid) const;
wb_object object(pwr_tCid cid) const { wb_object o; return o;} // Fix
wb_object object(char *name) const { wb_object o; return o;} // Fix
wb_object object(char *name) const;
wb_attribute attribute(pwr_tOid oid, char *bname, char *aname) { wb_attribute a; return a;}; // Fix
wb_attribute attribute(wb_object o, wb_adef adef) { wb_attribute a; return a;}; // Fix
......
......@@ -12,6 +12,7 @@
#include "wb_ldh_msg.h"
#include "wb_dbs.h"
#include "wb_erep.h"
#include "wb_ldh_msg.h"
extern "C" {
#include "co_dcli.h"
......@@ -26,6 +27,22 @@ wb_vrepwbl::~wb_vrepwbl()
}
}
wb_orep *wb_vrepwbl::object(pwr_tStatus *sts, pwr_tOid oid)
{
if ( oid.vid != m_vid) {
*sts = LDH__BADOBJID;
return 0;
}
ref_wblnode n = findObject( oid.oix);
if ( !n) {
*sts = LDH__NOSUCHOBJ;
return 0;
}
*sts = LDH__SUCCESS;
return new wb_orepwbl( this, n);
}
wb_vrep *wb_vrepwbl::next() const
{
pwr_tStatus sts;
......@@ -78,7 +95,7 @@ wb_vrepwbl::createSnapshot(char *fileName)
dbs.buildFile();
return true;
} catch (wb_error e) {
} catch (wb_error& e) {
return false;
}
}
......@@ -1010,7 +1027,7 @@ wb_orep *wb_vrepwbl::previous(pwr_tStatus *sts, wb_orep *o) const
return 0;
}
void wb_vrepwbl::objectName(pwr_tStatus *sts, wb_orep *o, char *str) const
void wb_vrepwbl::objectName(wb_orep *o, char *str) const
{
*str = 0;
......
......@@ -117,7 +117,7 @@ public:
wb_merep *merep() const { return m_merep;}
wb_orep *object(pwr_tStatus *sts);
wb_orep *object(pwr_tStatus *sts, pwr_tOid oid) {return 0;};
wb_orep *object(pwr_tStatus *sts, pwr_tOid oid);
wb_orep *object(pwr_tStatus *sts, wb_orep *parent, wb_name name)
{return 0;};
......@@ -172,7 +172,7 @@ public:
bool isLocal(wb_orep *o) const {return false;};
void objectName(pwr_tStatus *sts, wb_orep *o, char *str) const;
void objectName(wb_orep *o, char *str) const;
};
......
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