Commit d24baefa authored by claes's avatar claes

*** empty log message ***

parent f3182024
#include "wb_attribute.h" #include "wb_attribute.h"
#include "wb_cdrep.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_attribute::wb_attribute(const wb_attribute&) wb_attribute::wb_attribute(const wb_attribute& x) : wb_status(x.m_sts),m_orep(x.m_orep),
m_adrep(x.m_adrep)
{ {
if ( m_orep)
m_orep->ref();
if ( m_adrep)
m_adrep->ref();
} }
wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * const orep) : wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * const orep) : wb_status(sts),
m_orep(orep), m_sts(sts) m_orep(orep), m_adrep(0)
{ {
m_orep->ref();
} }
wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * const orep, const char *name) : wb_attribute::wb_attribute(pwr_tStatus sts, wb_orep * const orep, char *name) :
m_orep(orep), m_sts(sts) wb_status(sts), m_orep(orep), m_adrep(0)
{ {
wb_cdrep *cdrep = new wb_cdrep( *orep);
cdrep->ref();
m_adrep = cdrep->adrep( &m_sts, name);
if ( oddSts())
m_adrep->ref();
cdrep->unref();
} }
wb_attribute& wb_attribute::operator=(const wb_attribute&) wb_attribute& wb_attribute::operator=(const wb_attribute& x)
{ {
if ( x.m_orep)
x.m_orep->ref();
if ( x.m_adrep)
x.m_adrep->ref();
if ( m_orep)
m_orep->unref();
if ( m_adrep)
m_adrep->unref();
m_orep = x.m_orep;
m_adrep = x.m_adrep;
m_sts = x.m_sts;
return *this; return *this;
} }
......
...@@ -26,19 +26,16 @@ using namespace std; ...@@ -26,19 +26,16 @@ using namespace std;
class wb_adrep; class wb_adrep;
class wb_orep; class wb_orep;
class wb_attribute class wb_attribute : public wb_status
{ {
public:
wb_orep *m_orep; wb_orep *m_orep;
wb_adrep *m_adrep; wb_adrep *m_adrep;
pwr_tStatus m_sts; public:
wb_attribute(); wb_attribute();
wb_attribute(const wb_attribute&); // x = other_object wb_attribute(const wb_attribute&); // x = other_object
wb_attribute(pwr_tStatus, wb_orep* const ); // x = other orep wb_attribute(pwr_tStatus, wb_orep* const ); // x = other orep
wb_attribute(pwr_tStatus, wb_orep* const, const char*); wb_attribute(pwr_tStatus, wb_orep* const, char*);
wb_attribute(pwr_tStatus, wb_orep* const, wb_adrep* const) {}; wb_attribute(pwr_tStatus, wb_orep* const, wb_adrep* const) {};
wb_attribute& operator=(const wb_attribute&); wb_attribute& operator=(const wb_attribute&);
...@@ -47,8 +44,6 @@ public: ...@@ -47,8 +44,6 @@ public:
operator wb_adrep*() const; operator wb_adrep*() const;
bool operator==(wb_attribute&); bool operator==(wb_attribute&);
pwr_tStatus sts() const;
//wb_object& operator=(const wb_orep&); //wb_object& operator=(const wb_orep&);
pwr_tOid aoid(); // get objects object id pwr_tOid aoid(); // get objects object id
......
...@@ -8,6 +8,7 @@ extern "C" { ...@@ -8,6 +8,7 @@ extern "C" {
#include "co_dbs.h" #include "co_dbs.h"
#include "wb_orepdbs.h" #include "wb_orepdbs.h"
#include "wb_bdrep.h" #include "wb_bdrep.h"
#include "wb_adrep.h"
void wb_cdrep::unref() void wb_cdrep::unref()
{ {
...@@ -75,3 +76,26 @@ wb_bdrep *wb_cdrep::bdrep( pwr_tStatus *sts, char *bname) ...@@ -75,3 +76,26 @@ wb_bdrep *wb_cdrep::bdrep( pwr_tStatus *sts, char *bname)
wb_bdrep *bdrep = new wb_bdrep( *orep); wb_bdrep *bdrep = new wb_bdrep( *orep);
return bdrep; return bdrep;
} }
wb_adrep *wb_cdrep::adrep( pwr_tStatus *sts, char *aname)
{
wb_orepdbs *orep_attr;
wb_orepdbs *orep = (wb_orepdbs *)m_orep->first( sts);
while ( ODD(*sts)) {
if ( orep->cid() == pwr_eClass_ObjBodyDef) {
orep_attr = (wb_orepdbs *)orep->m_vrep->child( sts, orep, aname);
if ( ODD(*sts)) {
wb_adrep *adrep = new wb_adrep( *orep);
return adrep;
}
}
orep_attr = (wb_orepdbs *)orep_attr->next( sts);
}
return 0;
}
wb_name wb_cdrep::name()
{
wb_name n = wb_name( m_orep->name());
return n;
}
...@@ -36,12 +36,13 @@ class wb_cdrep ...@@ -36,12 +36,13 @@ class wb_cdrep
pwr_tCid cid() { return 0;} // Fix pwr_tCid cid() { return 0;} // Fix
wb_name name() { wb_name n; return n;} // Fix get class name wb_name name(); // get class name
wb_name name(ldh_eName type) { wb_name n; return n;} // Fix wb_name name(ldh_eName type) { wb_name n; return n;} // Fix
void name(const char *name); void name(const char *name);
void name(wb_name *name); void name(wb_name *name);
wb_bdrep *bdrep( pwr_tStatus *sts, char *bname); wb_bdrep *bdrep( pwr_tStatus *sts, char *bname);
wb_adrep *adrep( pwr_tStatus *sts, char *aname);
pwr_tStatus sts() { return m_sts;} pwr_tStatus sts() { return m_sts;}
}; };
......
...@@ -93,6 +93,11 @@ char *wb_object::name() ...@@ -93,6 +93,11 @@ char *wb_object::name()
return m_orep->name(); return m_orep->name();
} }
char *wb_object::name( int type)
{
return m_orep->name( type);
}
// //
// Get next object of same class // Get next object of same class
// //
......
...@@ -61,6 +61,7 @@ public: ...@@ -61,6 +61,7 @@ public:
pwr_tOix aoix(); //< Object index of object after this object pwr_tOix aoix(); //< Object index of object after this object
char *name(); char *name();
char *name( int type);
pwr_tTime ohTime(); //< time when this object was last changed pwr_tTime ohTime(); //< time when this object was last changed
pwr_tTime rbTime(); //< time when run time body of this object was last changed pwr_tTime rbTime(); //< time when run time body of this object was last changed
......
...@@ -38,6 +38,7 @@ public: ...@@ -38,6 +38,7 @@ public:
virtual pwr_tOid aoid() const = 0; virtual pwr_tOid aoid() const = 0;
virtual char * const name() = 0; virtual char * const name() = 0;
virtual char * const name( int type) = 0;
virtual pwr_tTime ohTime() const = 0; virtual pwr_tTime ohTime() const = 0;
virtual bool isOffspringOf(const wb_orep *o) const = 0; virtual bool isOffspringOf(const wb_orep *o) const = 0;
......
...@@ -56,6 +56,7 @@ public: ...@@ -56,6 +56,7 @@ public:
virtual pwr_tOid aoid() const; virtual pwr_tOid aoid() const;
virtual char * const name(); virtual char * const name();
virtual char * const name( int type) {return 0;}
virtual pwr_tTime ohTime() const; virtual pwr_tTime ohTime() const;
virtual bool isOffspringOf(const wb_orep *o) const; virtual bool isOffspringOf(const wb_orep *o) const;
......
...@@ -35,6 +35,7 @@ public: ...@@ -35,6 +35,7 @@ public:
virtual pwr_tOid aoid() const; virtual pwr_tOid aoid() const;
virtual char * const name(); virtual char * const name();
virtual char * const name( int type) { return 0;}
virtual pwr_tTime ohTime() const; virtual pwr_tTime ohTime() const;
virtual bool isOffspringOf(const wb_orep *o) const; virtual bool isOffspringOf(const wb_orep *o) const;
......
...@@ -72,6 +72,11 @@ char *const wb_orepwbl::name() ...@@ -72,6 +72,11 @@ char *const wb_orepwbl::name()
return m_wblnode->name; return m_wblnode->name;
} }
char *const wb_orepwbl::name( int type)
{
return m_wblnode->name; // Fix
}
pwr_tTime wb_orepwbl::ohTime() const pwr_tTime wb_orepwbl::ohTime() const
{ {
......
...@@ -33,6 +33,7 @@ public: ...@@ -33,6 +33,7 @@ public:
virtual pwr_tOid aoid() const; virtual pwr_tOid aoid() const;
virtual char * const name(); virtual char * const name();
virtual char * const name( int type);
virtual pwr_tTime ohTime() const; virtual pwr_tTime ohTime() const;
virtual bool isOffspringOf(const wb_orep *o) const; virtual bool isOffspringOf(const wb_orep *o) const;
......
...@@ -1010,4 +1010,33 @@ wb_orep *wb_vrepwbl::previous(pwr_tStatus *sts, wb_orep *o) const ...@@ -1010,4 +1010,33 @@ wb_orep *wb_vrepwbl::previous(pwr_tStatus *sts, wb_orep *o) const
return 0; return 0;
} }
void wb_vrepwbl::objectName(pwr_tStatus *sts, wb_orep *o, char *str) const
{
*str = 0;
// Count ancestors
int cnt = 0;
wb_wblnode *n = ((wb_orepwbl *)o)->wblNode();
while ( n) {
cnt++;
n = n->o_fth;
}
wb_wblnode **vect = (wb_wblnode **) calloc( cnt, sizeof(vect));
n = ((wb_orepwbl *)o)->wblNode();
for ( int i = 0; i < cnt; i++) {
vect[i] = n;
n = n->o_fth;
}
for ( int i = cnt - 1; i >= 0; i--) {
strcat( str, vect[i]->name);
if ( i == cnt - 1)
strcat( str, ":");
else if ( i != 0)
strcat( str, "-");
}
free( vect);
}
...@@ -172,6 +172,8 @@ public: ...@@ -172,6 +172,8 @@ public:
bool isLocal(wb_orep *o) const {return false;}; bool isLocal(wb_orep *o) const {return false;};
void objectName(pwr_tStatus *sts, wb_orep *o, char *str) const;
}; };
#endif #endif
......
...@@ -913,6 +913,7 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol) ...@@ -913,6 +913,7 @@ void wb_wblnode::registerNode( wb_vrepwbl *vol)
else else
setFirstChild( (RefAST)c_template); setFirstChild( (RefAST)c_template);
strcpy( c_template->cname, name); strcpy( c_template->cname, name);
c_template->m_oid.oix = m_vrep->nextOix();
c_template->m_cid = c_cid; c_template->m_cid = c_cid;
c_template->node_type = wbl_eNodeType_Template; c_template->node_type = wbl_eNodeType_Template;
} }
......
...@@ -3453,6 +3453,7 @@ static int wnav_create_func( void *client_data, ...@@ -3453,6 +3453,7 @@ static int wnav_create_func( void *client_data,
wb_vrepwbl *wbl = new wb_vrepwbl(erep); wb_vrepwbl *wbl = new wb_vrepwbl(erep);
wbl->load( filestr); wbl->load( filestr);
wbl->createSnapshot( outstr); wbl->createSnapshot( outstr);
delete wbl;
} }
catch ( wb_error &e) { catch ( wb_error &e) {
sts = e.sts(); sts = e.sts();
......
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