Commit 73d637d8 authored by ml's avatar ml

*** empty log message ***

parent 1d4ec19e
...@@ -5,16 +5,17 @@ ...@@ -5,16 +5,17 @@
#include "wb_attrname.h" #include "wb_attrname.h"
#include "pwr.h" #include "pwr.h"
wb_attribute::wb_attribute() : wb_attribute::wb_attribute() :
wb_status(LDH__NOSUCHATTR), m_orep(0), m_adrep(0), wb_status(LDH__NOSUCHATTR), m_orep(0), m_adrep(0),
m_size(0), m_offset(0), m_tid(0), m_elements(0), m_size(0), m_offset(0), m_idx(0), m_tid(0), m_elements(0),
m_type(pwr_eType_), m_flags(0), m_bix(pwr_eBix__) m_type(pwr_eType_), m_flags(0), m_bix(pwr_eBix__)
{ {
} }
wb_attribute::wb_attribute(const wb_attribute& x) : wb_attribute::wb_attribute(const wb_attribute& x) :
wb_status(x.m_sts),m_orep(x.m_orep), m_adrep( x.m_adrep), m_size(x.m_size), wb_status(x.m_sts),m_orep(x.m_orep), m_adrep( x.m_adrep), m_size(x.m_size),
m_offset(x.m_offset), m_tid(x.m_tid), m_elements(x.m_elements), m_type(x.m_type), m_offset(x.m_offset) , m_idx(x.m_idx), m_tid(x.m_tid), m_elements(x.m_elements), m_type(x.m_type),
m_flags(x.m_flags), m_bix(x.m_bix) m_flags(x.m_flags), m_bix(x.m_bix)
{ {
if ( m_orep) if ( m_orep)
...@@ -24,7 +25,7 @@ wb_attribute::wb_attribute(const wb_attribute& x) : ...@@ -24,7 +25,7 @@ wb_attribute::wb_attribute(const wb_attribute& x) :
} }
wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * orep) : wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * orep) :
wb_status(sts), m_orep(orep), m_adrep(0), m_size(0), m_offset(0), m_tid(0), wb_status(sts), m_orep(orep), m_adrep(0), m_size(0), m_offset(0), m_idx(0), m_tid(0),
m_elements(0), m_type(pwr_eType_), m_flags(0), m_bix(pwr_eBix__) m_elements(0), m_type(pwr_eType_), m_flags(0), m_bix(pwr_eBix__)
{ {
if ( orep == 0) if ( orep == 0)
...@@ -36,8 +37,8 @@ wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * orep) : ...@@ -36,8 +37,8 @@ wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * orep) :
} }
} }
wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, wb_adrep* adrep) : wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, wb_adrep* adrep, int idx) :
wb_status(sts), m_orep(orep), m_adrep(adrep), m_size(0), m_offset(0), m_tid(0), wb_status(sts), m_orep(orep), m_adrep(adrep), m_size(0), m_offset(0), m_idx(0), m_tid(0),
m_elements(0), m_type(pwr_eType_), m_flags(0), m_bix(pwr_eBix__) m_elements(0), m_type(pwr_eType_), m_flags(0), m_bix(pwr_eBix__)
{ {
if ( orep == 0) if ( orep == 0)
...@@ -53,6 +54,13 @@ wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, wb_adrep* adrep) : ...@@ -53,6 +54,13 @@ wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, wb_adrep* adrep) :
m_elements = m_adrep->nElement(); m_elements = m_adrep->nElement();
m_type = m_adrep->type(); m_type = m_adrep->type();
m_flags = m_adrep->flags(); m_flags = m_adrep->flags();
if (m_flags & PWR_MASK_ARRAY) {
if (idx >= m_elements)
throw wb_error_str("wb_attribute() subscript out of range");
m_idx = idx;
} else
m_idx = 0;
} }
else { else {
// m_size == get rtbody size... Fix // m_size == get rtbody size... Fix
...@@ -61,7 +69,7 @@ wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, wb_adrep* adrep) : ...@@ -61,7 +69,7 @@ wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, wb_adrep* adrep) :
} }
wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, const char* bname) : wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, const char* bname) :
wb_status(sts), m_orep(orep), m_adrep(0), m_size(0), m_offset(0), m_tid(0), wb_status(sts), m_orep(orep), m_adrep(0), m_size(0), m_offset(0), m_idx(0), m_tid(0),
m_elements(0), m_type(pwr_eType_), m_flags(0), m_bix(pwr_eBix__) m_elements(0), m_type(pwr_eType_), m_flags(0), m_bix(pwr_eBix__)
{ {
if ( orep == 0) if ( orep == 0)
...@@ -83,8 +91,8 @@ wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, const char* bname) : ...@@ -83,8 +91,8 @@ wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, const char* bname) :
} }
} }
wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, char const* bname, const char* aname) : wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, const char* bname, const char* aname) :
wb_status(sts), m_orep(orep), m_adrep(0), m_size(0), m_offset(0), m_tid(0), wb_status(sts), m_orep(orep), m_adrep(0), m_size(0), m_offset(0), m_idx(0), m_tid(0),
m_elements(0), m_type(pwr_eType_), m_flags(0), m_bix(pwr_eBix__) m_elements(0), m_type(pwr_eType_), m_flags(0), m_bix(pwr_eBix__)
{ {
if ( orep == 0) if ( orep == 0)
...@@ -128,7 +136,7 @@ wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, char const* bname, co ...@@ -128,7 +136,7 @@ wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, char const* bname, co
} }
} }
wb_attribute::wb_attribute(wb_attribute& pa, int idx, const char* aname) : wb_attribute::wb_attribute(const wb_attribute& pa, int idx, const char* aname) :
wb_status(LDH__NOSUCHATTR), m_orep(0), m_adrep(0), m_size(0), m_offset(0), m_tid(0), wb_status(LDH__NOSUCHATTR), m_orep(0), m_adrep(0), m_size(0), m_offset(0), m_tid(0),
m_elements(0), m_type(pwr_eType_), m_flags(0), m_bix(pwr_eBix__) m_elements(0), m_type(pwr_eType_), m_flags(0), m_bix(pwr_eBix__)
{ {
...@@ -229,6 +237,7 @@ wb_attribute& wb_attribute::operator=(const wb_attribute& x) ...@@ -229,6 +237,7 @@ wb_attribute& wb_attribute::operator=(const wb_attribute& x)
m_sts = x.m_sts; m_sts = x.m_sts;
m_size = x.m_size; m_size = x.m_size;
m_offset = x.m_offset; m_offset = x.m_offset;
m_idx = x.m_idx;
m_tid = x.m_tid; m_tid = x.m_tid;
m_elements = x.m_elements; m_elements = x.m_elements;
m_type = x.m_type; m_type = x.m_type;
...@@ -247,75 +256,75 @@ void wb_attribute::check() const ...@@ -247,75 +256,75 @@ void wb_attribute::check() const
// //
// Return object identifier of attribute. // Return object identifier of attribute.
// //
pwr_sAttrRef wb_attribute::aref() pwr_sAttrRef wb_attribute::aref() const
{ {
pwr_sAttrRef aref; pwr_sAttrRef aref;
return aref; return aref;
} }
pwr_sAttrRef *wb_attribute::aref(pwr_sAttrRef *arp) pwr_sAttrRef *wb_attribute::aref(pwr_sAttrRef *arp) const
{ {
return arp; return arp;
} }
size_t wb_attribute::size() size_t wb_attribute::size() const
{ {
check(); check();
return m_size; return m_size;
} }
size_t wb_attribute::offset() size_t wb_attribute::offset() const
{ {
check(); check();
return m_offset; return m_offset;
} }
pwr_eType wb_attribute::type() pwr_eType wb_attribute::type() const
{ {
check(); check();
return m_type; return m_type;
} }
int wb_attribute::nElement() int wb_attribute::nElement() const
{ {
check(); check();
return m_elements; return m_elements;
} }
int wb_attribute::index() int wb_attribute::index() const
{ {
if ( m_adrep) if ( m_adrep)
return m_adrep->index(); return m_adrep->index();
return 0; return 0;
} }
int wb_attribute::flags() int wb_attribute::flags() const
{ {
check(); check();
return m_flags; return m_flags;
} }
pwr_tAix wb_attribute::aix() pwr_tAix wb_attribute::aix() const
{ {
throw wb_error_str("wb_attribute::aix() NYI"); throw wb_error_str("wb_attribute::aix() NYI");
return 0; // Fix return 0; // Fix
} }
pwr_tCid wb_attribute::cid() pwr_tCid wb_attribute::cid() const
{ {
check(); check();
return m_orep->cid(); return m_orep->cid();
} }
pwr_eBix wb_attribute::bix() pwr_eBix wb_attribute::bix() const
{ {
throw wb_error_str("wb_attribute::bix() NYI"); throw wb_error_str("wb_attribute::bix() NYI");
return pwr_eBix__; // Fix return pwr_eBix__; // Fix
} }
pwr_tOid wb_attribute::boid() pwr_tOid wb_attribute::boid() const
{ {
throw wb_error_str("wb_attribute::boid() NYI"); throw wb_error_str("wb_attribute::boid() NYI");
...@@ -323,32 +332,32 @@ pwr_tOid wb_attribute::boid() ...@@ -323,32 +332,32 @@ pwr_tOid wb_attribute::boid()
return oid; // Fix return oid; // Fix
} }
pwr_tCid wb_attribute::subClass() pwr_tCid wb_attribute::subClass() const
{ {
if ( m_adrep) if ( m_adrep)
return m_adrep->subClass(); return m_adrep->subClass();
return 0; return 0;
} }
bool wb_attribute::checkXref() bool wb_attribute::checkXref() const
{ {
throw wb_error_str("wb_attribute::checkXref() NYI"); throw wb_error_str("wb_attribute::checkXref() NYI");
return true; // Fix return true; // Fix
} }
pwr_sAttrXRef *wb_attribute::xref() pwr_sAttrXRef *wb_attribute::xref() const
{ {
throw wb_error_str("wb_attribute::xref() NYI"); throw wb_error_str("wb_attribute::xref() NYI");
return (pwr_sAttrXRef*)0; // Fix return (pwr_sAttrXRef*)0; // Fix
} }
pwr_sObjXRef *wb_attribute::oxref() pwr_sObjXRef *wb_attribute::oxref() const
{ {
throw wb_error_str("wb_attribute::oxref() NYI"); throw wb_error_str("wb_attribute::oxref() NYI");
return (pwr_sObjXRef*)0; // Fix return (pwr_sObjXRef*)0; // Fix
} }
void *wb_attribute::value( void *p) void *wb_attribute::value( void *p) const
{ {
pwr_eBix bix; pwr_eBix bix;
pwr_tStatus sts; pwr_tStatus sts;
...@@ -366,34 +375,34 @@ void *wb_attribute::value( void *p) ...@@ -366,34 +375,34 @@ void *wb_attribute::value( void *p)
return m_orep->vrep()->readAttribute( &sts, m_orep, bix, m_offset, m_size, p); return m_orep->vrep()->readAttribute( &sts, m_orep, bix, m_offset, m_size, p);
} }
void *wb_attribute::value(void *vp, size_t size, pwr_tStatus *sts) void *wb_attribute::value(void *vp, size_t size, pwr_tStatus *sts) const
{ {
return 0; return 0;
} }
string wb_attribute::toString() string wb_attribute::toString() const
{ {
throw wb_error_str("wb_attribute::toString() NYI"); throw wb_error_str("wb_attribute::toString() NYI");
string a; string a;
return a; return a;
} }
pwr_tStatus wb_attribute::fromString(string) pwr_tStatus wb_attribute::fromString(string) const
{ {
throw wb_error_str("wb_attribute::fromString() NYI"); throw wb_error_str("wb_attribute::fromString() NYI");
pwr_tStatus sts; pwr_tStatus sts;
return sts; return sts;
} }
pwr_tStatus wb_attribute::fromString(char *) pwr_tStatus wb_attribute::fromString(char *) const
{ {
throw wb_error_str("wb_attribute::fromString() NYI"); throw wb_error_str("wb_attribute::fromString() NYI");
pwr_tStatus sts; pwr_tStatus sts;
return sts; return sts;
} }
wb_attribute wb_attribute::after() wb_attribute wb_attribute::after() const
{ {
pwr_tStatus sts; pwr_tStatus sts;
...@@ -417,14 +426,14 @@ wb_attribute wb_attribute::after() ...@@ -417,14 +426,14 @@ wb_attribute wb_attribute::after()
return a; return a;
} }
wb_attribute wb_attribute::before() wb_attribute wb_attribute::before() const
{ {
wb_attribute a; wb_attribute a;
return a; return a;
} }
wb_attribute wb_attribute::first(int idx) wb_attribute wb_attribute::first(int idx) const
{ {
if (!isClass()) if (!isClass())
return wb_attribute(); return wb_attribute();
...@@ -434,7 +443,7 @@ wb_attribute wb_attribute::first(int idx) ...@@ -434,7 +443,7 @@ wb_attribute wb_attribute::first(int idx)
} }
wb_attribute wb_attribute::child(int idx, const char* name) wb_attribute wb_attribute::child(int idx, const char* name) const
{ {
if (!isClass()) if (!isClass())
return wb_attribute(); return wb_attribute();
...@@ -451,8 +460,8 @@ const char *wb_attribute::name() const ...@@ -451,8 +460,8 @@ const char *wb_attribute::name() const
return m_orep->name(); return m_orep->name();
} }
// Fix, no index and no subclass !!! // Fix, no no subclass !!!
wb_name wb_attribute::longName() wb_name wb_attribute::longName() const
{ {
check(); check();
...@@ -460,11 +469,12 @@ wb_name wb_attribute::longName() ...@@ -460,11 +469,12 @@ wb_name wb_attribute::longName()
return m_orep->longName(); return m_orep->longName();
char str[512]; char str[512];
strcpy( str, m_orep->longName().name()); int len;
strcat( str, "."); len = sprintf( str, "%s.%s", m_orep->longName().c_str(), m_adrep->name());
strcat( str, m_adrep->name()); if (m_flags & PWR_MASK_ARRAY && m_idx != -1)
sprintf(&str[len], "[%d]", m_idx);
wb_name n = wb_name( str); wb_name n( str);
return n; return n;
} }
......
...@@ -32,6 +32,7 @@ class wb_attribute : public wb_status ...@@ -32,6 +32,7 @@ class wb_attribute : public wb_status
size_t m_size; size_t m_size;
size_t m_offset; size_t m_offset;
int m_idx; // -1 if whole array, only valid for arrays
pwr_tTid m_tid; pwr_tTid m_tid;
int m_elements; int m_elements;
pwr_eType m_type; pwr_eType m_type;
...@@ -43,16 +44,16 @@ public: ...@@ -43,16 +44,16 @@ public:
wb_attribute(); wb_attribute();
wb_attribute(const wb_attribute&); wb_attribute(const wb_attribute&);
wb_attribute(pwr_tStatus, wb_orep*); wb_attribute(pwr_tStatus, wb_orep*);
wb_attribute(pwr_tStatus, wb_orep*, wb_adrep*); wb_attribute(pwr_tStatus, wb_orep*, wb_adrep*, int idx = -1);
wb_attribute(pwr_tStatus, wb_orep*, const char* bname); wb_attribute(pwr_tStatus, wb_orep*, const char* bname);
wb_attribute(pwr_tStatus, wb_orep*, const char* bname, const char* aname); wb_attribute(pwr_tStatus, wb_orep*, const char* bname, const char* aname);
wb_attribute(wb_attribute& pa, int idx, const char* aname); wb_attribute(const wb_attribute& pa, int idx, const char* aname);
~wb_attribute(); ~wb_attribute();
wb_attribute& operator=(const wb_attribute&); wb_attribute& operator=(const wb_attribute&);
operator bool() const { return oddSts();} operator bool() const { return oddSts();}
operator wb_orep*() const; operator wb_orep*() const;
bool operator==(wb_attribute&); bool operator==( const wb_attribute&);
//wb_object& operator=(const wb_orep&); //wb_object& operator=(const wb_orep&);
...@@ -60,47 +61,47 @@ public: ...@@ -60,47 +61,47 @@ public:
bool isArray() const {return (m_flags & PWR_MASK_ARRAY);} bool isArray() const {return (m_flags & PWR_MASK_ARRAY);}
pwr_tOid aoid(); // get objects object id pwr_tOid aoid() const; // get objects object id
pwr_sAttrRef aref(); pwr_sAttrRef aref() const;
pwr_sAttrRef *aref(pwr_sAttrRef *arp); pwr_sAttrRef *aref(pwr_sAttrRef *arp) const;
size_t size(); size_t size() const;
size_t offset(); size_t offset() const;
pwr_eType type(); pwr_eType type() const;
int nElement(); int nElement() const;
int index(); int index() const;
int flags(); int flags() const;
pwr_tAix aix(); pwr_tAix aix() const;
// Class of attribute object // Class of attribute object
pwr_tCid cid(); pwr_tCid cid() const;
pwr_eBix bix(); pwr_eBix bix() const;
pwr_tOid boid(); pwr_tOid boid() const;
bool checkXref(); bool checkXref() const;
pwr_sAttrXRef *xref(); pwr_sAttrXRef *xref() const;
pwr_sObjXRef *oxref(); pwr_sObjXRef *oxref() const;
pwr_tCid subClass(); pwr_tCid subClass() const;
void *value( void *p = 0); void *value( void *p = 0) const;
void *value(void *vp, size_t size, pwr_tStatus*); void *value(void *vp, size_t size, pwr_tStatus*) const;
string toString(); string toString() const;
pwr_tStatus fromString(string); pwr_tStatus fromString(string) const;
pwr_tStatus fromString(char *); pwr_tStatus fromString(char *) const;
wb_attribute after(); wb_attribute after() const;
wb_attribute before(); wb_attribute before() const;
wb_attribute first(int idx); wb_attribute first(int idx) const;
wb_attribute child(int idx, const char* name); wb_attribute child(int idx, const char* name) const;
const char *name() const; const char *name() const;
wb_name longName(); wb_name longName() const;
void name(const char *name); void name(const char *name);
void name(wb_name *name); void name(wb_name *name);
pwr_tStatus sts() { return m_sts;} pwr_tStatus sts() const { return m_sts;}
private: private:
void check() const; void check() const;
......
...@@ -19,11 +19,14 @@ wb_print_wbl::wb_print_wbl(ostream& os, int levelIndentation) : ...@@ -19,11 +19,14 @@ wb_print_wbl::wb_print_wbl(ostream& os, int levelIndentation) :
m_errCnt(0), m_errCnt(0),
m_idxFlag(true), m_idxFlag(true),
m_level(0), m_level(0),
m_levelIndentation(levelIndentation), m_levelInd(levelIndentation),
m_os(os) m_os(os)
{ {
memset(m_indBuf, ' ', sizeof(m_indBuf));
m_indBuf[sizeof(m_indBuf) -1] = 0;
} }
wb_print_wbl::~wb_print_wbl() wb_print_wbl::~wb_print_wbl()
{ {
} }
...@@ -457,9 +460,9 @@ bool wb_print_wbl::printValue (wb_volume& v, ...@@ -457,9 +460,9 @@ bool wb_print_wbl::printValue (wb_volume& v,
else { else {
o = v.object(*(pwr_tOid *)val); o = v.object(*(pwr_tOid *)val);
if (o) if (o)
strcpy(sval, o.longName().c_str()); sprintf(sval, "\"%s\"", o.longName().c_str());
else else
sprintf(sval, "%s", cdh_ObjidToString(NULL, *(pwr_tObjid *)val, 1)); sprintf(sval, "\"%s\"", cdh_ObjidToString(NULL, *(pwr_tObjid *)val, 1));
} }
break; break;
case pwr_eType_ObjectIx: case pwr_eType_ObjectIx:
...@@ -480,7 +483,7 @@ bool wb_print_wbl::printValue (wb_volume& v, ...@@ -480,7 +483,7 @@ bool wb_print_wbl::printValue (wb_volume& v,
else { else {
wb_cdef cdef = v.cdef(*(pwr_tCid *)val); wb_cdef cdef = v.cdef(*(pwr_tCid *)val);
if (cdef) if (cdef)
strcpy(sval, cdef.longName().c_str()); sprintf(sval, "\"%s\"", cdef.longName().c_str());
else { else {
sprintf(sval, "Unknown class, identity: %d", (*(pwr_tClassId *) val)); sprintf(sval, "Unknown class, identity: %d", (*(pwr_tClassId *) val));
m_errCnt++; m_errCnt++;
...@@ -496,7 +499,7 @@ bool wb_print_wbl::printValue (wb_volume& v, ...@@ -496,7 +499,7 @@ bool wb_print_wbl::printValue (wb_volume& v,
oid = cdh_TypeIdToObjid(*(pwr_tTid *)val); oid = cdh_TypeIdToObjid(*(pwr_tTid *)val);
o = v.object(oid); o = v.object(oid);
if (o) if (o)
strcpy(sval, o.longName().c_str()); sprintf(sval, "\"%s\"", o.longName().c_str());
else { else {
sprintf(sval, "Unknown type, identity: %d", (*(pwr_tTypeId *) val)); sprintf(sval, "Unknown type, identity: %d", (*(pwr_tTypeId *) val));
m_errCnt++; m_errCnt++;
...@@ -510,9 +513,9 @@ bool wb_print_wbl::printValue (wb_volume& v, ...@@ -510,9 +513,9 @@ bool wb_print_wbl::printValue (wb_volume& v,
else { else {
wb_attribute a = v.attribute((pwr_sAttrRef*)val); wb_attribute a = v.attribute((pwr_sAttrRef*)val);
if (a) if (a)
strcpy(sval, a.longName().c_str()); sprintf(sval, "\"%s\"", a.longName().c_str());
else { else {
sprintf(sval, "%s", cdh_ArefToString(NULL, (pwr_sAttrRef*)val, 1)); sprintf(sval, "\"%s\"", cdh_ArefToString(NULL, (pwr_sAttrRef*)val, 1));
} }
} }
...@@ -591,14 +594,17 @@ void wb_print_wbl::printVolume(wb_volume& v, bool recursive) ...@@ -591,14 +594,17 @@ void wb_print_wbl::printVolume(wb_volume& v, bool recursive)
// //
ostream& wb_print_wbl::indent(int levelIncr) ostream& wb_print_wbl::indent(int levelIncr)
{ {
if (levelIncr < 0) if (levelIncr < 0)
m_level += levelIncr; m_level += levelIncr;
assert(m_level >= 0); assert(m_level >= 0);
m_indBuf[m_level * m_levelInd] = '\0';
m_os << m_indBuf;
for (int i = 0; i < m_level * m_levelIndentation; i++) m_indBuf[m_level * m_levelInd] = ' ';
m_os << " ";
if (levelIncr > 0) if (levelIncr > 0)
m_level += levelIncr; m_level += levelIncr;
......
...@@ -25,7 +25,8 @@ protected: ...@@ -25,7 +25,8 @@ protected:
int m_errCnt; int m_errCnt;
bool m_idxFlag; bool m_idxFlag;
int m_level; int m_level;
int m_levelIndentation; int m_levelInd;
char m_indBuf[256];
ostream& m_os; ostream& m_os;
...@@ -65,7 +66,7 @@ protected: ...@@ -65,7 +66,7 @@ protected:
public: public:
wb_print_wbl(ostream& os, int levelIndentation = 3); wb_print_wbl(ostream& os, int levelIndentation = 2);
~wb_print_wbl(); ~wb_print_wbl();
int getErrCnt() const { return m_errCnt;} int getErrCnt() const { return m_errCnt;}
......
#include "wb_volume.h" #include "wb_volume.h"
#include "wb_merep.h" #include "wb_merep.h"
#include "wb_bdrep.h"
#include "wb_cdrep.h"
wb_volume::wb_volume() : wb_status(LDH__NOSUCHVOL), m_vrep(0) wb_volume::wb_volume() : wb_status(LDH__NOSUCHVOL), m_vrep(0)
{ {
...@@ -197,7 +199,7 @@ wb_attribute wb_volume::attribute(pwr_tOid oid, const char *bname, const char *a ...@@ -197,7 +199,7 @@ wb_attribute wb_volume::attribute(pwr_tOid oid, const char *bname, const char *a
// Other volume // Other volume
orep = m_vrep->erep()->object(&sts, oid); orep = m_vrep->erep()->object(&sts, oid);
wb_attribute a = wb_attribute(sts, orep, bname, aname); wb_attribute a(sts, orep, bname, aname);
return a; return a;
} }
...@@ -214,12 +216,84 @@ wb_attribute wb_volume::attribute(pwr_tOid oid, const char *bname) const ...@@ -214,12 +216,84 @@ wb_attribute wb_volume::attribute(pwr_tOid oid, const char *bname) const
// Other volume // Other volume
orep = m_vrep->erep()->object(&sts, oid); orep = m_vrep->erep()->object(&sts, oid);
wb_attribute a = wb_attribute(sts, orep, bname); wb_attribute a(sts, orep, bname);
return a; return a;
} }
wb_attribute wb_volume::attribute(const pwr_sAttrRef* arp) const
{
pwr_tStatus sts;
int idx;
wb_orep* orep = 0;
wb_cdrep* cdrep = 0;
wb_bdrep* bdrep = 0;
wb_adrep* adrep = 0;
wb_adrep* old;
if (arp->Objid.vid == m_vrep->vid())
// This volume
orep = m_vrep->object( &sts, arp->Objid);
else
// Other volume
orep = m_vrep->erep()->object(&sts, arp->Objid);
if (EVEN(sts))
return wb_attribute();
cdrep = new wb_cdrep(*orep);
if (EVEN(cdrep->sts()))
goto error;
bdrep = cdrep->bdrep(&sts, pwr_eBix_rt);
if (bdrep == 0)
goto error;
// Check if we shall reference the whole object
if (arp->Size == 0 || (arp->Offset == 0 && arp->Size == bdrep->size())) {
wb_attribute a(sts, orep);
delete bdrep;
delete cdrep;
return a;
}
// We need to find a matching attribute
adrep = bdrep->adrep(&sts);
while (ODD(sts)) {
if (arp->Offset < (adrep->offset() + adrep->size())){
break;
}
old = adrep;
adrep = adrep->next(&sts);
delete old;
}
// We have found a matching attribute
if (ODD(sts)) {
if (arp->Size == 0 || arp->Size > (adrep->size() / adrep->nElement())) {
// Map whole atribute
idx = (adrep->nElement() > 1) ? -1 : 0;
} else if (adrep->nElement() > 1) {
idx = (arp->Offset - adrep->offset()) / (adrep->size() / adrep->nElement());
}
delete cdrep;
delete bdrep;
wb_attribute a(LDH__SUCCESS, orep, adrep, idx);
return a;
}
error:
delete orep;
delete cdrep;
delete bdrep;
return wb_attribute();
}
......
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
wb_attribute attribute(wb_object o, wb_adef adef) { wb_attribute a; return a;}; // Fix wb_attribute attribute(wb_object o, wb_adef adef) { wb_attribute a; return a;}; // Fix
wb_attribute attribute(wb_object o, wb_name aname) { wb_attribute a; return a;}; // Fix wb_attribute attribute(wb_object o, wb_name aname) { wb_attribute a; return a;}; // Fix
wb_attribute attribute(wb_name aname) { wb_attribute a; return a;}; // Fix wb_attribute attribute(wb_name aname) { wb_attribute a; return a;}; // Fix
wb_attribute attribute(pwr_sAttrRef *arp) { wb_attribute a; return a;}; // Fix wb_attribute attribute(const pwr_sAttrRef *arp) const;
wb_attribute attribute() { wb_attribute a; return a;}; // Fix 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_sAttrRef *arp) { wb_adef a; return a;}; // Fix
......
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