Exemplo n.º 1
0
bool wb_session::deleteFamily(wb_object o, bool storeix)
{
  if (isReadonly())
    throw wb_error_str("ReadOnlySession");

  if (!isLocal(o)) {
    m_sts = LDH__OTHERVOLUME;
    return false;
  }

  pwr_tStatus sts;
  wb_object parent = o.parent();
  sts = triggAnteUnadopt(parent, o);

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

  sts = triggPostUnadopt(parent, o);

  if (storeix)
    m_srep->recix_add(o);
  bool rsts = m_vrep->deleteFamily(&m_sts, (wb_orep*)o);
  m_srep->update();
  m_srep->eventSend(ep);
  return rsts;
}
Exemplo n.º 2
0
pwr_tOid wb_attribute::boid() const
{
  throw wb_error_str("wb_attribute::boid() NYI");

  pwr_tOid oid;
  return oid;  // Fix
}
Exemplo n.º 3
0
pwr_tOix wb_orepdbs::oix() const
{
  if (m_o == 0)
    throw wb_error_str("No current object");
    
  return m_o->oid.oix;
}
Exemplo n.º 4
0
pwr_tVid wb_orepdbs::vid() const
{
  if (m_o == 0)
    throw wb_error_str("No current object");
    
  return m_o->oid.vid;
}
Exemplo n.º 5
0
const char * wb_orepdbs::name() const
{
  if (m_o == 0)
    throw wb_error_str("No current object");
    
  return m_o->name;
}
Exemplo n.º 6
0
pwr_tOid wb_orepdbs::aoid() const
{
  if (m_o == 0)
    throw wb_error_str("No current object");
    
  return pwr_cNOid;
}
Exemplo n.º 7
0
bool wb_session::cutOset(pwr_sAttrRef* arp, bool keepref)
{
  if (isReadonly())
    throw wb_error_str("ReadOnlySession");

  m_sts = LDH__SUCCESS;

  copyOset(arp, keepref, false, false);
  if (EVEN(m_sts))
    return false;

  // ldh_sEvent *ep = m_srep->eventStart( pwr_cNOid,
  // ldh_eEvent_ObjectTreeDeleted);

  pwr_sAttrRef* ap = arp;
  while (cdh_ObjidIsNotNull(ap->Objid)) {
    wb_object o = object(ap->Objid);
    if (!o) {
      ap++;
      continue;
    }

    ldh_sEvent* ep = m_srep->eventStart(o.oid(), ldh_eEvent_ObjectDeleted);
    m_srep->eventOldFamily(ep, o);
    deleteFamily(o, 0);
    m_srep->eventSend(ep);

    ap++;
  }
  m_srep->update();
  // m_srep->eventSend( ep);

  return true;
}
Exemplo n.º 8
0
pkg_node& wb_pkg::getNode( char *name)
{
  for ( int i = 0; i < (int) m_nodelist.size(); i++) {
    if ( strcmp( m_nodelist[i].name(), cdh_Low(name)) == 0)
      return m_nodelist[i];
  }
  throw wb_error_str("No such node");
}
Exemplo n.º 9
0
bool wb_object::check(std::string str)
{
  if (m_orep == 0) {
    m_sts = LDH__NOSUCHOBJ; // LDH__NOOBJECT;
    throw wb_error_str(m_sts, str);
  }
  return true;
}
Exemplo n.º 10
0
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;
}
Exemplo n.º 11
0
bool wb_session::writeAttribute(wb_attribute& a, void* p, size_t size)
{
  if (isReadonly())
    throw wb_error_str("ReadOnlySession");

  bool sts = m_vrep->writeAttribute(
      &m_sts, (wb_orep*)a, a.bix(), a.offset(), a.size(), p);
  m_srep->update();
  ldh_sEvent* ep = m_srep->eventStart(a.aoid(), ldh_eEvent_AttributeModified);
  m_srep->eventSend(ep);
  return sts;
}
Exemplo n.º 12
0
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;
}
Exemplo n.º 13
0
bool wb_session::renameObject(wb_object o, wb_name name)
{
  m_sts = LDH__SUCCESS;

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

  bool ok = m_vrep->renameObject(&m_sts, (wb_orep*)o, name);
  if (!ok)
    return ok;

  triggPostRename(o);

  m_srep->update();
  ldh_sEvent* ep = m_srep->eventStart(o.oid(), ldh_eEvent_ObjectRenamed);
  m_srep->eventSend(ep);
  return ok;
}
Exemplo n.º 14
0
string wb_attribute::toString() const
{
  throw wb_error_str("wb_attribute::toString() NYI");
  string a;
  return a;
}
Exemplo n.º 15
0
wb_attribute::wb_attribute(const wb_attribute& pa, int pidx, const char *aname, int aidx) :
  wb_status(LDH__NOSUCHATTR), m_orep(0), m_adrep(0), m_size(0), m_offset(0), m_tid(0),
  m_elements(1), m_is_elem(0), m_type(pwr_eType_), m_flags(0), m_bix(pwr_eBix__), m_body(0), 
  m_shadowed(false)
{
  pwr_tCid cid;
  wb_attrname n;
  pwr_tAName attrname;
  
  if ( !cdh_tidIsCid( pa.tid()) || pa.m_orep == 0)
    return;

  if ( pidx == -1)
    pidx = pa.m_idx;

  if ( pa.m_flags & PWR_MASK_ARRAY && !pa.m_is_elem &&
       (pidx < 0 || pidx >= pa.m_elements))
    throw wb_error_str("Invalid subscript");
    
  strcpy( attrname, pa.attrName());
  if ( pa.m_flags & PWR_MASK_ARRAY) {
    if ( attrname[strlen(attrname)-1] == ']') {
      // Replace the index
      char *s = strrchr( attrname, '[');
      if ( s)
	sprintf( s, "[%d]", pidx);
    }
    else
      // Add index
      sprintf( &attrname[strlen(attrname)], "[%d]", pidx);
  }
  strcat( attrname, ".");
  if ( aname != 0)
    strcat( attrname, aname);
  else {
    // First attribute
    if ( pa.isClass())
      cid = pa.subClass();
    else
      cid = pa.tid();
    wb_cdrep *cd = pa.m_orep->vrep()->merep()->cdrep(&m_sts, cid);
    if ( evenSts()) return;
    
    wb_bdrep* bd = cd->bdrep(&m_sts, pwr_eBix_sys);
    if ( evenSts()) { delete cd; return;}

    wb_adrep *adrep = bd->adrep(&m_sts);
    if ( evenSts()) { delete cd; delete bd; return;}

    strcat( attrname, adrep->name());
    delete adrep;
    delete bd;
    delete cd;
  }

  n = attrname;

  cid = pa.cid();

  wb_cdrep *cd = pa.m_orep->vrep()->merep()->cdrep(&m_sts, cid);
  if (evenSts()) return;

  wb_bdrep* bd = cd->bdrep(&m_sts, pwr_eBix_sys);
  if (evenSts()) {
    // Try devbody
    bd = cd->bdrep(&m_sts, pwr_eBix_dev);
    if (evenSts()) { delete cd; return;}
  }

  m_adrep = bd->adrep(&m_sts, n.attributesAllTrue());
  if (evenSts()) {
    // Try devbody
    bd = cd->bdrep(&m_sts, pwr_eBix_dev);
    if (evenSts()) { delete cd; return;}

    m_adrep = bd->adrep(&m_sts, n.attributesAllTrue());
    if (evenSts()) { delete cd; delete bd; return;}
  }
  m_adrep->ref();
  m_size = m_adrep->size();
  m_offset = m_adrep->offset();
  m_tid = m_original_tid = m_adrep->tid();
  m_elements = m_adrep->nElement();
  m_flags = m_adrep->flags();
  m_type = m_adrep->type();  
  m_idx = aidx;

  m_orep = pa.m_orep;
  m_orep->ref();
  m_bix = bd->bix();

  if ( m_flags & PWR_MASK_CASTATTR) {
    pwr_tCastId castid;

    castId( &castid);
    if ( castid != pwr_cNCastId)
      m_tid = castid;
  }

#if 0
  if ( pa.isClass()) {
    m_flags |= PWR_MASK_SUBCLASS;

    if (pa.m_flags & PWR_MASK_SUBCLASS)
      m_bix = pa.m_bix;
    else
      m_bix = pa.m_adrep->bix();
  }
  else
    m_bix = pa.m_bix;
#endif

  delete bd;
  delete cd;
}
Exemplo n.º 16
0
pwr_tAix wb_attribute::aix() const
{
  throw wb_error_str("wb_attribute::aix() NYI");
  return 0; // Fix
}
Exemplo n.º 17
0
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;
}
Exemplo n.º 18
0
bool wb_attribute::checkXref() const
{
  throw wb_error_str("wb_attribute::checkXref() NYI");
  return true; // Fix
}
Exemplo n.º 19
0
void wb_pkg::readConfig()
{
  char fname[200];
  char line[200];
  char line_item[7][80];
  int num;
  int sts;

  dcli_translate_filename( fname, load_cNameDistribute);
  ifstream is( fname);

  while ( is.getline( line, sizeof(line))) {
    dcli_trim( line, line);
    if ( line[0] == '#' || line[0] == '!')
      continue;

    num = dcli_parse( line, " 	", "", (char *)line_item,
		     sizeof(line_item)/sizeof(line_item[0]),
		     sizeof(line_item[0]), 0);
    if ( !num)
      continue;

    if ( strcmp( cdh_Low(line_item[0]), "node") == 0) {
      pwr_mOpSys opsys;
      int bus;
      pwr_tMask dstatus;
      char bootnode[80];
      pwr_tString80 custom_platform;

      if ( num != 7)
	throw wb_error_str("File corrupt " load_cNameDistribute);

      sts = sscanf( line_item[2], "%d", (int *)&opsys);
      if ( sts != 1)
	throw wb_error_str("File corrupt " load_cNameDistribute);

      sts = sscanf( line_item[3], "%d", &bus);
      if ( sts != 1)
	throw wb_error_str("File corrupt " load_cNameDistribute);

      sts = sscanf( line_item[4], "%d", (int *)&dstatus);
      if ( sts != 1)
	throw wb_error_str("File corrupt " load_cNameDistribute);

      strcpy( bootnode, line_item[5]);
      strcpy( custom_platform, line_item[6]);
	
      if ( m_allnodes) {
	pkg_node node( line_item[1], opsys, bus, dstatus, bootnode, custom_platform);
	m_nodelist.push_back( node);
      }
      else {
	bool found = false;
	for ( int i = 0; i < (int) m_nodelist.size(); i++) {
	  if ( strcmp( m_nodelist[i].name(), cdh_Low(line_item[1])) == 0) {
	    found = true;
	    m_nodelist[i].setOpsys( opsys);
	    m_nodelist[i].setBus( bus);
	    m_nodelist[i].setDStatus( dstatus);
	    m_nodelist[i].setBootnode( bootnode);
	    m_nodelist[i].setCustomPlatform( custom_platform);
	    m_nodelist[i].setValid();
	    break;
	  }
	}
      }
    }
    else if ( strcmp( cdh_Low(line_item[0]), "appl") == 0) {
      if ( !(num == 4 || num == 5))
	throw wb_error_str("File corrupt " load_cNameDistribute);

      char severity = line_item[2][0];
      try {
	pkg_node& n = getNode( line_item[1]);
	if ( num == 4) {
	  pkg_pattern p( line_item[3], "", severity);
	  n.push_back( p);
	}
	else {
	  pkg_pattern p( line_item[3], line_item[4], severity);
	  n.push_back( p);
	}
      } catch ( wb_error &e) {
	continue;
      }
    }
    else if ( strcmp( cdh_Low(line_item[0]), "load") == 0) {
      pwr_tVolumeId *vollist;
      pwr_tString40 *volnamelist;
      int       volcount;
      pwr_tString80 *plclist;
      int	plccount;
      char     	systemname[80];
      char     	systemgroup[80];
      pwr_tTime date;

      if ( !(num == 2))
	throw wb_error_str("File corrupt " load_cNameDistribute);

      try {
        pkg_node &n = getNode( line_item[1]);

	// Add ld_node file
	sprintf( fname, load_cNameNode, load_cDirectory, n.name(), n.bus());
	pkg_pattern pnode( fname, "", 'E');
	n.push_back( pnode);

	// Add bootfile
	sprintf( fname, load_cNameBoot, load_cDirectory, n.name(), n.bus());
	pkg_pattern pboot( fname, "", 'E');
	n.push_back( pboot);

	// Read bootfile, get plc and volumes
	sts = lfu_ReadBootFile( fname, &date, systemname, 
				systemgroup, &vollist, &volnamelist, &volcount, &plclist, &plccount);
	if ( EVEN(sts))
	  throw wb_error_str("Bootfile is corrupt");

	// Add plc
	for ( int j = 0; j < plccount; j++) {
	  pwr_tFileName dir;
	
	  if ( n.opsys() == pwr_mOpSys_CustomBuild && 
	       strcmp( n.customPlatform(), "-") != 0)
	    sprintf( dir, "$pwrp_root/bld/%s/exe/", n.customPlatform());
	  else
	    sprintf( dir, "$pwrp_root/bld/%s/exe/", cdh_OpSysToStr( n.opsys()));
	  sprintf( fname, "%s%s", dir, plclist[j]);
	  sprintf( dir, "$pwrp_exe/");
	  pkg_pattern pplc( fname, dir, 'W');
	  n.push_back( pplc);
	}

	// Add volumes
	for ( int j = 0; j < volcount; j++) {
	  char dir[80];

	  if ( (vollist[j] >= cdh_cManufactClassVolMin && 
		vollist[j] <= cdh_cManufactClassVolMax) ||
	       (vollist[j] >= cdh_cSystemClassVolMin && 
		vollist[j] <= cdh_cSystemClassVolMax)) {
	    // Base volume, skip
	    continue;
	  }	       

	  strcpy( dir, "$pwrp_load/");
	  sprintf( fname, "%s%s.dbs", dir, cdh_Low( (char *)(volnamelist + j))); 
	  n.checkVolume( fname);

	  // Check if there are any rtt-files for Root or Sub Volumes
	  if ( vollist[j] >= cdh_cUserVolMin &&
	       vollist[j] <= cdh_cUserVolMax) {
	    cdh_uVolumeId	vid;
	    vid.pwr = vollist[j];

	    // RttCrr-file
	    strcpy( dir, "$pwrp_load/");
	    sprintf( fname, "%s" load_cNameRttCrr,
		dir, vid.v.vid_3, vid.v.vid_2, vid.v.vid_1, vid.v.vid_0);
	    pkg_pattern rttcrr( fname);
	    n.push_back( rttcrr);

	    // RttCrrObj-file
	    strcpy( dir, "$pwrp_load/");
	    sprintf( fname, "%s" load_cNameRttCrrObj,
		dir, vid.v.vid_3, vid.v.vid_2, vid.v.vid_1, vid.v.vid_0);
	    pkg_pattern rttcrrobj( fname);
	    n.push_back( rttcrrobj);

	    // RttCrrCode-file
	    strcpy( dir, "$pwrp_load/");
	    sprintf( fname, "%s" load_cNameRttCrrCode,
		dir, vid.v.vid_3, vid.v.vid_2, vid.v.vid_1, vid.v.vid_0);
	    pkg_pattern rttcrrcode( fname);
	    n.push_back( rttcrrcode);

	    // RttSignals

	    strcpy( dir, "$pwrp_load/");
	    sprintf( fname, "%s" load_cNameRttSignals,
		dir, vid.v.vid_3, vid.v.vid_2, vid.v.vid_1, vid.v.vid_0);
	    pkg_pattern rttsignals( fname);
	    n.push_back( rttsignals);

	  }
	}

	free( volnamelist);
	free( vollist);

      } catch ( wb_error &e) {
	if  ( e.what() == string("No such node"))
	  continue;
	throw wb_error_str(e.what());
      }
    }
    else if ( strcmp( cdh_Low(line_item[0]), "boot") == 0) {
      // A Sev node, only node and bootfile
      try {
	if ( !(num == 2))
	  throw wb_error_str("File corrupt " load_cNameDistribute);

	pkg_node &n = getNode( line_item[1]);
	// Add ld_node file
	sprintf( fname, load_cNameNode, load_cDirectory, n.name(), n.bus());
	pkg_pattern pnode( fname, "", 'E');
	n.push_back( pnode);
	
	// Add bootfile
	sprintf( fname, load_cNameBoot, load_cDirectory, n.name(), n.bus());
	pkg_pattern pboot( fname, "", 'E');
	n.push_back( pboot);
      } catch ( wb_error &e) {
	if  ( e.what() == string("No such node"))
	  continue;
	throw wb_error_str(e.what());
      }
    }
  }

  is.close();

  // Check that all nodes are valid
  for ( int i = 0; i < (int) m_nodelist.size(); i++) {
    if ( !m_nodelist[i].valid())
      throw wb_error_str( "Unknown node name");
  }
}
Exemplo n.º 20
0
void pkg_node::fetchFiles( bool distribute) 
{
  char	dev[80];
  char	dir[80];
  char	file[80];
  char	type[80];
  int 	version;
  char  pack_fname[200];
  char  fname[200];

  // Get temporary directory
  sprintf( m_tmpdir, "/tmp/pwrpkg%06u", pkg_random());
  sprintf( m_blddir, "%s/pkg_build", m_tmpdir);

  // Add volumes to pattern
  for ( int i = 0; i < (int)m_volumelist.size(); i++) {
    if ( !m_volumelist[i].m_isSystem) {
      pkg_pattern vol( m_volumelist[i].m_filename, "$pwrp_load/", 'E');
      push_back( vol);
    }
  }

  for ( int i = 0; i < (int)m_pattern.size(); i++) 
    m_pattern[i].fetchFiles();

  // Put all files in a single list
  for ( int i = 0; i < (int)m_pattern.size(); i++) {
    for ( int j = 0; j < (int)m_pattern[i].m_filelist.size(); j++) {
      try {
	pkg_file f = m_pattern[i].m_filelist[j];

	dcli_parse_filename( f.m_source, dev, dir, file, type, &version);
	strcpy( f.m_arname, file);
	strcat( f.m_arname, type);

	// Check that this name is unic
	for (;;) {
	  bool new_name = false;
	  for ( int k = 0; k < (int)m_filelist.size(); k++) {
	    if ( strcmp( m_filelist[k].m_arname, f.m_arname) == 0) {
	      strcat( f.m_arname, "x");
	      new_name = true;
	      break;
	    }
	  }
	  if ( !new_name)
	    break;
	}

	m_filelist.push_back( f);
      } catch ( wb_error &e) {
	MsgWindow::message( 'W', e.what().c_str(), msgw_ePop_No);
	m_warnings++;
      }
    }
  }

  if ( m_errors) {
    char msg[200];
    sprintf( msg, "Distribute errors node %s: %d errors, %d warnings", m_name, m_errors, m_warnings);
    MsgWindow::message( 'E', msg, msgw_ePop_Yes);
    throw wb_error_str( msg);
  }
  else if ( m_warnings) {
    char msg[200];
    sprintf( msg, "Distribute warnings node %s: %d warnings", m_name, m_warnings);
    MsgWindow::message( 'W', msg, msgw_ePop_Yes);
  }

  // Read and increment package version
  sprintf( fname, "$pwrp_load/pkg_v_%s.dat", m_name);
  dcli_translate_filename( fname, fname);
  ifstream ifv( fname);
  if ( ifv) {
    ifv >> version;
    ifv.close();
    version++;
  }
  else
Exemplo n.º 21
0
pwr_sObjXRef *wb_attribute::oxref() const
{
  throw wb_error_str("wb_attribute::oxref() NYI");
  return (pwr_sObjXRef*)0; // Fix
}
Exemplo n.º 22
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(1), m_is_elem(0), m_type(pwr_eType_), m_flags(0), m_bix(pwr_eBix__), m_body(0), 
  m_shadowed(false)
{
  if ( orep == 0)
    m_sts = LDH__NOSUCHATTR;
  else {
    m_orep->ref();

    if ( m_adrep) {
      m_adrep->ref();
      m_size = m_adrep->size();
      m_offset = m_adrep->offset();
      m_tid = m_original_tid = m_adrep->tid();
      m_elements = m_adrep->nElement();
      m_type = m_adrep->type();
      m_flags = m_adrep->flags();
      m_bix = m_adrep->bix();

      if (m_flags & PWR_MASK_ARRAY) {
        if (idx >= m_elements)
          throw wb_error_str("wb_attribute() subscript out of range");
        m_idx = idx;
        if (idx != -1) { // element
          m_size = m_adrep->size() / m_adrep->nElement();
	  if ( m_flags & PWR_MASK_POINTER)
	    m_offset = m_adrep->offset() + m_idx * sizeof(pwr_tUInt64);
	  else
	    m_offset = m_adrep->offset() + m_idx * m_size;
          m_elements = 1;
	  m_is_elem = 1;
        }
      } else
        m_idx = 0;

      if ( m_flags & PWR_MASK_CASTATTR) {
	pwr_tCastId castid;

	castId( &castid);
	if ( castid != pwr_cNCastId)
	  m_tid = castid;
      }
    }
    else {
      // m_size == get rtbody size... Fix
      wb_cdef cdef(*orep);
      if (EVEN(cdef.sts())) {
        char msg[256];
        m_sts = cdef.sts();
        sprintf(msg, "Can't get cdef for orep: %s", orep->name());  
        throw wb_error_str(m_sts, msg);
      }
      wb_bdef bdef(((wb_cdrep *)cdef)->bdrep(&m_sts, pwr_eBix_rt));
      if (EVEN(bdef.sts())) {
        char msg[256];
        m_sts = bdef.sts();
        sprintf(msg, "Can't get bdef for orep: %s", orep->name());  
        throw wb_error_str(m_sts, msg);
      }

      m_size = bdef.size();
      m_bix = bdef.bix();
    }
  }
}
Exemplo n.º 23
0
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;
}
Exemplo n.º 24
0
pwr_tStatus wb_attribute::fromString(char *) const
{
  throw wb_error_str("wb_attribute::fromString() NYI");    
  pwr_tStatus sts;
  return sts;
}
Exemplo n.º 25
0
pwr_tStatus
wb_dbs::prepareSectVolref()
{
  char v[dbs_dAlign(sizeof(dbs_sVolRef))];
  dbs_sVolRef *vp = (dbs_sVolRef*)v;
  cdh_uTid    cid;
  sCentry     *cep;
  pwr_tStatus sts;
  pwr_tUInt32 dvVersion;
  
    
  if (fseek(m_fp, m_sect[dbs_eSect_volref].offset, SEEK_SET) != 0)
    return LDH__FILEPOS;

  memset(v, 0, sizeof(v));

  cid.pwr = pwr_cNCid;
  cep = (sCentry*)tree_FindSuccessor(&sts, m_class_th, &cid.pwr);
  while (cep) {
    cdh_uVid vid;

    vid.pwr = pwr_cNVid;
    cid.pwr = cep->c.cid;
    vid.v.vid_0 = cid.c.vid_0;
    vid.v.vid_1 = cid.c.vid_1;
        
    if (vid.pwr != m_volume.vid) {
      wb_mvrep *mvrep = m_v->merep()->volume(&sts, vid.pwr);
      if ( EVEN(sts)) throw wb_error_str("Metavolume not found");

      dvVersion = getDvVersion( mvrep);

      sVentry *vep;

      vep = (sVentry*)tree_Insert(&sts, m_vol_th, &vid.pwr);
      if (sts == TREE__INSERTED) {
        /* was inserted now */
        dbs_Open(&sts, &vep->env, mvrep->fileName());

        strcpy(vep->v.name, mvrep->name());
        vep->v.cid  = mvrep->cid();
	if ( m_volume.cid == pwr_eClass_DetachedClassVolume) {
	  vep->v.time.tv_sec = dvVersion;
	  vep->v.time.tv_nsec = 0;
	}
	else
	  vep->v.time = vep->env.file.time;
        vep->v.size = vep->env.file.size;
        vep->v.offset = 0;

        int i = 0;
        while ((vp = dbs_VolRef(&sts, i, (dbs_sVolRef *)v, &vep->env)) != NULL) {
          sVentry *nvep;
          i++;
          nvep = (sVentry*)tree_Insert(&sts, m_vol_th, &vp->vid);
          if (sts == TREE__INSERTED) {
	    wb_mvrep *nmvrep = m_v->merep()->volume(&sts, vp->vid);
	    if ( EVEN(sts)) {
	      printf( "** Classvolume %s referenced but not loaded\n", vp->name);
	      throw wb_error_str("Metavolume not loaded");
	    }      
      
	    dvVersion = getDvVersion( mvrep);
      
	    dbs_Open(&sts, &nvep->env, nmvrep->fileName());

            strcpy(nvep->v.name, vp->name);
            nvep->v.cid  = vp->cid;
	    if ( m_volume.cid == pwr_eClass_DetachedClassVolume) {
	      nvep->v.time.tv_sec = dvVersion;
	      nvep->v.time.tv_nsec = 0;
	    }
	    else
	      nvep->v.time = vp->time;
	    // nvep->v.dvVersion = vp->dvVersion;
            nvep->v.size = vp->size;
            nvep->v.offset = 0;
          }          
        }
      }
    }
    vid.pwr++;
    cid.pwr = pwr_cNCid;
    cid.c.vid_0 = vid.v.vid_0;
    cid.c.vid_1 = vid.v.vid_1;
    cep = (sCentry*)tree_FindSuccessor(&sts, m_class_th, &cid.pwr);        
  }

  // Search trhough all found volumes and get their volrefs
  int nVolume = 0;
  sVentry *vep;
  vep = (sVentry*)tree_Minimum(&sts, m_vol_th);
  while (vep) {
    if (vep->env.file.cookie == 0) {
      printf("  volume not found: %d\n", vep->v.vid);
    } else {
      nVolume++;
      m_sect[dbs_eSect_volref].size += sizeof(v);
    }
    
    vep = (sVentry*)tree_Successor(&sts, m_vol_th, vep);        
  }

  return LDH__SUCCESS;
}