コード例 #1
0
ファイル: wb_session.cpp プロジェクト: siamect/proview
bool wb_session::moveObject(wb_object o, wb_destination d)
{
  if (isReadonly())
    throw wb_error_str("ReadOnlySession");

  validateDestination(d, o.cid());
  if (evenSts())
    return false;

  // Check that object is not ancestor to destination
  wb_object dest = object(d.oid());
  while (dest) {
    if (cdh_ObjidIsEqual(dest.oid(), o.oid()))
      throw wb_error(LDH__BADDEST);
    dest = dest.parent();
  }

  wb_object parent;
  switch (d.code()) {
  case ldh_eDest_IntoFirst:
  case ldh_eDest_IntoLast:
    parent = object(d.oid());
    break;
  case ldh_eDest_After:
  case ldh_eDest_Before:
    parent = object(d.oid()).parent();
    break;
  default:
    throw wb_error(LDH__NODEST);
  }

  wb_object old_parent = o.parent();
  m_sts = triggAnteMove(o, parent, old_parent);
  if (evenSts())
    return false;
  m_sts = triggAnteUnadopt(old_parent, o);
  if (evenSts())
    return false;
  m_sts = triggAnteAdopt(parent, o.cid());
  if (evenSts())
    return false;

  ldh_sEvent* ep = m_srep->eventStart(o.oid(), ldh_eEvent_ObjectMoved);
  m_srep->eventOldFamily(ep, o);

  bool rsts = m_vrep->moveObject(&m_sts, (wb_orep*)o, d);
  m_srep->update();

  triggPostMove(o);
  triggPostUnadopt(old_parent, o);
  triggPostAdopt(parent, o);

  m_srep->eventNewFamily(ep, o);
  m_srep->eventSend(ep);

  return rsts;
}
コード例 #2
0
wb_nrep::wb_nrep( const char *n) throw (wb_error) :
  m_nRef(0), num_seg(0), num_attr(0), vol_len(0),
  vol_offs(0), b_size(0), b_offset(0), seg(0), attr(0), m_hasSuper(false),
  m_shadowed(false)
{ 
  const char *s;
  int seg_cnt = 1;
  int attr_cnt = 0;
  int name_len = 0;

  if (*n != '_') {
    // Count number of segments and attributes

    for ( s = n; *s; s++) {
      if ( *s == '-') seg_cnt++;
      else if ( *s == '.') attr_cnt++;
      name_len++;
    }
    if ( name_len >= (int) sizeof( oname)) {
      throw wb_error(LDH__BADNAME);
      return;
    }
  }
  else {
    name_type = wname_eType_Name;
    int enable_cnt = 0;
    seg_cnt = 2;
    attr_cnt = 1;
    for ( s = n; *s; s++) {
      if ( *s == ')')
        enable_cnt = 1;
      else if ( *s == '[')
        enable_cnt = 0;
      else if ( *s == ']')
        enable_cnt = 1;
      if ( enable_cnt && *s == '.') attr_cnt++;
      name_len++;
    }
    if ( name_len >= (int) sizeof( oname)) {
      throw wb_error(LDH__BADNAME);
      return;
    }
  }
  if ( seg_cnt)
    seg = (wb_namesegments *) calloc( seg_cnt, sizeof( wb_namesegments));
  if ( attr_cnt) {
    attr = (wb_nameattributes *) calloc( attr_cnt, sizeof( wb_nameattributes));
    for ( int i = 0; i < attr_cnt; i++)
      attr[i].index = -1;
  }
  strcpy( oname, n);
  parse();
}
コード例 #3
0
void *wb_adrep::body( void *p)
{
  pwr_tStatus sts;
  int size;

  switch ( m_orep->cid()) {
  case pwr_eClass_Param:
    size = sizeof( pwr_sParam);
    break;
  case pwr_eClass_Intern:
  case pwr_eClass_Input:
  case pwr_eClass_Output:
    size = sizeof( pwr_sIntern);
    break;
  case pwr_eClass_ObjXRef:
    size = sizeof( pwr_sObjXRef);
    break;
  case pwr_eClass_AttrXRef:
    size = sizeof( pwr_sAttrXRef);
    break;
  case pwr_eClass_Buffer:
    size = sizeof( pwr_sBuffer);
    break;
  default:
    throw wb_error(LDH__NYI);
  }

  return m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, p);
}
コード例 #4
0
ファイル: wb_bdrep.cpp プロジェクト: Strongc/proview
wb_bdrep::wb_bdrep( wb_adrep *adrep) : m_nRef(0), m_merep(0)
{
  pwr_tStatus sts;
  m_orep = adrep->m_orep->parent( &sts);
  if ( EVEN(sts)) throw wb_error(sts);
  m_sts = LDH__SUCCESS;
}
コード例 #5
0
ファイル: wb_vrepdbs.cpp プロジェクト: siamect/proview
dbs_sVenv* wb_vrepdbs::dbsenv()
{
  pwr_tStatus sts;

  if (!m_isDbsenvLoaded) {
    m_dbsmep = dbs_Map(&sts, m_fileName);
    if (!m_dbsmep) {
      throw wb_error(sts);
    }

    m_isDbsenvLoaded = true;

    m_dbsvep = dbs_Vmap(&sts, 0, m_dbsmep);

    strcpy(m_name, m_dbsvep->vp->name);
    m_vid = m_dbsvep->vp->vid;
    m_cid = m_dbsvep->vp->cid;

    for (int i = 0; i < dbs_nVolRef(&sts, m_dbsmep); i++) {
      dbs_sVenv* vep = dbs_Vmap(&sts, i + 1, m_dbsmep);
      wb_vrepdbs* vp
          = new wb_vrepdbs(m_erep, m_merep, m_fileName, m_dbsmep, vep);
      m_merep->addDbs(&sts, (wb_mvrep*)vp);
    }
  }

  return m_dbsvep;
}
コード例 #6
0
ファイル: wb_object.cpp プロジェクト: siamect/proview
bool wb_object::check()
{
  if (m_orep == 0) {
    m_sts = LDH__NOSUCHOBJ; // LDH__NOOBJECT;
    throw wb_error(m_sts);
  }
  return true;
}
コード例 #7
0
ファイル: wb_session.cpp プロジェクト: siamect/proview
wb_object wb_session::createObject(wb_cdef cdef, wb_destination d, wb_name name)
{
  wb_orep* orep = 0;

  if (isReadonly())
    throw wb_error_str("ReadOnlySession");

  validateDestination(d, cdef.cid());
  if (evenSts())
    throw wb_error(sts());

  wb_object parent;
  switch (d.code()) {
  case ldh_eDest_IntoFirst:
  case ldh_eDest_IntoLast:
    parent = object(d.oid());
    break;
  case ldh_eDest_After:
  case ldh_eDest_Before:
    parent = object(d.oid()).parent();
    break;
  default:
    throw wb_error(LDH__NODEST);
  }

  m_sts = triggAnteCreate(parent, cdef.cid());
  if (evenSts())
    throw wb_error(sts());
  m_sts = triggAnteAdopt(parent, cdef.cid());
  if (evenSts())
    throw wb_error(sts());

  orep = m_vrep->createObject(&m_sts, cdef, d, name);
  if (evenSts())
    throw wb_error(sts());
  m_srep->update();

  wb_object o = wb_object(m_sts, orep);
  ldh_sEvent* ep = m_srep->eventStart(o.oid(), ldh_eEvent_ObjectCreated);
  m_srep->eventNewFamily(ep, o);
  triggPostCreate(o);
  triggPostAdopt(parent, o);
  m_srep->eventSend(ep);
  return o;
}
コード例 #8
0
ファイル: wb_bdrep.cpp プロジェクト: Strongc/proview
size_t wb_bdrep::size()
{
  pwr_tStatus sts;
  pwr_sObjBodyDef body;

  m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &body);
  if ( EVEN(sts)) throw wb_error(sts);

  return body.Size;
}
コード例 #9
0
ファイル: wb_bdrep.cpp プロジェクト: Strongc/proview
char *wb_bdrep::structName()
{
  pwr_sObjBodyDef body;
  pwr_tStatus sts;

  m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &body);
  if ( EVEN(sts)) throw wb_error(sts);

  strcpy( m_structname, body.StructName);
  return m_structname;
}
コード例 #10
0
ファイル: wb_vrepdbs.cpp プロジェクト: siamect/proview
bool wb_vrepdbs::exportTree(wb_treeimport& i, pwr_tOid oid)
{
  pwr_tStatus sts;

  dbs_sObject* op = dbs_OidToObject(&sts, dbsenv(), oid);
  if (op == 0)
    throw wb_error(LDH__NOSUCHOBJ);

  exportTreeObject(i, op, true);
  return true;
}
コード例 #11
0
ファイル: wb_db.cpp プロジェクト: jordibrus/proview
wb_db_ohead &wb_db_ohead::get(wb_db_txn *txn, pwr_tOid oid)
{
  int rc = 0;
  m_oid = oid;
  m_data.set_ulen(sizeof(m_o));
  m_data.set_flags(DB_DBT_USERMEM);

  rc = m_db->m_t_ohead->get(txn, &m_key, &m_data, 0);
  if ( rc == DB_NOTFOUND)
    throw wb_error(LDH__NOSUCHOBJ);
  if (rc)
    printf("wb_db_ohead::get(txn, oid = %d.%d), get, rc %d\n", oid.vid, oid.oix, rc);
  //pwr_Assert(oid.oix == m_o.oid.oix);
  if (oid.oix != m_o.oid.oix)
    printf("oid.oix (%d.%d) != m_o.oid.oix (%d.%d), %s\n", oid.vid, oid.oix, m_o.oid.vid, m_o.oid.oix, m_o.name);
  return *this;
}
コード例 #12
0
ファイル: wb_bdrep.cpp プロジェクト: Strongc/proview
pwr_sAttrRef wb_bdrep::aref()
{
  pwr_tStatus sts;
  pwr_sObjBodyDef body;

  m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &body);
  if ( EVEN(sts)) throw wb_error(sts);

  pwr_sAttrRef aref;
  
  aref.Objid = pwr_cNOid;
  aref.Body = cdh_oixToBix( m_orep->oid().oix);
  aref.Offset = 0;
  aref.Size = body.Size;
  aref.Flags.m = 0;  // ?? Is this right?

  return aref;
}
コード例 #13
0
bool wb_treeimport::importUpdateTree( wb_vrep *vrep)
{
  iterator_translation_table it;
  pwr_tStatus sts;

  // Update all imported objects, get objects from the translationtable
  for ( it = m_translation_table.begin(); it != m_translation_table.end(); it++) {
    pwr_tOid oid;
    oid.oix = it->second;
    oid.vid = vrep->vid();
    wb_orep *o = vrep->object( &sts, oid);
    if ( EVEN(sts)) throw wb_error( LDH__NOSUCHOBJ);

    o->ref();
    importUpdateObject( o, vrep);
    o->unref();
  }
  return true;
}
コード例 #14
0
ファイル: wb_name.cpp プロジェクト: siamect/proview
void wb_name::check() const
{
  if (evenSts())
    throw wb_error(m_sts);
}
コード例 #15
0
bool wb_treeimport::importUpdateSubClass( wb_adrep *subattr, char *body, wb_vrep *vrep, 
					  bool *modified)
{
  pwr_tStatus sts;
  pwr_tOix oix;
  pwr_tCid cid = subattr->subClass();
  wb_cdrep *cdrep = vrep->merep()->cdrep( &sts, cid);
  if ( EVEN(sts)) throw wb_error(sts);
  wb_bdrep *bdrep = cdrep->bdrep( &sts, pwr_eBix_rt);
  if ( EVEN(sts)) throw wb_error(sts);

  int subattr_elements = subattr->isArray() ? subattr->nElement() : 1;

  for ( int i = 0; i < subattr_elements; i++) {
    wb_adrep *adrep = bdrep->adrep( &sts);
    while ( ODD(sts)) {
      int elements = adrep->isArray() ? adrep->nElement() : 1;
      if ( adrep->isClass()) {
	importUpdateSubClass( adrep, body + i * subattr->size() / subattr_elements + adrep->offset(),
			vrep, modified);
      }
      else {
	switch ( adrep->type()) {
	case pwr_eType_Objid: {
	  pwr_tOid *oidp = (pwr_tOid *)(body + i * subattr->size() / subattr_elements + 
					adrep->offset());
	  for ( int j = 0; j < elements; j++) {
	    if ( oidp->vid == m_import_source_vid && (oix = importTranslate( oidp->oix))) {
	      oidp->vid = vrep->vid();
	      oidp->oix = oix;
	      *modified = true;
	    }
	    else if ( ldh_isSymbolicVid( oidp->vid) && 
		      (oix = importTranslateCid(oidp->oix))) {
	      oidp->oix = oix;
	      *modified = true;
	    }
	    oidp++;
	  }
	  break;
	}
	case pwr_eType_AttrRef: {
	  pwr_sAttrRef *arp = (pwr_sAttrRef *)(body + i * subattr->size() / subattr_elements + 
					adrep->offset());
	  for ( int j = 0; j < elements; j++) {
	    if ( arp->Objid.vid == m_import_source_vid && (oix = importTranslate( arp->Objid.oix))) {
	      arp->Objid.vid = vrep->vid();
	      arp->Objid.oix = oix;
	      *modified = true;
	    }
	    else if ( ldh_isSymbolicVid( arp->Objid.vid) && 
		      (oix = importTranslateCid(arp->Objid.oix))) {
	      arp->Objid.oix = oix;
	      *modified = true;
	    }
	    arp++;
	  }
	  break;
	}
	case pwr_eType_DataRef: {
	  pwr_tDataRef *drp = (pwr_tDataRef *)(body + i * subattr->size() / subattr_elements + 
					adrep->offset());
	  for ( int j = 0; j < elements; j++) {
	    if ( drp->Aref.Objid.vid == m_import_source_vid && 
		 (oix = importTranslate( drp->Aref.Objid.oix))) {
	      drp->Aref.Objid.vid = vrep->vid();
	      drp->Aref.Objid.oix = oix;
	      *modified = true;
	    }
	    drp++;
	  }
	  break;
	}
	default:
	  ;
	}
      }
      wb_adrep *prev = adrep;
      adrep = adrep->next( &sts);
      delete prev;
    }
  }
  delete bdrep;
  delete cdrep;

  return true;
}
コード例 #16
0
bool wb_treeimport::importUpdateObject( wb_orep *o, wb_vrep *vrep)
{
  pwr_tOix oix;
  pwr_tStatus sts;
  wb_cdrep *cdrep = vrep->merep()->cdrep( &sts, o->cid());
  if ( EVEN(sts)) throw wb_error(sts);
  pwr_mClassDef flags = cdrep->flags();

  for ( int i = 0; i < 2; i++) {
    pwr_eBix bix = i ? pwr_eBix_rt : pwr_eBix_dev;

    wb_bdrep *bdrep = cdrep->bdrep( &sts, bix);
    if ( EVEN(sts)) continue;

    int size = bdrep->size();
    
    char *body = (char *)malloc( bdrep->size());
    vrep->readBody( &sts, o, bix, body);
    if ( EVEN(sts)) throw wb_error(sts);

    bool modified = false;

    wb_adrep *adrep = bdrep->adrep( &sts);
    while ( ODD(sts)) {
      int elements = adrep->isArray() ? adrep->nElement() : 1;
      if (adrep->offset() < 0 || ((int)(adrep->offset() + adrep->size()) > size))
        printf("(adrep->offset() < 0 || (adrep->offset() + adrep->size() > size))\n");
      
      if ( adrep->isClass()) {
	importUpdateSubClass( adrep, body + adrep->offset(), vrep, &modified);
      }
      else {
	switch ( adrep->type()) {
	case pwr_eType_Objid: {
	  pwr_tOid *oidp = (pwr_tOid *)(body + adrep->offset());
	  for ( int j = 0; j < elements; j++) {
	    if ( oidp->vid == m_import_source_vid && (oix = importTranslate( oidp->oix))) {
	      oidp->vid = vrep->vid();
	      oidp->oix = oix;
	      modified = true;
	    }
	    else if ( ldh_isSymbolicVid( oidp->vid) && 
		      (oix = importTranslateCid(oidp->oix))) {
	      oidp->oix = oix;
	      modified = true;
	    }
	    oidp++;
	  }
	  break;
	}
	case pwr_eType_AttrRef: {
	  pwr_sAttrRef *arp = (pwr_sAttrRef *)(body + adrep->offset());
	  for ( int j = 0; j < elements; j++) {
	    if ( arp->Objid.vid == m_import_source_vid && (oix = importTranslate( arp->Objid.oix))) {
	      arp->Objid.vid = vrep->vid();
	      arp->Objid.oix = oix;
	      modified = true;
	    }
	    else if ( ldh_isSymbolicVid( arp->Objid.vid) && 
		      (oix = importTranslateCid(arp->Objid.oix))) {
	      arp->Objid.oix = oix;
	      modified = true;
	    }
	    arp++;
	  }
	  break;
	}
	case pwr_eType_DataRef: {
	  pwr_tDataRef *drp = (pwr_tDataRef *)(body + adrep->offset());
	  for ( int j = 0; j < elements; j++) {
	    if ( drp->Aref.Objid.vid == m_import_source_vid && 
		 (oix = importTranslate( drp->Aref.Objid.oix))) {
	      drp->Aref.Objid.vid = vrep->vid();
	      drp->Aref.Objid.oix = oix;
	      modified = true;
	    }
	    drp++;
	  }
	  break;
	}
	default:
	  ;
	}
      }
      wb_adrep *prev = adrep;
      adrep = adrep->next( &sts);
      delete prev;
    }
    if ( modified) {
      vrep->writeBody( &sts, o, bix, body);
      if ( EVEN(sts)) throw wb_error(sts);
    }
    free( body);
    delete bdrep;
  }

  delete cdrep;
  return true;
}
コード例 #17
0
wb_adrep::wb_adrep( wb_orep& o): m_nRef(0), m_orep(&o), m_sts(LDH__SUCCESS),
				 m_subClass(pwr_eClass__), m_isSubattr(false)
{
  m_orep->ref();
  strcpy( m_subName, "");

  pwr_tStatus sts;
  switch ( m_orep->cid()) {
  case pwr_eClass_Param:
  {
    pwr_sParam attr;

    m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &attr);
    if ( EVEN(sts)) throw wb_error(sts);

    strcpy( m_pgmname, attr.Info.PgmName);
    m_size = attr.Info.Size;
    m_type = attr.Info.Type;
    m_offset = m_suboffset = attr.Info.Offset;
    m_elements = attr.Info.Elements;
    m_paramindex = attr.Info.ParamIndex;
    m_flags = attr.Info.Flags;
    m_tid = attr.TypeRef;
    if ( m_flags & PWR_MASK_CLASS)
      m_subClass = attr.TypeRef;
    else
      m_subClass = 0;
    break;
  }
  case pwr_eClass_Intern:
  case pwr_eClass_Input:
  case pwr_eClass_Output:
  {
    pwr_sIntern attr;

    m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &attr);
    if ( EVEN(sts)) throw wb_error(sts);

    strcpy( m_pgmname, attr.Info.PgmName);
    m_size = attr.Info.Size;
    m_type = attr.Info.Type;
    m_offset = m_suboffset = attr.Info.Offset;
    m_elements = attr.Info.Elements;
    m_paramindex = attr.Info.ParamIndex;
    m_flags = attr.Info.Flags;
    m_tid = attr.TypeRef;
    if ( m_flags & PWR_MASK_CLASS)
      m_subClass = attr.TypeRef;
    else
      m_subClass = 0;

    break;
  }
  case pwr_eClass_ObjXRef:
  {
    pwr_sObjXRef attr;

    m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &attr);
    if ( EVEN(sts)) throw wb_error(sts);

    strcpy( m_pgmname, attr.Info.PgmName);
    m_size = attr.Info.Size;
    m_type = attr.Info.Type;
    m_offset = m_suboffset = attr.Info.Offset;
    m_elements = attr.Info.Elements;
    m_paramindex = attr.Info.ParamIndex;
    m_flags = attr.Info.Flags;
    m_tid = m_type;

    break;
  }
  case pwr_eClass_AttrXRef:
  {
    pwr_sAttrXRef attr;

    m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &attr);
    if ( EVEN(sts)) throw wb_error(sts);

    strcpy( m_pgmname, attr.Info.PgmName);
    m_size = attr.Info.Size;
    m_type = attr.Info.Type;
    m_offset = m_suboffset = attr.Info.Offset;
    m_elements = attr.Info.Elements;
    m_paramindex = attr.Info.ParamIndex;
    m_flags = attr.Info.Flags;
    m_tid = m_type;

    break;
  }
  case pwr_eClass_Buffer:
  {
    pwr_sBuffer attr;

    m_orep->vrep()->readBody( &sts, m_orep, pwr_eBix_sys, (void *) &attr);
    if ( EVEN(sts)) throw wb_error(sts);

    strcpy( m_pgmname, attr.Info.PgmName);
    m_size = attr.Info.Size;
    m_type = attr.Info.Type;
    m_offset = m_suboffset = attr.Info.Offset;
    m_elements = attr.Info.Elements;
    m_paramindex = attr.Info.ParamIndex;
    m_flags = attr.Info.Flags;
    m_flags |= PWR_MASK_BUFFER;
    m_subClass = attr.Class;
    m_tid = m_subClass;

    break;
  }
  default:
    throw wb_error(LDH__NYI);
  }
}
コード例 #18
0
ファイル: wb_tdef.cpp プロジェクト: ManfredHerrmann/proview
void wb_tdef::check() const
{
  if ( !m_tdrep) throw wb_error(m_sts);
}
コード例 #19
0
wb_vrep *wb_adrep::vrep() const
{
  if (EVEN(m_sts)) throw wb_error(m_sts);
  return m_orep->vrep();
}
コード例 #20
0
ファイル: wb_attribute.cpp プロジェクト: Strongc/proview
void wb_attribute::check() const
{
  if ( evenSts())
    throw wb_error( m_sts);
}
コード例 #21
0
ファイル: wb_pkg.cpp プロジェクト: Strongc/proview
void pkg_node::checkVolume( char *filename)
{
  lfu_t_volref *volref;
  int volref_cnt;
  pwr_tVid vol_vid;
  pwr_tCid vol_cid;
  pwr_tTime vol_time;
  char vol_name[80];
  bool found;
  pwr_tStatus sts;
  char fname[200];
	  
  sts = lfu_GetVolume( filename, vol_name, &vol_vid, &vol_cid, &vol_time);
  if ( EVEN(sts)) throw wb_error(sts);

  found = false;
  for ( int i = 0; i < (int)m_volumelist.size(); i++) {
    if ( m_volumelist[i].m_vid == vol_vid) {
      found = true;
      if ( m_volumelist[i].m_time.tv_sec != vol_time.tv_sec) {
	char msg[200];
	sprintf( msg, "Version mismatch volume %s in %s", (volref+i)->name, filename);
	MsgWindow::message( 'E', msg, msgw_ePop_No);
	m_errors++;
      }
      break;
    }
  }
  if ( !found) {
    pkg_volume vol( vol_name, filename, vol_vid, vol_time);
    m_volumelist.push_back( vol);
  }

  if ( vol_cid == pwr_eClass_DetachedClassVolume)
    // No check of referenced volumes
    return;

  sts = lfu_GetVolRef( filename, &volref, &volref_cnt);
  if ( EVEN(sts)) throw wb_error(sts);
	  
  for ( int i = 0; i < volref_cnt; i++) {
    wb_erep::volumeNameToFilename( &sts, (volref+i)->name, fname);
    if ( EVEN(sts)) {
      char msg[200];
      sprintf( msg, "Loadfile not found: %s", (volref+i)->name);
      MsgWindow::message( 'E', msg, msgw_ePop_No);
      m_errors++;
      continue;
    }

    checkVolume( fname);

    for ( int j = 0; j < (int)m_volumelist.size(); j++) {
      if ( m_volumelist[j].m_vid == (volref+i)->vid) {
	if ( m_volumelist[j].m_time.tv_sec != (volref+i)->version.tv_sec) {
	  char msg[200];
	  sprintf( msg, "Version mismatch volume %s in %s and %s", (volref+i)->name, filename, m_volumelist[j].m_filename);
	  MsgWindow::message( 'E', msg, msgw_ePop_No);
	  m_errors++;
	}
	break;
      }
    }
  }
  free( (char *)volref);
}
コード例 #22
0
ファイル: wb_session.cpp プロジェクト: siamect/proview
bool wb_session::pasteOset(
    pwr_tOid doid, ldh_eDest dest, bool keepoid, bool recycleix, char* buffer)
{
  if (isReadonly())
    throw wb_error_str("ReadOnlySession");

  m_sts = LDH__SUCCESS;
  wb_destination d = wb_destination(doid, dest);

  wb_vrepmem* mem;
  // Get last buffer
  if (!buffer) {
    mem = (wb_vrepmem*)m_vrep->erep()->bufferVolume(&m_sts);
    if (EVEN(m_sts))
      return false;

    wb_vrepmem* prev = NULL;
    while (mem) {
      prev = mem;
      mem = (wb_vrepmem*)mem->next();
    }
    mem = prev;
  } else {
    // Get specified buffer
    mem = (wb_vrepmem*)m_vrep->erep()->bufferVolume(&m_sts, buffer);
    if (EVEN(m_sts))
      return false;
  }

  if (mem == m_vrep) {
    m_sts = LDH__PASTESELF;
    return false;
  }

  // Check that rootobjects are valid for this destination
  pwr_tStatus sts;
  wb_orep* orep = mem->object(&sts);
  while (ODD(sts)) {
    orep->ref();
    validateDestination(d, orep->cid());
    if (evenSts())
      return false;
    wb_orep* prev = orep;
    orep = orep->after(&sts);
    prev->unref();
  }

  // Trigg ante adopt
  wb_object parent;
  switch (dest) {
  case ldh_eDest_IntoFirst:
  case ldh_eDest_IntoLast:
    parent = object(doid);
    break;
  case ldh_eDest_After:
  case ldh_eDest_Before:
    parent = object(doid).parent();
    break;
  default:
    throw wb_error(LDH__NODEST);
  }

  if (parent) {
    wb_orep* orep = mem->object(&sts);
    while (ODD(sts)) {
      orep->ref();
      m_sts = triggAnteAdopt(parent, orep->cid());
      if (evenSts())
        return false;
      wb_orep* prev = orep;
      orep = orep->after(&sts);
      prev->unref();
    }
  }

  wb_recix* recix = 0;
  if (recycleix)
    recix = m_srep->recix();
  pwr_tOid* olist;
  mem->exportPaste(*m_vrep, doid, dest, keepoid, recix, &olist);
  m_srep->update();
  if (recycleix)
    m_srep->recix_clear();

  if (parent) {
    for (pwr_tOid* oidp = olist; cdh_ObjidIsNotNull(*oidp); oidp++) {
      wb_object o = object(*oidp);
      triggPostAdopt(parent, o);
    }
  }
  free(olist);

  if (dest == ldh_eDest_After || dest == ldh_eDest_Before)
    doid = pwr_cNOid;
  ldh_sEvent* ep = m_srep->eventStart(doid, ldh_eEvent_ObjectTreeCopied);
  m_srep->eventSend(ep);

  return true;
}
コード例 #23
0
void wb_nrep::parse () throw (wb_error)
{
  int state = 0;
  char *s, *snn;

  snn = norm_name;

  if (oname[0] == '_') { 
    // This is an identity name.
    for ( s = oname; *s; s++, snn++) {
      if (idname_tab[*(unsigned char *)s] == '!')
        throw wb_error(LDH__BADNAME);
      else if (idname_tab[*(unsigned char *)s] == '^')
        *snn = *s - 32;
      else
        *snn = idname_tab[*(unsigned char *)s];

      if ( s == oname)
        continue;
      if ( s == oname + 1) {
        switch ( *s) {
        case 'V':
          name_type = wname_eType_Vid;
          continue;
        case 'O':
          name_type = wname_eType_Oid;
          continue;
        case 'A':
          name_type = wname_eType_Aid;
          continue;
        default:
          throw wb_error(LDH__BADNAME);
        }
      }

      /* States
         0: before ':'
         1: before '('
         2: before ')'
         3: attribute before '['
         4: attribute index before ']'
         5: attribute after  ']'
         6: offset.size before '.'
         7: offset.size before ']'
         8: offset.size after  ']'  */

      switch (state) {

      case 0:	// before ':'
        if ( *s == ':') {
          if ( s == oname)
            throw wb_error(LDH__BADNAME);
          vol_offs = 2;
          vol_len = nameDiff( s, oname) - vol_offs;
          seg[0].offs = nameDiff( s + 1, oname);
          state = 1;
        } else if (*s == '(' || *s == ')' || *s == '[' || *s == ']') {
          throw wb_error(LDH__BADNAME);
        }
        break;
      case 1:	// before '('
        if ( *s == '(') {
          if ( nameDiff( s, oname) == seg[0].offs)
            throw wb_error(LDH__BADNAME);
          seg[1].offs = nameDiff( s + 1, oname);
          seg[0].len = nameDiff( s, oname) - seg[0].offs;
          num_seg++;
          state = 2;
        } else if (*s == ')' || *s == '[' || *s == ']') {
          throw wb_error(LDH__BADNAME);
        }
        break;
      case 2:	// before ')'
        if (*s == ')') {
          if ( nameDiff( s, oname) == seg[1].offs)
            throw wb_error(LDH__BADNAME);
          attr[0].offs = nameDiff( s + 1, oname);
          seg[1].len = nameDiff( s, oname) - seg[1].offs;
          num_seg++;
          state = 3;
        } else if (*s == '[' || *s == ']') {
          throw wb_error(LDH__BADNAME);
        }  
        break;
      case 3:	// after ')'
        if (*s == '[') {
          if ( nameDiff( s, oname) == seg[1].offs + seg[1].len + 1) {
            // offset.size
            state = 7;	      
          }
        } else if ( *s == ']' || *s == '.') {
          throw wb_error(LDH__BADNAME);
        } else {
          attr[num_attr].len = nameDiff( s, oname) - attr[num_attr].offs;
          attr[num_attr].index = -1;
          state = 4;
        }
        break;
      case 4:	// attribute before '['
        if (*s == '.') {
          if ( nameDiff( s, oname) == attr[num_attr].offs)
            throw wb_error(LDH__BADNAME);
          attr[num_attr].len = nameDiff( s, oname) - attr[num_attr].offs;
          num_attr++;
          attr[num_attr].offs = nameDiff( s + 1, oname);
          state = 4;
        } else if (*s == '[') {
          attr[num_attr].len = nameDiff( s, oname) - attr[num_attr].offs;
          attr[num_attr].index = 0;
          state = 5;
        }
        break;
      case 5:	// attribute index before ']'
        if (*s == ']') {
          num_attr++;
          state = 6;
        } else if ((*s < '0') || (*s > '9')) {
          throw wb_error(LDH__BADNAME);
        } else {
          attr[num_attr].index = attr[num_attr].index * 10 + (*s - '0');
          if (attr[num_attr].index > 65535) throw wb_error(LDH__BADNAME);
        }
        break;
      case 6:	// attribute after ']', '.' or nothing
        if ( *s == '.') {
          attr[num_attr].offs = nameDiff( s + 1, oname);
          state = 4;
        }
        else
          throw wb_error(LDH__BADNAME);
        break;
      case 7:	// offset.size before '.'
        if (*s == '.') {
          b_size = 0;
          state = 8;
        } else if (*s == ']') {
          throw wb_error(LDH__BADNAME);
        } else {
          if ((*s < '0') || (*s > '9')) {
            throw wb_error(LDH__BADNAME);
          } else {
            b_offset = b_offset * 10 + (*s - '0');
            if (b_offset > 65535) throw wb_error(LDH__BADNAME);
          }
        }
        break;
      case 8:	// offset.size before ']'
        if (*s == ']') {
          state = 9;
        } else if ((*s < '0') || (*s > '9')) {
          throw wb_error(LDH__BADNAME);
        } else {
          b_size = b_size * 10 + (*s - '0');
          if (b_size > 65535) throw wb_error(LDH__BADNAME);
        }
        break;
      case 9:	// offset.size after ']', must be nothing there!
        throw wb_error(LDH__BADNAME);
        break;
      }
    }

    switch ( state) {
    case 0:
      if ( s == oname) 
        throw wb_error(LDH__BADNAME);  // No segment name
      vol_len = nameDiff( s, oname);
      break;
    case 1:
      if ( nameDiff( s, oname) == seg[num_seg].offs)
        throw wb_error(LDH__BADNAME);
      if ( nameDiff( s, oname)  - (vol_len + 1) == 0)
        break;
      seg[num_seg].len = nameDiff( s, oname) - seg[num_seg].offs;
      if ( seg[num_seg].len)
        num_seg++;
      break;
    case 4:
      if ( nameDiff( s, oname) == attr[num_attr].offs)
        throw wb_error(LDH__BADNAME);
      attr[num_attr].len = nameDiff( s, oname) - attr[num_attr].offs;
      if ( attr[num_attr].len)
        num_attr++;
      break;
    case 2:
    case 3:
    case 5:
    case 7:
    case 8:
      throw wb_error(LDH__BADNAME);
    default:
      ;
    }

    *snn = 0;
  }
  else {

    for ( s = oname; *s; s++, snn++) {
      if (normname_tab[*(unsigned char *)s] == '!')
        throw wb_error(LDH__BADNAME);
      else if (normname_tab[*(unsigned char *)s] == '^')
        *snn = *s - 32;
      else
        *snn = normname_tab[*(unsigned char *)s];

      /* States
         0: before ':'
         1: before '.'
         2: before '['
         3: before ']'
         4: after  ']'  */

      switch (state) {
      case 0:	// before ':'
        if ( *s == ':') {
          if ( s == oname) 
            throw wb_error(LDH__BADNAME);  // No volume name
          vol_len = nameDiff( s, oname);
          if ( *(s+1))
            seg[0].offs = nameDiff(s+1, oname);
          state = 1;
        } else if ( *s == '-') {
          if ( s == oname) 
            throw wb_error(LDH__BADNAME);  // No segment name
          seg[0].offs = 0;
          seg[0].len = nameDiff( s, oname);
          num_seg++;
          seg[1].offs = nameDiff( s+1, oname);
          state = 1;
        } else if ( *s == '.') {
          if ( s != oname) {
            seg[0].offs = 0;
            seg[0].len = nameDiff( s, oname);
            num_seg++;
          }
          attr[0].offs = nameDiff( s+1, oname);
          state = 2;
        }
        else if ( *s == '[' || *s == ']')
          throw wb_error(LDH__BADNAME);
        break;
      case 1:	// before '.'
        if ( *s == '-') {
          if ( nameDiff( s, oname) == seg[num_seg].offs)
            throw wb_error(LDH__BADNAME);
          seg[num_seg+1].offs = nameDiff( s+1, oname);
          seg[num_seg].len = seg[num_seg+1].offs - seg[num_seg].offs - 1;
          num_seg++;
        } else if ( *s == '.') {
          // if ( nameDiff( s, oname) == seg[num_seg].offs) // Could be volume object !!
          //   throw wb_error(LDH__BADNAME);
          attr[0].offs = nameDiff( s+1, oname);
          seg[num_seg].len = attr[0].offs - seg[num_seg].offs - 1;
          num_seg++;
          state = 2;
        }
        break;
      case 2:	// before '['
        if ( *s == '.') {
          if ( nameDiff( s, oname) == attr[num_attr].offs)
            throw wb_error(LDH__BADNAME);
          attr[num_attr+1].offs = nameDiff( s+1, oname);
          attr[num_attr].len = attr[num_attr+1].offs - attr[num_attr].offs - 1;
	  if ( attr[num_attr].len == 5 && 
	       cdh_NoCaseStrncmp( oname + attr[num_attr].offs, "Super", 5) == 0) {
	    attr[num_attr].isSuper = true;
	    m_hasSuper = true;
	  }
          num_attr++;
        }
        else if ( *s == '[') {
          if ( nameDiff( s, oname) == attr[num_attr].offs)
            throw wb_error(LDH__BADNAME);
          attr[num_attr].len = nameDiff( s, oname) - attr[num_attr].offs;
          attr[num_attr].index = 0;
          state = 3;
        }
        break;
      case 3:	/* within brackets */
        if (*s == ']') {
          num_attr++;
          state = 4;
        } else if ((*s < '0') || (*s > '9')) {
          throw wb_error(LDH__BADNAME);
        } else {
          attr[num_attr].index = attr[num_attr].index * 10 + (*s - '0');
          if (attr[num_attr].index > 65535) throw wb_error(LDH__BADNAME);
        }
        break;
      case 4:	// after brackets
        if ( *s == '.') {
          attr[num_attr].offs = nameDiff( s+1, oname);
          state = 2;
        }
        else
          throw wb_error(LDH__BADNAME);
        break;
      }
    }

    switch ( state) {
    case 0:
      if ( s == oname) 
        throw wb_error(LDH__BADNAME);  // No segment name
      seg[0].offs = 0;
      seg[0].len = nameDiff( s, oname);
      if ( seg[0].len > pwr_cSizObjName)
	throw wb_error(LDH__BADNAME);
      num_seg++;
      break;
    case 1:
      if ( nameDiff( s, oname) == seg[num_seg].offs)
        throw wb_error(LDH__BADNAME);
      if ( nameDiff( s, oname)  - (vol_len + 1) == 0)
        break;
      seg[num_seg].len = nameDiff( s, oname) - seg[num_seg].offs;
      if ( seg[num_seg].len > pwr_cSizObjName)
	throw wb_error(LDH__BADNAME);
      if ( seg[num_seg].len)
        num_seg++;
      break;
    case 2:
      if ( nameDiff( s, oname) == attr[num_attr].offs)
        throw wb_error(LDH__BADNAME);
      attr[num_attr].len = nameDiff( s, oname) - attr[num_attr].offs;
      if ( attr[num_attr].len)
        num_attr++;
      break;
    case 3:
      throw wb_error(LDH__BADNAME);
    case 4:
      break;
    }
    *snn = 0;
  }
}
コード例 #24
0
ファイル: wb_session.cpp プロジェクト: siamect/proview
wb_object wb_session::copyObject(wb_object o, wb_destination d, wb_name name)
{
  wb_orep* orep = 0;

  if (isReadonly())
    throw wb_error_str("ReadOnlySession");

  validateDestination(d, o.cid());
  if (evenSts())
    throw wb_error(sts());

  wb_object parent;
  switch (d.code()) {
  case ldh_eDest_IntoFirst:
  case ldh_eDest_IntoLast:
    parent = object(d.oid());
    break;
  case ldh_eDest_After:
  case ldh_eDest_Before:
    parent = object(d.oid()).parent();
    break;
  default:
    throw wb_error(LDH__NODEST);
  }

  m_sts = triggAnteCreate(parent, o.cid());
  if (evenSts())
    throw wb_error(sts());
  m_sts = triggAnteAdopt(parent, o.cid());
  if (evenSts())
    throw wb_error(sts());

  if (m_vrep->vid() == o.vid()) {
    orep = m_vrep->copyObject(&m_sts, (wb_orep*)o, d, name);
    if (evenSts())
      throw wb_error(sts());

    orep->ref();
  } else {
    wb_cdef c = cdef(o.cid());

    orep = m_vrep->createObject(&m_sts, c, d, name);
    orep->ref();
    wb_attribute rba(o.sts(), (wb_orep*)o, "RtBody");
    if (rba) {
      void* p = rba.value();
      wb_attribute rban(m_sts, orep, "RtBody");
      writeAttribute(rban, p);
    }
    wb_attribute dba(o.sts(), (wb_orep*)o, "DevBody");
    if (dba) {
      void* p = dba.value();
      wb_attribute dban(m_sts, orep, "DevBody");
      writeAttribute(dban, p);
    }
    wb_attribute sba(o.sts(), (wb_orep*)o, "SysBody");
    if (sba) {
      void* p = sba.value();
      wb_attribute sban(m_sts, orep, "SysBody");
      writeAttribute(sban, p);
    }
  }
  m_srep->update();

  wb_object onew = wb_object(m_sts, orep);
  orep->unref();
  ldh_sEvent* ep = m_srep->eventStart(onew.oid(), ldh_eEvent_ObjectCreated);
  m_srep->eventNewFamily(ep, onew);
  triggPostCreate(onew);
  triggPostAdopt(parent, onew);
  m_srep->eventSend(ep);

  return onew;
}
コード例 #25
0
ファイル: wb_volume.cpp プロジェクト: ManfredHerrmann/proview
void wb_volume::nextAref(pwr_tCid cid, pwr_sAttrRef *arp,
			 pwr_sAttrRef *oarp)
{
  tree_sTable *catt_tt = m_vrep->merep()->catt_tt();
  int bd_size;

  if (!catt_tt) throw wb_error(LDH__CATT);

  wb_orep *op = m_vrep->object(&m_sts, arp->Objid);
  if (evenSts()) return;

  // Get body size
  wb_cdrep *cd = m_vrep->merep()->cdrep(&m_sts, cid);
  if (evenSts()) return;

  wb_bdrep *bd = cd->bdrep(&m_sts, pwr_eBix_rt);
  if (oddSts()) {
    bd_size = bd->size();
    delete bd;
  }
  else
    bd_size = 0;
  delete cd;

  op->ref();
  if (op->cid() == cid) {
    // Find next object in class list
    wb_orep *ol = m_vrep->next(&m_sts, op);
    if (oddSts()) {
      *oarp = pwr_cNAttrRef;
      oarp->Objid = ol->oid();
      oarp->Flags.b.Object = 1;
      oarp->Size = bd_size;
      oarp->Body = cdh_cidToBid( cid, pwr_eBix_rt);
      ol->unref();
      op->unref();
      return;
    } 
    else {
      // Find first attribute object
      merep_sClassAttrKey key;
      merep_sClassAttr *item;
      pwr_tCid hostCid = 0;

      key.subCid = cid;
      key.hostCid = 0;
      key.idx = 0;
      for (item = (merep_sClassAttr*) tree_FindSuccessor(&m_sts, catt_tt, &key);
	    item && item->key.subCid == cid;
	    item = (merep_sClassAttr*) tree_FindSuccessor(&m_sts, catt_tt, &item->key)) {
	if (cd && item->key.hostCid == hostCid)
	  // Same class with other index
	  continue;
	  
	hostCid = item->key.hostCid;

	  
	wb_orep *ol = m_vrep->object(&m_sts, item->key.hostCid);
	if (oddSts()) {
	  ol->ref();
	  *oarp = pwr_cNAttrRef;
	  oarp->Objid = ol->oid();
	  oarp->Flags.b.ObjectAttr = 1;
	  oarp->Size = bd_size;
	  oarp->Offset = item->offset[0];
	  oarp->Body = cdh_cidToBid( cid, pwr_eBix_rt);
	  ol->unref();
	  op->unref();

	  if (item->flags[0] & PWR_MASK_DISABLEATTR) {
	    wb_attribute a = attribute(oarp);
	    if (a.disabled()) {
	      pwr_sAttrRef aref = *oarp;
	      nextAref(cid, &aref, oarp);
	    }
	  }
	  return;
	}
      }
      op->unref();
      m_sts = LDH__NONEXT;
      return;
    }
  }

  // Find next attribute object in current object
  merep_sClassAttrKey key;
  merep_sClassAttr *item;
  int first_offset = 0;

  key.subCid = cid;
  key.hostCid = op->cid();
  key.idx = 0;
  for (item = (merep_sClassAttr*)tree_Find(&m_sts, catt_tt, &key);
	item && item->key.subCid == cid && item->key.hostCid == op->cid();
	item = (merep_sClassAttr*)tree_FindSuccessor(&m_sts, catt_tt, &item->key)) {
    // Find next offset
    for (int i = 0; i < item->numOffset; i++) {
      if (i == 0 && item->key.idx == 0)
	first_offset = item->offset[0];
      if (item->offset[i] > arp->Offset) {
	*oarp = pwr_cNAttrRef;
	oarp->Objid = op->oid();
	oarp->Flags.b.ObjectAttr = 1;
	oarp->Offset = item->offset[i];
	oarp->Size = bd_size;
	oarp->Body = cdh_cidToBid( cid, pwr_eBix_rt);
	op->unref();

	if (item->flags[0] & PWR_MASK_DISABLEATTR) {
	  wb_attribute a = attribute(oarp);
	  if (a.disabled()) {
	    pwr_sAttrRef aref = *oarp;
	    nextAref(cid, &aref, oarp);
	  }
	}
	return;
      }
    }
  }

  // Find first attribute in next object
  wb_orep *ol = m_vrep->next(&m_sts, op);
  if (oddSts()) {
    ol->ref();
    *oarp = pwr_cNAttrRef;
    oarp->Objid = ol->oid();
    oarp->Flags.b.ObjectAttr = 1;
    oarp->Offset = first_offset;
    oarp->Size = bd_size;
    oarp->Body = cdh_cidToBid( cid, pwr_eBix_rt);
    ol->unref();
    op->unref();

    if (item->flags[0] & PWR_MASK_DISABLEATTR) {
      wb_attribute a = attribute(oarp);
      if (a.disabled()) {
	pwr_sAttrRef aref = *oarp;
	nextAref(cid, &aref, oarp);
      }
    }

    return;
  }

  // Find first offset in first object of next class
  key.subCid = cid;
  key.hostCid = op->cid();
  key.idx = 0;
  for (item = (merep_sClassAttr*) tree_Find(&m_sts, catt_tt, &key);
       item && item->key.subCid == cid;
       item = (merep_sClassAttr*) tree_FindSuccessor(&m_sts, catt_tt, &item->key)) {
    
    if (item->key.hostCid == key.hostCid)
      continue;

    wb_orep *ol = m_vrep->object(&m_sts, item->key.hostCid);
    if (oddSts()) {
      ol->ref();
      *oarp = pwr_cNAttrRef;
      oarp->Objid = ol->oid();
      oarp->Flags.b.ObjectAttr = 1;
      oarp->Offset = item->offset[0];
      oarp->Size = bd_size;
      oarp->Body = cdh_cidToBid( cid, pwr_eBix_rt);
      ol->unref();
      op->unref();

      if (item->flags[0] & PWR_MASK_DISABLEATTR) {
	wb_attribute a = attribute(oarp);
	if (a.disabled()) {
	  pwr_sAttrRef aref = *oarp;
	  nextAref(cid, &aref, oarp);
	}
      }
      return;
    }
  }
  m_sts = LDH__NONEXT;
  op->unref();
}