Commit 73d637d8 authored by ml's avatar ml

*** empty log message ***

parent 1d4ec19e
......@@ -5,16 +5,17 @@
#include "wb_attrname.h"
#include "pwr.h"
wb_attribute::wb_attribute() :
wb_attribute::wb_attribute() :
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__)
{
}
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),
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)
{
if ( m_orep)
......@@ -24,7 +25,7 @@ wb_attribute::wb_attribute(const wb_attribute& x) :
}
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__)
{
if ( orep == 0)
......@@ -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_status(sts), m_orep(orep), m_adrep(adrep), m_size(0), m_offset(0), m_tid(0),
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_idx(0), m_tid(0),
m_elements(0), m_type(pwr_eType_), m_flags(0), m_bix(pwr_eBix__)
{
if ( orep == 0)
......@@ -53,6 +54,13 @@ wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep* orep, wb_adrep* adrep) :
m_elements = m_adrep->nElement();
m_type = m_adrep->type();
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 {
// m_size == get rtbody size... Fix
......@@ -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_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__)
{
if ( orep == 0)
......@@ -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_status(sts), m_orep(orep), m_adrep(0), m_size(0), m_offset(0), m_tid(0),
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_idx(0), m_tid(0),
m_elements(0), m_type(pwr_eType_), m_flags(0), m_bix(pwr_eBix__)
{
if ( orep == 0)
......@@ -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),
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)
m_sts = x.m_sts;
m_size = x.m_size;
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;
......@@ -247,75 +256,75 @@ void wb_attribute::check() const
//
// Return object identifier of attribute.
//
pwr_sAttrRef wb_attribute::aref()
pwr_sAttrRef wb_attribute::aref() const
{
pwr_sAttrRef aref;
return aref;
}
pwr_sAttrRef *wb_attribute::aref(pwr_sAttrRef *arp)
pwr_sAttrRef *wb_attribute::aref(pwr_sAttrRef *arp) const
{
return arp;
}
size_t wb_attribute::size()
size_t wb_attribute::size() const
{
check();
return m_size;
}
size_t wb_attribute::offset()
size_t wb_attribute::offset() const
{
check();
return m_offset;
}
pwr_eType wb_attribute::type()
pwr_eType wb_attribute::type() const
{
check();
return m_type;
}
int wb_attribute::nElement()
int wb_attribute::nElement() const
{
check();
return m_elements;
}
int wb_attribute::index()
int wb_attribute::index() const
{
if ( m_adrep)
return m_adrep->index();
return 0;
}
int wb_attribute::flags()
int wb_attribute::flags() const
{
check();
return m_flags;
}
pwr_tAix wb_attribute::aix()
pwr_tAix wb_attribute::aix() const
{
throw wb_error_str("wb_attribute::aix() NYI");
return 0; // Fix
}
pwr_tCid wb_attribute::cid()
pwr_tCid wb_attribute::cid() const
{
check();
return m_orep->cid();
}
pwr_eBix wb_attribute::bix()
pwr_eBix wb_attribute::bix() const
{
throw wb_error_str("wb_attribute::bix() NYI");
return pwr_eBix__; // Fix
}
pwr_tOid wb_attribute::boid()
pwr_tOid wb_attribute::boid() const
{
throw wb_error_str("wb_attribute::boid() NYI");
......@@ -323,32 +332,32 @@ pwr_tOid wb_attribute::boid()
return oid; // Fix
}
pwr_tCid wb_attribute::subClass()
pwr_tCid wb_attribute::subClass() const
{
if ( m_adrep)
return m_adrep->subClass();
return 0;
}
bool wb_attribute::checkXref()
bool wb_attribute::checkXref() const
{
throw wb_error_str("wb_attribute::checkXref() NYI");
return true; // Fix
}
pwr_sAttrXRef *wb_attribute::xref()
pwr_sAttrXRef *wb_attribute::xref() const
{
throw wb_error_str("wb_attribute::xref() NYI");
return (pwr_sAttrXRef*)0; // Fix
}
pwr_sObjXRef *wb_attribute::oxref()
pwr_sObjXRef *wb_attribute::oxref() const
{
throw wb_error_str("wb_attribute::oxref() NYI");
return (pwr_sObjXRef*)0; // Fix
}
void *wb_attribute::value( void *p)
void *wb_attribute::value( void *p) const
{
pwr_eBix bix;
pwr_tStatus sts;
......@@ -366,34 +375,34 @@ void *wb_attribute::value( void *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;
}
string wb_attribute::toString()
string wb_attribute::toString() const
{
throw wb_error_str("wb_attribute::toString() NYI");
string a;
return a;
}
pwr_tStatus wb_attribute::fromString(string)
pwr_tStatus wb_attribute::fromString(string) const
{
throw wb_error_str("wb_attribute::fromString() NYI");
pwr_tStatus sts;
return sts;
}
pwr_tStatus wb_attribute::fromString(char *)
pwr_tStatus wb_attribute::fromString(char *) const
{
throw wb_error_str("wb_attribute::fromString() NYI");
pwr_tStatus sts;
return sts;
}
wb_attribute wb_attribute::after()
wb_attribute wb_attribute::after() const
{
pwr_tStatus sts;
......@@ -417,14 +426,14 @@ wb_attribute wb_attribute::after()
return a;
}
wb_attribute wb_attribute::before()
wb_attribute wb_attribute::before() const
{
wb_attribute a;
return a;
}
wb_attribute wb_attribute::first(int idx)
wb_attribute wb_attribute::first(int idx) const
{
if (!isClass())
return wb_attribute();
......@@ -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())
return wb_attribute();
......@@ -451,21 +460,22 @@ const char *wb_attribute::name() const
return m_orep->name();
}
// Fix, no index and no subclass !!!
wb_name wb_attribute::longName()
// Fix, no no subclass !!!
wb_name wb_attribute::longName() const
{
check();
if ( !m_adrep)
return m_orep->longName();
char str[512];
strcpy( str, m_orep->longName().name());
strcat( str, ".");
strcat( str, m_adrep->name());
char str[512];
int len;
len = sprintf( str, "%s.%s", m_orep->longName().c_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);
return n;
wb_name n( str);
return n;
}
void wb_attribute::name(const char *name)
......
......@@ -28,10 +28,11 @@ class wb_orep;
class wb_attribute : public wb_status
{
wb_orep *m_orep;
wb_adrep *m_adrep;
wb_adrep *m_adrep;
size_t m_size;
size_t m_offset;
int m_idx; // -1 if whole array, only valid for arrays
pwr_tTid m_tid;
int m_elements;
pwr_eType m_type;
......@@ -43,16 +44,16 @@ public:
wb_attribute();
wb_attribute(const wb_attribute&);
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, 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& operator=(const wb_attribute&);
operator bool() const { return oddSts();}
operator wb_orep*() const;
bool operator==(wb_attribute&);
bool operator==( const wb_attribute&);
//wb_object& operator=(const wb_orep&);
......@@ -60,47 +61,47 @@ public:
bool isArray() const {return (m_flags & PWR_MASK_ARRAY);}
pwr_tOid aoid(); // get objects object id
pwr_sAttrRef aref();
pwr_sAttrRef *aref(pwr_sAttrRef *arp);
size_t size();
size_t offset();
pwr_eType type();
int nElement();
int index();
int flags();
pwr_tAix aix();
pwr_tOid aoid() const; // get objects object id
pwr_sAttrRef aref() const;
pwr_sAttrRef *aref(pwr_sAttrRef *arp) const;
size_t size() const;
size_t offset() const;
pwr_eType type() const;
int nElement() const;
int index() const;
int flags() const;
pwr_tAix aix() const;
// Class of attribute object
pwr_tCid cid();
pwr_eBix bix();
pwr_tOid boid();
bool checkXref();
pwr_sAttrXRef *xref();
pwr_sObjXRef *oxref();
pwr_tCid subClass();
pwr_tCid cid() const;
pwr_eBix bix() const;
pwr_tOid boid() const;
bool checkXref() const;
pwr_sAttrXRef *xref() const;
pwr_sObjXRef *oxref() const;
pwr_tCid subClass() const;
void *value( void *p = 0);
void *value(void *vp, size_t size, pwr_tStatus*);
void *value( void *p = 0) const;
void *value(void *vp, size_t size, pwr_tStatus*) const;
string toString();
pwr_tStatus fromString(string);
pwr_tStatus fromString(char *);
string toString() const;
pwr_tStatus fromString(string) const;
pwr_tStatus fromString(char *) const;
wb_attribute after();
wb_attribute before();
wb_attribute after() const;
wb_attribute before() const;
wb_attribute first(int idx);
wb_attribute child(int idx, const char* name);
wb_attribute first(int idx) const;
wb_attribute child(int idx, const char* name) const;
const char *name() const;
wb_name longName();
wb_name longName() const;
void name(const char *name);
void name(wb_name *name);
pwr_tStatus sts() { return m_sts;}
pwr_tStatus sts() const { return m_sts;}
private:
void check() const;
......
......@@ -19,11 +19,14 @@ wb_print_wbl::wb_print_wbl(ostream& os, int levelIndentation) :
m_errCnt(0),
m_idxFlag(true),
m_level(0),
m_levelIndentation(levelIndentation),
m_levelInd(levelIndentation),
m_os(os)
{
memset(m_indBuf, ' ', sizeof(m_indBuf));
m_indBuf[sizeof(m_indBuf) -1] = 0;
}
wb_print_wbl::~wb_print_wbl()
{
}
......@@ -457,9 +460,9 @@ bool wb_print_wbl::printValue (wb_volume& v,
else {
o = v.object(*(pwr_tOid *)val);
if (o)
strcpy(sval, o.longName().c_str());
sprintf(sval, "\"%s\"", o.longName().c_str());
else
sprintf(sval, "%s", cdh_ObjidToString(NULL, *(pwr_tObjid *)val, 1));
sprintf(sval, "\"%s\"", cdh_ObjidToString(NULL, *(pwr_tObjid *)val, 1));
}
break;
case pwr_eType_ObjectIx:
......@@ -480,7 +483,7 @@ bool wb_print_wbl::printValue (wb_volume& v,
else {
wb_cdef cdef = v.cdef(*(pwr_tCid *)val);
if (cdef)
strcpy(sval, cdef.longName().c_str());
sprintf(sval, "\"%s\"", cdef.longName().c_str());
else {
sprintf(sval, "Unknown class, identity: %d", (*(pwr_tClassId *) val));
m_errCnt++;
......@@ -496,7 +499,7 @@ bool wb_print_wbl::printValue (wb_volume& v,
oid = cdh_TypeIdToObjid(*(pwr_tTid *)val);
o = v.object(oid);
if (o)
strcpy(sval, o.longName().c_str());
sprintf(sval, "\"%s\"", o.longName().c_str());
else {
sprintf(sval, "Unknown type, identity: %d", (*(pwr_tTypeId *) val));
m_errCnt++;
......@@ -510,9 +513,9 @@ bool wb_print_wbl::printValue (wb_volume& v,
else {
wb_attribute a = v.attribute((pwr_sAttrRef*)val);
if (a)
strcpy(sval, a.longName().c_str());
sprintf(sval, "\"%s\"", a.longName().c_str());
else {
sprintf(sval, "%s", cdh_ArefToString(NULL, (pwr_sAttrRef*)val, 1));
sprintf(sval, "\"%s\"", cdh_ArefToString(NULL, (pwr_sAttrRef*)val, 1));
}
}
......@@ -591,16 +594,19 @@ void wb_print_wbl::printVolume(wb_volume& v, bool recursive)
//
ostream& wb_print_wbl::indent(int levelIncr)
{
if (levelIncr < 0)
m_level += levelIncr;
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_os << " ";
m_indBuf[m_level * m_levelInd] = ' ';
if (levelIncr > 0)
if (levelIncr > 0)
m_level += levelIncr;
return m_os;
......
......@@ -22,58 +22,59 @@ class wb_volume;
class wb_print_wbl
{
protected:
int m_errCnt;
bool m_idxFlag;
int m_level;
int m_levelIndentation;
ostream& m_os;
int m_errCnt;
bool m_idxFlag;
int m_level;
int m_levelInd;
char m_indBuf[256];
ostream& m_os;
ostream& indent(int levelIncr = 0);
ostream& indent(int levelIncr = 0);
void printAttribute(wb_volume& v,
wb_attribute& attr,
wb_attribute& tattr, ///< template attribute
wb_adef& adef);
void printAttribute(wb_volume& v,
wb_attribute& attr,
wb_attribute& tattr, ///< template attribute
wb_adef& adef);
void printBody(wb_volume& v,
wb_object& o,
wb_object& templ,
wb_cdef& cdef,
pwr_eBix bix);
void printBody(wb_volume& v,
wb_object& o,
wb_object& templ,
wb_cdef& cdef,
pwr_eBix bix);
void printClass(wb_volume& v,
wb_attribute& attr,
wb_attribute& tattr, ///< template attribute
wb_adef& adef);
void printParameter(wb_volume& v,
wb_attribute& attr,
wb_attribute& tattr, ///< template attribute
wb_adef& adef);
void printText(wb_volume& v,
wb_adef& adef,
const char* text,
int varSize);
bool printValue(wb_volume& v,
wb_adef& adef,
void *val,
int varSize,
char **svalp);
void printParameter(wb_volume& v,
wb_attribute& attr,
wb_attribute& tattr, ///< template attribute
wb_adef& adef);
void printText(wb_volume& v,
wb_adef& adef,
const char* text,
int varSize);
bool printValue(wb_volume& v,
wb_adef& adef,
void *val,
int varSize,
char **svalp);
public:
wb_print_wbl(ostream& os, int levelIndentation = 3);
~wb_print_wbl();
wb_print_wbl(ostream& os, int levelIndentation = 2);
~wb_print_wbl();
int getErrCnt() const { return m_errCnt;}
void resetErrCnt() {m_errCnt = 0; }
int getErrCnt() const { return m_errCnt;}
void resetErrCnt() {m_errCnt = 0; }
void printHierarchy(wb_volume& v, wb_object& o); //< Prints a hierarchy
void printObject(wb_volume& v, wb_object& o, bool recursive = true); //< Prints an object
void printVolume(wb_volume& v, bool recursive = true); //< Prints the volume
void printHierarchy(wb_volume& v, wb_object& o); //< Prints a hierarchy
void printObject(wb_volume& v, wb_object& o, bool recursive = true); //< Prints an object
void printVolume(wb_volume& v, bool recursive = true); //< Prints the volume
};
......
#include "wb_volume.h"
#include "wb_merep.h"
#include "wb_bdrep.h"
#include "wb_cdrep.h"
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
// Other volume
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;
}
......@@ -214,12 +216,84 @@ wb_attribute wb_volume::attribute(pwr_tOid oid, const char *bname) const
// Other volume
orep = m_vrep->erep()->object(&sts, oid);
wb_attribute a = wb_attribute(sts, orep, bname);
wb_attribute a(sts, orep, bname);
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:
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_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_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