Пример #1
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;
}
Пример #2
0
//
// printBody
//
void wb_print_wbl::printBody(wb_volume& v, 
                             wb_object& o, 
                             wb_object& templ,
                             wb_cdef& cdef,
                             pwr_eBix bix)
{
  wb_adef adef;
  wb_attribute attr;
  wb_attribute tattr;
  const char* bname;
  char timestr[40] = " ";
  int force = 0;
    
  wb_bdef bdef = cdef.bdef(bix);
    

  if (!bdef)
    return;

  bname = bdef.name();

  wb_bdef tbdef = templ.bdef(bix);
  if (!tbdef) {
    m_errCnt++;
    m_os << "Couldn't find template body def for object " << o.name() << endl;
    return;
  }
    
  if ( m_timeFlag) {
    // Get body time
    pwr_tTime btime;
    switch ( bix) {
    case pwr_eBix_rt:
      btime = o.rbTime();

      // Bugcheck in 4.2 btime can be corrupt
      if ( btime.tv_nsec < 0 || btime.tv_nsec >= 1000000000)
	break;

      strcpy( timestr, " ");
      time_AtoAscii( &btime, time_eFormat_DateAndTime, &timestr[1], sizeof(timestr)-1);
      break;
    case pwr_eBix_dev:
      btime = o.dbTime();
      strcpy( timestr, " ");
      time_AtoAscii( &btime, time_eFormat_DateAndTime, &timestr[1], sizeof(timestr)-1);
      break;
    default: ;
    }
  }

  indent(1) << "Body " << bdef.name() << timestr << endl;
  for (adef = bdef.adef(); adef; adef = adef.next()) {
    if ( cdef.cid() == pwr_eClass_Param && strcmp( adef.name(), "Size") == 0) {
      // Print Size for Pointers that is not private
      wb_attribute flags_attr = o.attribute(bname, "Flags");
      pwr_tMask *flagsp = (pwr_tMask *)flags_attr.value();
      if (*flagsp & PWR_MASK_POINTER && !(*flagsp & PWR_MASK_PRIVATE))
	force = 1;
    }

    attr = o.attribute(bname, adef.name());
    tattr = templ.attribute(bname, adef.name());
    //    if (tattr == attr)
    //  continue;
    printAttribute(v, attr, tattr, adef, force);
  }

  indent(-1) << "EndBody" << endl;
    
  return;
}