Example #1
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;
}
Example #2
0
static void process( wb_session& session, wb_object& o)
{
  pwr_sPlcNode plcnode;

  if ( o.cid() == pwr_cClass_csub) {
    printf ( "Object: %s\n", o.longName().c_str());

    wb_attribute a = session.attribute( o.oid(), "DevBody", "PlcNode");
    if ( !a) exit(0);

    a.value( &plcnode);

    printf( "subwindow:  %d, woid: %u,%u\n", plcnode.subwindow, 
	    plcnode.subwind_oid[0].vid, plcnode.subwind_oid[0].oix);

    wb_object c = o.first();
    if ( c && c.cid() == pwr_cClass_windowplc) {
      plcnode.subwind_oid[0].vid = c.oid().vid;
      plcnode.subwind_oid[0].oix = c.oid().oix;

      printf( "subwindow:  %d, woid: %u,%u\n", plcnode.subwindow, 
	      plcnode.subwind_oid[0].vid, plcnode.subwind_oid[0].oix);

      session.writeAttribute( a, &plcnode, sizeof(plcnode)); 
      if ( !a) cout << "** Write error" << endl;
    }
  }

  for ( wb_object c = o.first(); c.oddSts(); c = c.after()) {
    process( session, c);
  }
}
Example #3
0
pwr_tStatus wb_volume::triggPostMove(wb_object& o)
{
  pwr_tStatus sts;
  char *methodName;
  wb_tMethod method;
  
  wb_cdrep *cdrep = m_vrep->merep()->cdrep(&sts, o.cid());
  if (EVEN(sts)) return sts;

  cdrep->dbCallBack(&sts, ldh_eDbCallBack_PostMove, &methodName, 0);
  delete cdrep;
  if (EVEN(sts)) return LDH__SUCCESS;

  m_vrep->erep()->method(&sts, methodName, &method);
  if (EVEN(sts)) return LDH__SUCCESS;

  wb_object father = o.parent();
  if (father) {
    sts = ((wb_tMethodPostMove) (method))((ldh_tSesContext)this, o.oid(), father.oid(),
					   father.cid());
  }
  else
    sts = ((wb_tMethodPostMove) (method))((ldh_tSesContext)this, o.oid(), pwr_cNObjid,
					   pwr_cNClassId);
  return sts;
}
Example #4
0
pwr_tStatus wb_volume::triggPostCreate(wb_object& o)
{
  pwr_tStatus sts;
  char *methodName;
  wb_tMethod method;
  
  // Call object method, or inherited method
  for ( wb_cdef cd = cdef(o.cid()); cd; cd = cd.super()) {
    wb_cdrep *cdrep = cd;
    
    cdrep->dbCallBack(&sts, ldh_eDbCallBack_PostCreate, &methodName, 0);

    if (ODD(sts)) {
      m_vrep->erep()->method(&sts, methodName, &method);
      if (EVEN(sts)) return LDH__SUCCESS;

      wb_object father = o.parent();
      if (father) {
	sts = ((wb_tMethodPostCreate) (method))((ldh_tSesContext)this, o.oid(), father.oid(),
						father.cid());
      }
      else
	sts = ((wb_tMethodPostCreate) (method))((ldh_tSesContext)this, o.oid(), pwr_cNObjid,
						pwr_cNClassId);
      return sts;
    }
  }

  return LDH__SUCCESS;
}
Example #5
0
pwr_tStatus wb_volume::triggAnteMove(wb_object& o, wb_object& father, wb_object& old_father)
{
  pwr_tStatus sts;
  char *methodName;
  wb_tMethod method;
  pwr_tOid foid;
  pwr_tOid old_foid;
  
  wb_cdrep *cdrep = m_vrep->merep()->cdrep(&sts, o.cid());
  if (EVEN(sts)) return sts;

  cdrep->dbCallBack(&sts, ldh_eDbCallBack_AnteMove, &methodName, 0);
  delete cdrep;
  if (EVEN(sts)) return LDH__SUCCESS;

  m_vrep->erep()->method(&sts, methodName, &method);
  if (EVEN(sts)) return LDH__SUCCESS;

  if (father)
    foid = father.oid();
  else
    foid = pwr_cNObjid;

  if (old_father)
    old_foid = old_father.oid();
  else
    old_foid = pwr_cNObjid;

  sts = ((wb_tMethodAnteMove) (method))((ldh_tSesContext)this, o.oid(), foid,
					 old_foid);
  return sts;
}
Example #6
0
pwr_tStatus wb_volume::triggAnteAdopt(wb_object& father, pwr_tCid cid)
{
  pwr_tStatus sts;
  char *methodName;
  wb_tMethod method;
  pwr_tOid foid;
  
  if (!father)
    return LDH__SUCCESS;

  wb_cdrep *cdrep = m_vrep->merep()->cdrep(&sts, father.cid());
  if (EVEN(sts)) return sts;

  cdrep->dbCallBack(&sts, ldh_eDbCallBack_AnteAdopt, &methodName, 0);
  delete cdrep;
  if (EVEN(sts)) return LDH__SUCCESS;

  m_vrep->erep()->method(&sts, methodName, &method);
  if (EVEN(sts)) return LDH__SUCCESS;

  if (!father)
    foid = pwr_cNObjid;
  else
    foid = father.oid();

  sts = ((wb_tMethodAnteAdopt) (method))((ldh_tSesContext)this, foid, cid);
  return sts;
}
Example #7
0
pwr_tStatus wb_volume::triggPostUnadopt(wb_object& father, wb_object& o)
{
  pwr_tStatus sts;
  char *methodName;
  wb_tMethod method;
  
  if (!father)
    return LDH__SUCCESS;

  wb_cdrep *cdrep = m_vrep->merep()->cdrep(&sts, father.cid());
  if (EVEN(sts)) return sts;

  cdrep->dbCallBack(&sts, ldh_eDbCallBack_PostUnadopt, &methodName, 0);
  delete cdrep;
  if (EVEN(sts)) return LDH__SUCCESS;

  m_vrep->erep()->method(&sts, methodName, &method);
  if (EVEN(sts)) return LDH__SUCCESS;

  sts = ((wb_tMethodPostUnadopt) (method))((ldh_tSesContext)this, father.oid(), o.oid(),
					    o.cid());
  return sts;
}
Example #8
0
void wb_volume::aref(pwr_tCid cid, wb_object o, pwr_sAttrRef *arp)
{
  tree_sTable *catt_tt = m_vrep->merep()->buildCatt(&m_sts);

  merep_sClassAttrKey key;
  merep_sClassAttr *item;

  key.subCid = cid;
  key.hostCid = o.cid();
  key.idx = 0;
  item = (merep_sClassAttr *) tree_Find(&m_sts, catt_tt, &key);
  if (item == NULL) {
    m_sts = LDH__CLASSLIST;
    return;
  }

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

  int bd_size;
  wb_bdrep *bd = cd->bdrep(&m_sts, pwr_eBix_rt);
  if (oddSts()) {
    bd_size = bd->size();
    delete bd;
  }
  else
    bd_size = 0;
  delete cd;
  
  *arp = pwr_cNAttrRef;
  arp->Objid = o.oid();
  arp->Flags.b.ObjectAttr = 1;
  arp->Offset = item->offset[0];
  arp->Size = bd_size;
  arp->Body = cdh_cidToBid( cid, pwr_eBix_rt);

  if (item->flags[0] & PWR_MASK_DISABLEATTR) {
    wb_attribute a = attribute(arp);
    if (a.disabled()) {
      pwr_sAttrRef aref = *arp;
      nextObjectAref(cid, &aref, arp);
    }
  }
}
Example #9
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;
}