Esempio n. 1
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;
}
Esempio n. 2
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;
}
Esempio n. 3
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;
}
Esempio n. 4
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;
}
Esempio n. 5
0
bool wb_volume::isAncestor(wb_object& ancestor, wb_object& o)
{
  if (ancestor.oid().vid != o.oid().vid)
    return false;

  wb_object p = o.parent();
  while (p) {
    if (p.oid().oix == ancestor.oid().oix)
      return true;
    p = p.parent();
  }
  return false;
}
Esempio n. 6
0
bool wb_recix::add_object_ctree( wb_object &o) {

  add( o.longName().c_str(), o.oid().oix);
  for ( wb_object ch = o.first(); ch; ch = ch.after())
    add_object_tree( ch);
  return true;
}
Esempio n. 7
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);
  }
}
Esempio n. 8
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;
}
Esempio n. 9
0
pwr_tStatus wb_volume::triggAnteCreate(wb_object& father, pwr_tCid cid)
{
  pwr_tStatus sts;
  char *methodName;
  wb_tMethod method;
  pwr_tOid foid;
  

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

  cdrep->dbCallBack(&sts, ldh_eDbCallBack_AnteCreate, &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_tMethodAnteCreate) (method))((ldh_tSesContext)this, foid, cid);
  return sts;
}
Esempio n. 10
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;
}
Esempio n. 11
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;
}
Esempio n. 12
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);
    }
  }
}
Esempio n. 13
0
bool wb_recix::add_object_tree( wb_object &o) {

  clear();

  wb_object p = o.parent();
  if ( p)
    strcpy( m_srcroot, p.longName().c_str());

  add( o.longName().c_str(), o.oid().oix);
  for ( wb_object ch = o.first(); ch; ch = ch.after())
    add_object_ctree( ch);


  // for (  ix_iterator it = m_ix.begin(); it != m_ix.end(); it++) {
  //   cout << " Object: " << it->second << "  " << it->first << endl;
  // }  

  return true;
}
Esempio n. 14
0
//
// printObject
//
void wb_print_wbl::printObject(wb_volume& v, wb_object& o, bool recursive)
{
  wb_object to = o;
  wb_object templ;
  cdh_uObjid	uid;
  unsigned int idx;
  wb_cdef cdef = v.cdef(o);
  if ( !cdef) {
    m_os << "! %WBDUMP-E-Error Failed to get object class" << endl;
    m_errCnt++;
    // return;
    cdef = v.cdef( pwr_eClass_ClassLost);
  }
  const char* cname = cdef.name();
  char *block;
  int size;

  if ( o.docBlock( &block, &size) && strcmp( block, "") != 0) {
    indent(0) << "!/**" << endl;
    indent(0) << "! ";
    for ( char *s = block; *s; s++) {
      if ( *s == '\n') {
	m_os << *s;
	indent(0) << "! ";
	continue;
      }
      m_os << *s;
    }
    m_os << endl;
    indent(0) << "!*/" << endl;
  }

  indent(1) << "Object " << o.name() << " " << cname;

  if (m_idxFlag) {
    switch (cdef.cid()) {
    case pwr_eClass_ClassDef:
      uid.pwr = o.oid();
      idx = uid.c.cix;
      break;
    case pwr_eClass_TypeDef:
      uid.pwr = o.oid();
      idx = uid.t.tix;
      break;
    case pwr_eClass_ObjBodyDef:
      uid.pwr = o.oid();
      idx = uid.c.bix;
      break;
    case pwr_eClass_Param:
    case pwr_eClass_Input:
    case pwr_eClass_Output:
    case pwr_eClass_Intern:
    case pwr_eClass_Buffer:
    case pwr_eClass_ObjXRef:
      uid.pwr = o.oid();
      idx = uid.c.aix;
      break;
    default:
      idx = (unsigned long) o.oix();
    }
    m_os << " " << idx;
  }
  if ( m_timeFlag) {
    // Get oh time
    char timestr[40];
    pwr_tTime ohtime = o.ohTime();
    time_AtoAscii( &ohtime, time_eFormat_DateAndTime, timestr, sizeof(timestr));

    m_os << " " << timestr;
  }
  m_os << endl;

  wb_object co = v.object(cdh_ClassIdToObjid(cdef.cid()));
  wb_name t("Template");
  
  templ = co.child(t);
  if (!templ) {
    m_errCnt++;
    m_os << "Template not found for class " << cdef.name() << endl;
    return;
  }

  if ( v.cid() == pwr_eClass_ClassVolume &&
       strcmp( o.name(), "Template") == 0)
    m_isTemplateObject = true;
  else
    m_isTemplateObject = false;
  
 
  printBody(v, o, templ, cdef, pwr_eBix_rt);
  printBody(v, o, templ, cdef, pwr_eBix_dev);

  if (recursive) {
    if ( !(m_noFoCodeFlag && isFoCodeObject( v, o))) {
      for (to = o.first(); to; to = to.after())
	printObject(v, to);
    }
  }    

  indent(-1) << "EndObject" << endl;
}
Esempio n. 15
0
wb_destination::wb_destination(wb_object &o, ldh_eDest code) :
  m_oid(o.oid()), m_code(code)
{    
}