Commit dd4739a4 authored by claes's avatar claes

More adef,bdef...

parent eeec0970
#include <string.h>
#include "wb_attrname.h"
wb_attrname::wb_attrname( char *name)
{
try {
char str[80];
if ( *name != '.') {
strcpy( str, ".");
strcat( str, name);
}
else
strcpy( str, name);
m_nrep = new wb_nrep( str);
m_sts = LDH__SUCCESS;
m_nrep->ref();
}
catch ( wb_error &e) {
m_sts = e.sts();
m_nrep = 0;
}
}
#ifndef wb_attrname_h
#define wb_attrname_h
#include "wb_name.h"
class wb_attrname : public wb_name
{
public:
wb_attrname(char *);
};
#endif
......@@ -74,9 +74,21 @@ pwr_sAttrRef wb_bdef::aref()
return m_bdrep->aref();
}
wb_adef wb_bdef::adef() // Fix
wb_adef wb_bdef::adef()
{
wb_adef a;
pwr_tStatus sts;
wb_adrep *adrep = m_bdrep->adrep( &sts);
wb_adef a = wb_adef( adrep);
return a;
}
wb_adef wb_bdef::adef( char *aname)
{
pwr_tStatus sts;
wb_adrep *adrep = m_bdrep->adrep( &sts, aname);
wb_adef a = wb_adef( adrep);
return a;
}
......
......@@ -36,6 +36,18 @@ wb_cdrep::wb_cdrep( wb_mvrep *mvrep, pwr_tCid cid) : m_nRef(0)
m_sts = LDH__SUCCESS;
}
wb_cdrep::wb_cdrep( wb_mvrep *mvrep, wb_name name) : m_nRef(0)
{
char str[80];
strcpy( str, "Class-");
strcat( str, name.object());
m_orep = (wb_orepdbs *) mvrep->object( &m_sts, str);
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.cid());
......
......@@ -25,6 +25,7 @@ class wb_cdrep
wb_cdrep(const wb_orep&); // x = other orep
wb_cdrep(wb_mvrep *, const wb_orep&);
wb_cdrep(wb_mvrep *, pwr_tCid);
wb_cdrep(wb_mvrep *, wb_name);
void unref();
wb_cdrep *ref();
......
......@@ -9,6 +9,7 @@
#include "wb_orep.h"
#include "wb_tdrep.h"
#include "wb_adrep.h"
#include "wb_name.h"
#include "wb_ldh_msg.h"
extern "C" {
......@@ -76,10 +77,12 @@ wb_vrep *wb_erep::volume(pwr_tStatus *sts, char *name) // Fix
{
vrep_iterator it;
for ( it = m_vrepdb.begin(); it != m_vrepdb.end(); it++) {
// Check name
if ( cdh_NoCaseStrcmp( it->second->name(), name) == 0)
return it->second;
}
for ( it = m_vrepdbs.begin(); it != m_vrepdbs.end(); it++) {
// Check name
if ( cdh_NoCaseStrcmp( it->second->name(), name) == 0)
return it->second;
}
*sts = LDH__NOSUCHVOL;
return 0;
......@@ -413,7 +416,23 @@ wb_tdrep *wb_erep::tdrep( pwr_tStatus *sts, const wb_adrep& a)
return vrep->merep()->tdrep( sts, a);
}
wb_orep *wb_erep::object(pwr_tStatus *sts, pwr_tOid oid)
{
wb_vrep *vrep = volume( sts, oid.vid);
if ( EVEN(*sts)) return 0;
return vrep->object( sts, oid);
}
wb_orep *wb_erep::object(pwr_tStatus *sts, char *name)
{
wb_name n = wb_name(name);
wb_vrep *vrep = volume( sts, n.volume());
if ( EVEN(*sts)) return 0;
return vrep->object( sts, name);
}
......
......@@ -47,6 +47,9 @@ public:
void removeExtern( pwr_tStatus *sts, wb_vrep *vrep);
void load( pwr_tStatus *sts);
wb_orep *object( pwr_tStatus *sts, pwr_tOid oid);
wb_orep *object( pwr_tStatus *sts, char *name);
wb_cdrep *cdrep( pwr_tStatus *sts, const wb_orep& o);
wb_tdrep *tdrep( pwr_tStatus *sts, const wb_adrep& a);
......
......@@ -287,19 +287,6 @@ ldh_ClassNameToId(ldh_tSession session, pwr_tCid *cid, char *name)
return c.sts();
}
pwr_tStatus
ldh_ClassNameToObjid(ldh_tSession session, pwr_tOid *oid, char *name)
{
wb_session *sp = (wb_session *)session;
wb_cdef c = sp->cdef(name);
if (!c) return c.sts();
*oid = c.oid();
return c.sts();
}
pwr_tStatus
ldh_CloseSession(ldh_tSession session)
{
......
......@@ -380,12 +380,6 @@ pwr_tStatus ldh_ClassNameToId (
char *name
);
pwr_tStatus ldh_ClassNameToObjid (
ldh_tSession Session,
pwr_tObjid *objid,
char *name
);
pwr_tStatus ldh_CloseSession (
ldh_tSession Session
);
......
......@@ -6,7 +6,7 @@
// Get first volume
wb_mvrep *wb_merep::volume( pwr_tStatus *sts)
{
map<pwr_tVid, wb_mvrep*>::iterator it = m_mvrepdbs.begin();
mvrep_iterator it = m_mvrepdbs.begin();
if ( it == m_mvrepdbs.end()) {
*sts = LDH__NOSUCHVOL;
return 0;
......@@ -17,7 +17,7 @@ wb_mvrep *wb_merep::volume( pwr_tStatus *sts)
wb_mvrep *wb_merep::volume(pwr_tStatus *sts, pwr_tVid vid)
{
map<pwr_tVid, wb_mvrep*>::iterator it = m_mvrepdbs.find( vid);
mvrep_iterator it = m_mvrepdbs.find( vid);
if ( it == m_mvrepdbs.end()) {
*sts = LDH__NOSUCHVOL;
return 0;
......@@ -28,7 +28,7 @@ wb_mvrep *wb_merep::volume(pwr_tStatus *sts, pwr_tVid vid)
void wb_merep::addDbs( pwr_tStatus *sts, wb_mvrep *mvrep)
{
map<pwr_tVid, wb_mvrep*>::iterator it = m_mvrepdbs.find( mvrep->vid());
mvrep_iterator it = m_mvrepdbs.find( mvrep->vid());
if ( it == m_mvrepdbs.end()) {
// Look for vrep in erep list... TODO
......@@ -42,7 +42,7 @@ void wb_merep::addDbs( pwr_tStatus *sts, wb_mvrep *mvrep)
void wb_merep::removeDbs(pwr_tStatus *sts, wb_mvrep *mvrep)
{
map<pwr_tVid, wb_mvrep*>::iterator it = m_mvrepdbs.find( mvrep->vid());
mvrep_iterator it = m_mvrepdbs.find( mvrep->vid());
if ( it == m_mvrepdbs.end()) {
*sts = LDH__NOSUCHVOL;
return;
......@@ -58,7 +58,7 @@ wb_cdrep *wb_merep::cdrep( pwr_tStatus *sts, const wb_orep& o)
// Fetch from other meta environment
return m_erep->cdrep( sts, o);
map<pwr_tVid, wb_mvrep*>::iterator it = m_mvrepdbs.find( cdh_CidToVid(o.cid()));
mvrep_iterator it = m_mvrepdbs.find( cdh_CidToVid(o.cid()));
if ( it == m_mvrepdbs.end()) {
*sts = LDH__NOSUCHVOL;
return 0;
......@@ -69,13 +69,41 @@ wb_cdrep *wb_merep::cdrep( pwr_tStatus *sts, const wb_orep& o)
wb_cdrep *wb_merep::cdrep( pwr_tStatus *sts, pwr_tCid cid)
{
map<pwr_tVid, wb_mvrep*>::iterator it = m_mvrepdbs.find( cdh_CidToVid( cid));
mvrep_iterator it = m_mvrepdbs.find( cdh_CidToVid( cid));
if ( it == m_mvrepdbs.end()) {
*sts = LDH__NOSUCHVOL;
return 0;
}
return it->second->cdrep( cid);
try {
*sts = LDH__SUCCESS;
return it->second->cdrep( cid);
}
catch ( wb_error& e) {
*sts = e.sts();
return 0;
}
}
wb_cdrep *wb_merep::cdrep( pwr_tStatus *sts, wb_name name)
{
wb_cdrep *cdrep;
for ( mvrep_iterator it = m_mvrepdbs.begin(); it != m_mvrepdbs.end(); it++) {
try {
cdrep = new wb_cdrep( it->second, name);
*sts = LDH__SUCCESS;
return cdrep;
}
catch ( wb_error& e) {
// Not found in this volume, try next
}
}
// Not found
*sts = LDH__NOCLASS;
return 0;
}
wb_tdrep *wb_merep::tdrep( pwr_tStatus *sts, const wb_adrep& a)
{
if ( a.vrep() != m_vrep)
......
......@@ -17,6 +17,8 @@ class wb_merep {
wb_erep *m_erep;
wb_vrep *m_vrep;
typedef map<pwr_tVid, wb_mvrep*>::iterator mvrep_iterator;
public:
wb_merep( wb_erep *erep, wb_vrep *vrep = 0) : m_erep(erep), m_vrep(vrep) {}
wb_mvrep *volume(pwr_tStatus *sts);
......@@ -26,6 +28,7 @@ class wb_merep {
wb_cdrep *cdrep( pwr_tStatus *sts, const wb_orep& o);
wb_cdrep *cdrep( pwr_tStatus *sts, pwr_tCid cid);
wb_cdrep *cdrep( pwr_tStatus *sts, wb_name name);
wb_tdrep *tdrep( pwr_tStatus *sts, const wb_adrep& a);
wb_tdrep *tdrep( pwr_tStatus *sts, pwr_tTid tid);
};
......
......@@ -106,18 +106,15 @@ wb_object wb_volume::object(pwr_tOid oid) const
{
pwr_tStatus sts;
wb_orep *orep;
wb_vrep *vrep;
wb_object o;
if (oid.vid == m_vrep->vid())
vrep = m_vrep;
// This volume
orep = m_vrep->object( &sts, oid);
else
vrep = m_vrep->erep()->volume(&sts, oid.vid);
// Other volume
orep = m_vrep->erep()->object(&sts, oid);
if ( !vrep)
return o;
orep = vrep->object(&sts, oid);
o = wb_object(sts, orep);
return o;
......@@ -127,33 +124,80 @@ 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;
// This volume
orep = m_vrep->object( &sts, name);
else
vrep = m_vrep->erep()->volume(&sts, n.volume());
// Other volume
orep = m_vrep->erep()->object(&sts, name);
if ( !vrep)
return o;
// orep = vrep->object(&sts, name); // Fix
o = wb_object(sts, orep);
return o;
}
wb_adef wb_volume::adef( pwr_tCid cid, char *bname, char *aname)
{
pwr_tStatus sts;
wb_cdrep *cdrep = m_vrep->merep()->cdrep( &sts, cid);
if ( EVEN(sts)) return 0;
wb_cdef cdef = wb_cdef(cdrep);
wb_bdef bdef = cdef.bdef( bname);
return bdef.adef( aname);
}
wb_bdef wb_volume::bdef(wb_cdef cdef, char *bname)
{
return cdef.bdef( bname);
}
wb_bdef wb_volume::bdef(wb_object o, char *bname)
{
wb_orep *orep = o;
wb_cdef cdef = wb_cdef(*orep);
return cdef.bdef( bname);
}
wb_cdef wb_volume::cdef(wb_object o)
{
pwr_tStatus sts;
return wb_cdef(m_vrep->erep()->merep()->cdrep( &sts, o.cid()));
wb_orep *orep = o;
wb_cdrep *cdrep;
if ( orep->vrep() == m_vrep)
// Object in this volume
cdrep = m_vrep->merep()->cdrep( &sts, *orep);
else
// Object in other volume, get class info from this volume's meta environment
cdrep = m_vrep->erep()->cdrep( &sts, *orep);
return wb_cdef( cdrep);
}
wb_cdef wb_volume::cdef(pwr_tCid cid)
{
pwr_tStatus sts;
// Look in this volume's meta environment only
return wb_cdef(m_vrep->merep()->cdrep( &sts, cid));
}
wb_cdef wb_volume::cdef(pwr_tOid coid)
{
return cdef( cdh_ClassObjidToId( coid));
}
wb_cdef wb_volume::cdef(wb_name n)
{
pwr_tStatus sts;
// Look in this volume's meta environment only
return wb_cdef(m_vrep->merep()->cdrep( &sts, n));
}
......
......@@ -60,15 +60,15 @@ public:
wb_attribute attribute() { wb_attribute a; return a;}; // Fix
wb_adef adef(pwr_sAttrRef *arp) { wb_adef a; return a;}; // Fix
wb_adef adef(pwr_tCid cid, char *bname, char *aname) { wb_adef a; return a;}; // Fix
wb_adef adef(pwr_tCid cid, char *bname, char *aname);
wb_bdef bdef(wb_cdef cdef, char *bname) { wb_bdef b; return b;}; // Fix
wb_bdef bdef(wb_object o, char *bname) { wb_bdef b; return b;}; // Fix
wb_bdef bdef(wb_cdef cdef, char *bname);
wb_bdef bdef(wb_object o, char *bname);
wb_cdef cdef(wb_object o);
wb_cdef cdef(pwr_tCid cid) { wb_cdef c; return c;}; // Fix
wb_cdef cdef(pwr_tOid coid) { wb_cdef c; return c;}; // Fix
wb_cdef cdef(wb_name n) { wb_cdef c; return c;}; // Fix
wb_cdef cdef(pwr_tCid cid);
wb_cdef cdef(pwr_tOid coid);
wb_cdef cdef(wb_name n);
//wb_tdef tdef(wb_object o);
wb_tdef tdef(pwr_tTid tid) { wb_tdef t; return t;} // Fix
......
......@@ -35,6 +35,7 @@ public:
virtual wb_orep *object(pwr_tStatus *sts) = 0;
virtual wb_orep *object(pwr_tStatus *sts, pwr_tOid oid) = 0;
virtual wb_orep *object(pwr_tStatus *sts, char *name) = 0;
virtual wb_orep *object(pwr_tStatus *sts, wb_orep *parent, wb_name name) = 0;
virtual wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination d, wb_name name) = 0;
......
......@@ -129,6 +129,7 @@ public:
virtual wb_erep *erep();
virtual wb_orep *object(pwr_tStatus *sts, pwr_tOid oid);
virtual wb_orep *object(pwr_tStatus *sts, char *name);
virtual wb_orep *object(pwr_tStatus *sts, wb_orep *parent, wb_name name);
virtual wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination d, wb_name name);
......
......@@ -27,6 +27,7 @@ public:
virtual wb_erep *erep() const;
virtual wb_orep *object(pwr_tStatus *sts, pwr_tOid oid);
virtual wb_orep *object(pwr_tStatus *sts, char *name);
virtual wb_orep *object(pwr_tStatus *sts, wb_orep *parent, wb_name name);
virtual wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination d, wb_name name);
......
......@@ -43,6 +43,17 @@ wb_orep *wb_vrepwbl::object(pwr_tStatus *sts, pwr_tOid oid)
return new wb_orepwbl( this, n);
}
wb_orep *wb_vrepwbl::object(pwr_tStatus *sts, char *name)
{
ref_wblnode n = find( name);
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;
......
......@@ -118,6 +118,7 @@ public:
wb_orep *object(pwr_tStatus *sts);
wb_orep *object(pwr_tStatus *sts, pwr_tOid oid);
wb_orep *object(pwr_tStatus *sts, char *name);
wb_orep *object(pwr_tStatus *sts, wb_orep *parent, wb_name name)
{return 0;};
......
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