void Window::
get_size( const std::string &aname, int pid,
	  int *nitem, int *ng) const throw( COM_exception) {
  const Pane_friend *pn;
  try { pn = &(Pane_friend&)pane(pid); }
  catch ( COM_exception ex) {
    ex.msg = append_frame( ex.msg, Window::get_size);
    throw ex;
  }
    
  // Special handing for connectivity
  if ( Connectivity::is_element_name( aname)) {
    // Get the corresponding attribute object.
    const COM::Connectivity *conn = pn->connectivity( aname);
    if ( conn==NULL) 
      throw COM_exception( COM_ERR_ATTRIBUTE_NOTEXIST, append_frame
			   ( name()+"."+aname, Window::get_size));
    get_size_common( conn, pid, nitem, ng);
  }
  else {
    // Get the corresponding attribute object.
    const COM::Attribute *attr = pn->attribute( aname);
    if ( attr==NULL) 
      throw COM_exception( COM_ERR_ATTRIBUTE_NOTEXIST, append_frame
			   ( name()+"."+aname, Window::get_size));

    get_size_common( attr, pid, nitem, ng);
  }
}
Exemple #2
0
void ComponentInterface::
get_size( const std::string &aname, int pid,
	  int *nitem, int *ng) const throw( COM_exception) {
  const Pane_friend *pn;
  try { pn = &(Pane_friend&)pane(pid); }
  catch ( COM_exception ex) {
    ex.msg = append_frame( ex.msg, ComponentInterface::get_size);
    throw ex;
  }
    
  // Special handing for connectivity
  if ( Connectivity::is_element_name( aname)) {
    // Get the corresponding dataitem object.
    const COM::Connectivity *conn = pn->connectivity( aname);
    if ( conn==NULL) 
      throw COM_exception( COM_ERR_DATAITEM_NOTEXIST, append_frame
			   ( name()+"."+aname, ComponentInterface::get_size));
    get_size_common( conn, pid, nitem, ng);
  }
  else {
    // Get the corresponding dataitem object.
    const COM::DataItem *attr = pn->dataitem( aname);
    if ( attr==NULL) 
      throw COM_exception( COM_ERR_DATAITEM_NOTEXIST, append_frame
			   ( name()+"."+aname, ComponentInterface::get_size));

    get_size_common( attr, pid, nitem, ng);
  }
}
Exemple #3
0
void ComponentInterface::copy_array(const std::string &aname, const int pane_id,
			void *val, int v_strd, int v_size, 
			int offset) const throw(COM_exception)
{
  const Pane_friend *pn;
  try { pn = &(Pane_friend&)pane(pane_id); }
  catch ( COM_exception ex) {
    ex.msg = append_frame( ex.msg, ComponentInterface::copy_array);
    throw ex;
  }

  if ( Connectivity::is_element_name( aname)) {
    const Connectivity *conn = pn->connectivity( aname);
    if ( conn == NULL) 
      throw COM_exception( COM_ERR_DATAITEM_NOTEXIST, append_frame
			   (name()+"."+aname, ComponentInterface::copy_array));

    copy_array_common( conn, pane_id, 
		       val, v_strd, v_size, offset);
  }
  else {
    const DataItem *attr = pn->dataitem( aname);
    if ( attr == NULL) 
      throw COM_exception( COM_ERR_DATAITEM_NOTEXIST, append_frame
			   (name()+"."+aname, ComponentInterface::copy_array));

    copy_array_common( attr, pane_id, 
		       val, v_strd, v_size, offset);
  }
}
void Window::append_array( const std::string &aname, const int pane_id,
			   const void *val, int v_strd, int v_size) throw(COM_exception)
{
  COM_assertion_msg( !Connectivity::is_element_name( aname),
		     "append_array supports only window and pane attributes");
  
  Attribute *a = pane( pane_id,true).attribute( aname);

  if ( a==NULL) 
    throw COM_exception( COM_ERR_ATTRIBUTE_NOTEXIST, append_frame
			 (name()+"."+aname,Window::append_array));
  try {
    // Set size to 0 if not yet set.
    if ( !a->size_set()) a->set_size(0); 
    // resize the target attribute.
    reinit_attr( a, Pane::OP_RESIZE, NULL, a->stride(), 
		 a->size_of_items()+v_size);
  }
  catch ( COM_exception ex) {
    ex.msg = append_frame( ex.msg, Window::append_array);
    throw ex;
  }
  
  // copy the array to the back of the target array
  a->append_array( val, v_strd, v_size);
}
void Window::
get_parent( const std::string &aname, int pid, 
	    std::string &parent) const throw( COM_exception) {

  const Pane_friend *pn;
  try { 
    pn = &(Pane_friend&)pane(pid); 
    
    // Special handing for connectivity
    if ( Connectivity::is_element_name( aname)) {
      // Get the corresponding attribute object.
      const COM::Connectivity *conn = pn->connectivity( aname);
      if ( conn==NULL) 
	throw COM_exception( COM_ERR_ATTRIBUTE_NOTEXIST, append_frame
			     (name()+"."+aname,Window::get_parent));

      conn = conn->parent();
      if ( conn==NULL) parent.clear();
      else parent = conn->fullname();
    }
    else {
      // Get the corresponding attribute object.
      const COM::Attribute *attr = pn->attribute( aname);
      if ( attr==NULL) 
	throw COM_exception( COM_ERR_ATTRIBUTE_NOTEXIST, append_frame
			     (name()+"."+aname,Window::get_parent));

      if ( attr==NULL) parent.clear();
      else parent = attr->fullname();
    }
  } catch ( COM_exception ex) {
    ex.msg = append_frame( ex.msg, Window::get_parent);
    throw ex;
  }
}
void Window::copy_array(const std::string &aname, const int pane_id,
			void *val, int v_strd, int v_size, 
			int offset) const throw(COM_exception)
{
  const Pane_friend *pn;
  try { pn = &(Pane_friend&)pane(pane_id); }
  catch ( COM_exception ex) {
    ex.msg = append_frame( ex.msg, Window::copy_array);
    throw ex;
  }

  if ( Connectivity::is_element_name( aname)) {
    const Connectivity *conn = pn->connectivity( aname);
    if ( conn == NULL) 
      throw COM_exception( COM_ERR_ATTRIBUTE_NOTEXIST, append_frame
			   (name()+"."+aname, Window::copy_array));

    copy_array_common( conn, pane_id, 
		       val, v_strd, v_size, offset);
  }
  else {
    const Attribute *attr = pn->attribute( aname);
    if ( attr == NULL) 
      throw COM_exception( COM_ERR_ATTRIBUTE_NOTEXIST, append_frame
			   (name()+"."+aname, Window::copy_array));

    copy_array_common( attr, pane_id, 
		       val, v_strd, v_size, offset);
  }
}
Exemple #7
0
DataItem* ComponentInterface::
dataitem( const std::string &aname) throw(COM_exception) 
{
  if ( !DataItem::is_digit(aname[0])) {
    Attr_map::iterator it = _attr_map.find( aname);
    if ( it == _attr_map.end())
      return NULL;
    else 
      return it->second;
  }
  else {
    std::string::size_type start = aname.find( '-'); 
    if ( start == aname.npos) 
      throw COM_exception( COM_ERR_INVALID_DATAITEM_NAME, append_frame
			   (_name+"."+aname,ComponentInterface::dataitem));
			   
    Attr_map::iterator it = _attr_map.find( &aname[start+1]);

    if ( it != _attr_map.end()) {
      DataItem *att = it->second;
      if ( att->size_of_components()>1) { 
	// Get the subcomponent
	int i = std::atoi( aname.c_str()); 

	if ( i<=0 || i>att->size_of_components()) 
	  throw COM_exception( COM_ERR_INVALID_DATAITEM_NAME, append_frame
			       (_name+"."+aname,ComponentInterface::dataitem));
	return dataitem( att->id()+i);
      }
    }
    
    return NULL;
  }
}
Exemple #8
0
void ComponentInterface::append_array( const std::string &aname, const int pane_id,
			   const void *val, int v_strd, int v_size) throw(COM_exception)
{
  COM_assertion_msg( !Connectivity::is_element_name( aname),
		     "append_array supports only CI window and pane dataitems");
  
  DataItem *a = pane( pane_id,true).dataitem( aname);

  if ( a==NULL) 
    throw COM_exception( COM_ERR_DATAITEM_NOTEXIST, append_frame
			 (name()+"."+aname,ComponentInterface::append_array));
  try {
    // Set size to 0 if not yet set.
    if ( !a->size_set()) a->set_size(0); 
    // resize the target dataitem.
    reinit_dataitem( a, Pane::OP_RESIZE, NULL, a->stride(), 
		 a->size_of_items()+v_size);
  }
  catch ( COM_exception ex) {
    ex.msg = append_frame( ex.msg, ComponentInterface::append_array);
    throw ex;
  }
  
  // copy the array to the back of the target array
  a->append_array( val, v_strd, v_size);
}
void Window::set_array(const std::string &aname, const int pane_id,
		       void *addr, int strd, int cap, bool is_const) 
  throw(COM_exception)
{
  if ( Connectivity::is_element_name( aname)) {
    Pane &pn = pane(pane_id,true);
    Connectivity *con = ((Pane_friend&)pn).connectivity( aname,true);
    
    if ( con==NULL) 
      throw COM_exception( COM_ERR_ATTRIBUTE_NOTEXIST, append_frame
			   (name()+"."+aname,Window::set_array));

    reinit_conn( con, is_const?Pane::OP_SET_CONST:Pane::OP_SET, 
		 &(int*&)addr, strd, cap);
  }
  else {
    Attribute *a = pane( pane_id,true).attribute( aname);
    if ( a==NULL) 
      throw COM_exception( COM_ERR_ATTRIBUTE_NOTEXIST, append_frame
			   (name()+"."+aname,Window::set_array));

    reinit_attr( a, is_const?Pane::OP_SET_CONST:Pane::OP_SET, 
		 &addr, strd, cap);
  }
}
Exemple #10
0
void ComponentInterface::
get_parent( const std::string &aname, int pid, 
	    std::string &parent) const throw( COM_exception) {

  const Pane_friend *pn;
  try { 
    pn = &(Pane_friend&)pane(pid); 
    
    // Special handing for connectivity
    if ( Connectivity::is_element_name( aname)) {
      // Get the corresponding dataitem object.
      const COM::Connectivity *conn = pn->connectivity( aname);
      if ( conn==NULL) 
	throw COM_exception( COM_ERR_DATAITEM_NOTEXIST, append_frame
			     (name()+"."+aname,ComponentInterface::get_parent));

      conn = conn->parent();
      if ( conn==NULL) parent.clear();
      else parent = conn->fullname();
    }
    else {
      // Get the corresponding dataitem object.
      const COM::DataItem *attr = pn->dataitem( aname);
      if ( attr==NULL) 
	throw COM_exception( COM_ERR_DATAITEM_NOTEXIST, append_frame
			     (name()+"."+aname,ComponentInterface::get_parent));

      if ( attr==NULL) parent.clear();
      else parent = attr->fullname();
    }
  } catch ( COM_exception ex) {
    ex.msg = append_frame( ex.msg, ComponentInterface::get_parent);
    throw ex;
  }
}
Exemple #11
0
void ComponentInterface::set_array(const std::string &aname, const int pane_id,
		       void *addr, int strd, int cap, bool is_const) 
  throw(COM_exception)
{
  if ( Connectivity::is_element_name( aname)) {
    Pane &pn = pane(pane_id,true);
    Connectivity *con = ((Pane_friend&)pn).connectivity( aname,true);
    
    if ( con==NULL) 
      throw COM_exception( COM_ERR_DATAITEM_NOTEXIST, append_frame
			   (name()+"."+aname,ComponentInterface::set_array));

    reinit_conn( con, is_const?Pane::OP_SET_CONST:Pane::OP_SET, 
		 &(int*&)addr, strd, cap);
  }
  else {
    DataItem *a = pane( pane_id,true).dataitem( aname);
    if ( a==NULL) 
      throw COM_exception( COM_ERR_DATAITEM_NOTEXIST, append_frame
			   (name()+"."+aname,ComponentInterface::set_array));

    reinit_dataitem( a, is_const?Pane::OP_SET_CONST:Pane::OP_SET, 
                     &addr, strd, cap);
  }
}
Attribute* Window::
attribute( const std::string &aname) throw(COM_exception) 
{
  if ( !Attribute::is_digit(aname[0])) {
    Attr_map::iterator it = _attr_map.find( aname);
    if ( it == _attr_map.end())
      return NULL;
    else 
      return it->second;
  }
  else {
    std::string::size_type start = aname.find( '-'); 
    if ( start == aname.npos) 
      throw COM_exception( COM_ERR_INVALID_ATTRIBUTE_NAME, append_frame
			   (_name+"."+aname,Window::attribute));
			   
    Attr_map::iterator it = _attr_map.find( &aname[start+1]);

    if ( it != _attr_map.end()) {
      Attribute *att = it->second;
      if ( att->size_of_components()>1) { 
	// Get the subcomponent
	int i = std::atoi( aname.c_str()); 

	if ( i<=0 || i>att->size_of_components()) 
	  throw COM_exception( COM_ERR_INVALID_ATTRIBUTE_NAME, append_frame
			       (_name+"."+aname,Window::attribute));
	return attribute( att->id()+i);
      }
    }
    
    return NULL;
  }
}
Exemple #13
0
void ComponentInterface::get_array(const std::string &aname, const int pane_id,
		       Pointer_descriptor &addr,
		       int *strd, int *cap, bool is_const) throw(COM_exception)
{
  Pane_friend *pn;
  try { pn = &(Pane_friend&)pane(pane_id); }
  catch ( COM_exception ex) {
    ex.msg = append_frame( ex.msg, ComponentInterface::get_array);
    throw ex;
  }
    
  if ( Connectivity::is_element_name( aname)) {
    // Define as const reference to avoid exception.
    const Connectivity *con=pn->connectivity( aname);

    if ( con==NULL) 
      throw COM_exception( COM_ERR_DATAITEM_NOTEXIST,append_frame
			   (name()+"."+aname,ComponentInterface::get_array));

    get_array_common( con, pane_id, addr, strd, cap, is_const);
  }
  else {
    // Define as const reference to avoid exception.
    const DataItem *a = pn->dataitem( aname);

    if ( a==NULL) 
      throw COM_exception( COM_ERR_DATAITEM_NOTEXIST,append_frame
			   (name()+"."+aname,ComponentInterface::get_array));
    get_array_common( a, pane_id, addr, strd, cap, is_const);
  }
}
Exemple #14
0
DataItem *ComponentInterface::inherit( DataItem *from, const std::string &aname,
			    int mode, bool withghost,
			    const DataItem *cond, int val) 
  throw(COM_exception) 
{
  DataItem *a = ((Pane_friend&)_dummy).inherit(from, aname, mode, withghost);
  if ( from->is_windowed()) return a;

  // Copy the panes
  Pane_map &ps = from->window()->_pane_map;

  bool with_conn = from->id()==COM_CONN || from->id()==COM_MESH || 
    from->id()==COM_PMESH || from->id()==COM_ALL;

  bool insert_pane = (mode != Pane::INHERIT_COPY) && with_conn;

  if ( with_conn && aname.size() && from->name() != aname)
    throw COM_exception( COM_ERR_INCOMPATIBLE_DATAITEMS, append_frame
			 (from->fullname()+" and " +aname,
			  ComponentInterface::inherit));

  if ( cond && cond->window()!=from->window()) {
    throw COM_exception( COM_ERR_INCOMPATIBLE_DATAITEMS, append_frame
			 (from->fullname()+" and "+cond->fullname(),
			  ComponentInterface::inherit));
  }

  for ( Pane_map::iterator ppit = ps.begin(); ppit!=ps.end(); ++ppit) {
    Pane *ppn=ppit->second;
    const int *cnd = NULL;
    if ( cond) {
      const DataItem *cond_pn = ppn->dataitem( cond->id());
      cnd = (const int*)cond_pn->pointer();
    }

    // Inherit the pane if the condition was set to an variable (cnd!=NULL),
    // or set to to pane ID (cnd==NULL && val!=0), or not set.
    if ( !cond && (val==0 || val==ppn->id()) || cnd && *cnd == val) {
      // Create new panes only when we are inheriting the mesh.
      Pane_friend *pn;
      if ( insert_pane)
	pn = (Pane_friend*)( &pane( ppit->first, true));
      else {
	Pane_map::iterator it = _pane_map.find( ppit->first);
	pn = ( it!=_pane_map.end())?(Pane_friend*)(it->second):NULL;
      }
 
      if ( pn)
	pn->inherit( ppn->dataitem( from->id()), aname, mode, withghost);
    }
  }
  return a;
}
Exemple #15
0
DataItem *ComponentInterface::
new_dataitem( const std::string &aname, const char loc, const int type, 
	       int ncomp, const std::string &unit) throw(COM_exception) 
{
  // Special handing for connectivity
  if ( Connectivity::is_element_name( aname) || 
       DataItem::is_digit(aname[0])) 
    throw COM_exception( COM_ERR_INVALID_DATAITEM_NAME,append_frame
			 (_name+"."+aname,ComponentInterface::new_dataitem));
  if ( ncomp<=0)
    throw COM_exception( COM_ERR_INVALID_DIMENSION,append_frame
			 (_name+"."+aname,ComponentInterface::new_dataitem));

  if ( loc != 'w' && loc != 'p' && loc != 'e' && loc != 'n' && loc != 'c')
    throw COM_exception( COM_ERR_UNKNOWN_KEYWORD,append_frame
			 (_name+"."+aname,ComponentInterface::new_dataitem));

  if ( type<COM_MIN_TYPEID || type > COM_MAX_TYPEID)
    throw COM_exception( COM_ERR_UNKNOWN_DATATYPE,append_frame
			 (_name+"."+aname,ComponentInterface::new_dataitem));

  // Redefine an dataitem if it pre-exists, but ncomp cannot be increased.
  Attr_map::const_iterator it = _attr_map.find( aname);

  if ( it != _attr_map.end() && ncomp > it->second->size_of_components()) {
    COM_assertion_msg( it->second->id()>=COM_NUM_KEYWORDS,
		       "Cannot increase size of keywords");
    delete_dataitem( it->first);
    it = _attr_map.end();
  }

  int id = (it==_attr_map.end())?_last_id:it->second->id();

  // Insert the object into both the set and the map.
  DataItem *a = ((Pane_friend&)_dummy).
    new_dataitem( aname, id, loc, type, ncomp, unit);
  _attr_map[aname] = a;
  
  // Propagete onto all existing panes.
  for (Pane_map::iterator it=_pane_map.begin(); it!=_pane_map.end(); ++it) {
    Pane_friend *pn = (Pane_friend*)it->second;
    pn->new_dataitem( aname, id, loc, type, ncomp, unit);
  }

  // Update last available id
  if ( it == _attr_map.end()) _last_id = id+ncomp+(ncomp>1);
  
  if ( _status == STATUS_NOCHANGE) _status = STATUS_CHANGED;
  return a;
}
Exemple #16
0
void ComponentInterface::set_size( const std::string &aname, int pid,
		       int nitems, int ng) throw( COM_exception) 
{ 
  if ( Connectivity::is_element_name( aname)) {
    Pane_friend &pn = (Pane_friend&)pane(pid,true);
    Connectivity *con = pn.connectivity( aname,true);
    pn.set_size( con, nitems, ng);
  }
  else {
    DataItem *a = dataitem(aname);

    if ( a == NULL)
      throw COM_exception( COM_ERR_DATAITEM_NOTEXIST,append_frame
			   (_name+"."+aname,ComponentInterface::set_size));
  
    if ( a->is_windowed()) 
      ((Pane_friend&)_dummy).set_size( a, nitems, ng);
    else if ( pid==0) {
      // Loop through the panes to set the sizes.
      for (Pane_map::iterator it=_pane_map.begin(), iend=_pane_map.end();
	   it != iend; ++it) {
	((Pane_friend*)it->second)->set_size
	  ( it->second->dataitem( a->id()), nitems, ng);
      }
    }
    else 
      ((Pane_friend&)pane(pid,true)).set_size( a, nitems, ng); 
  }
}
Exemple #17
0
DataItem *ComponentInterface::
get_dataitem( const std::string &aname, char *loc, int *type, 
	       int *ncomp, std::string *unit) const throw(COM_exception) {
  // Special handing for connectivity tables
  if ( Connectivity::is_element_name( aname)) {
    // Set the arguments if not NULL.
    if ( loc) *loc = 'p';
    if ( type) *type = COM_INT;
    // Return the number of nodes.
    if ( ncomp) *ncomp = Connectivity::get_size_info(aname)
		  [Connectivity::SIZE_NNODES];
    if ( unit) *unit = "";
    return NULL; // A connectivity is not defined in ComponentInterface scope.
  }
  else {
    // Obtain reference to the dataitem
    Attr_map::const_iterator it = _attr_map.find( aname);
    if ( it == _attr_map.end())
      throw COM_exception(COM_ERR_DATAITEM_NOTEXIST, append_frame
			  (_name+"."+aname,ComponentInterface::get_dataitem));
    DataItem &a = *it->second;

    // Set the arguments if not NULL.
    if ( loc) *loc = a.location();
    if ( type) *type = a.data_type();
    if ( ncomp) *ncomp = a.size_of_components();
    if ( unit) *unit = a.unit();
    return &a;
  }
}
Exemple #18
0
int ComponentInterface::
get_status( const std::string &aname, int pid) const throw( COM_exception) {
  // If aname is empty, then check the status of the pane.
  if ( aname.empty()) {
    Pane_map::const_iterator pit = _pane_map.find( pid);
    if ( pit == _pane_map.end()) return -1;
    else return 0;
  }

  const Pane_friend *pn;
  try { pn = &(Pane_friend&)pane(pid); }
  catch ( COM_exception ex) {
    ex.msg = append_frame( ex.msg, ComponentInterface::get_status);
    throw ex;
  }
    
  // Special handing for connectivity
  if ( Connectivity::is_element_name( aname)) {
    // Get the corresponding dataitem object.
    const COM::Connectivity *conn = pn->connectivity( aname);
    if ( conn==NULL) return -1;
    else return conn->status();
  }
  else {
    // Get the corresponding dataitem object.
    const COM::DataItem *attr = pn->dataitem( aname);
    if ( attr==NULL) return -1;
    else return attr->status();
  }
}
Exemple #19
0
void ComponentInterface::
delete_dataitem( const std::string &aname) throw(COM_exception)
{
  Attr_map::iterator it = _attr_map.find( aname);
  if ( it == _attr_map.end())
    throw COM_exception( COM_ERR_DATAITEM_NOTEXIST,append_frame
			 (_name+"."+aname,ComponentInterface::delete_dataitem));

  DataItem *attr = it->second;
  int id = attr->id(), ncomp=attr->size_of_components();

  if ( id < COM_NUM_KEYWORDS && id != COM_DATA)
    throw COM_exception( COM_ERR_INVALID_DATAITEM_NAME,append_frame
			 (_name+"."+aname,ComponentInterface::delete_dataitem));

  // Remove the object from both the set
  ((Pane_friend&)_dummy).delete_dataitem( id);

  // Remove from all panes.
  for (Pane_map::iterator it=_pane_map.begin(); it!=_pane_map.end(); ++it) {
    Pane_friend *pn = (Pane_friend*)it->second;
    pn->delete_dataitem( id);
  }

  // Update last id
  if (id != COM_DATA) {
    _attr_map.erase( it); // Remove from _attr_map
    if ( _last_id == id + ncomp+(ncomp>1)) {
      _last_id = id;
      if ( _status==STATUS_NOCHANGE) _status = STATUS_CHANGED; 
    }
    else
      _status = STATUS_SHRUNK;
  }
  else if (_last_id>COM_NUM_KEYWORDS) {
    _attr_map.clear();
    for ( int i=0; i<COM_NUM_KEYWORDS; ++i) {
      DataItem *a = _dummy.dataitem(i);
      if ( !DataItem::is_digit(a->name()[0])) _attr_map[ a->name()] = a;
    }

    _status = STATUS_CHANGED;
    _last_id = COM_NUM_KEYWORDS;
  }
}
Exemple #20
0
void get_size_common( const Attr *a, int pid, int *nitem, int *ng) 
  throw( COM_exception)
{
  if ( pid==0 && a->location() != 'w')
    throw COM_exception( COM_ERR_NOT_A_WINDOW_DATAITEM, append_frame
			 ( a->fullname(), ComponentInterface::get_size));

  if ( nitem) *nitem = a->size_of_items();
  if ( ng)    *ng = a->size_of_ghost_items();
}
void get_size_common( const Attr *a, int pid, int *nitem, int *ng) 
  throw( COM_exception)
{
  if ( pid==0 && a->location() != 'w')
    throw COM_exception( COM_ERR_NOT_A_WINDOW_ATTRIBUTE, append_frame
			 ( a->fullname(), Window::get_size));

  if ( nitem) *nitem = a->size_of_items();
  if ( ng)    *ng = a->size_of_ghost_items();
}
inline void copy_array_common( const Attr *a, int pid, void *val, int v_strd, 
			       int v_size, int offset) throw(COM_exception) {

  if ( pid==0 && a->location() != 'w')
    throw COM_exception( COM_ERR_NOT_A_WINDOW_ATTRIBUTE, append_frame
			 ( a->fullname(), Window::copy_size));

  const_cast<Attr*>(a)->copy_array( val, v_strd, v_size, 
				    offset, Attribute::COPY_OUT);
}
Exemple #23
0
// duplicate an existing frame
void DrawMolecule::duplicate_frame(const Timestep *ts) {
  Timestep *newts;
  if (ts == NULL) { // append a 'null' frame
    newts = new Timestep(nAtoms);
    newts->zero_values();
  } else {
    newts = new Timestep(*ts);
  }
  append_frame(newts);
}
Exemple #24
0
inline void copy_array_common( const Attr *a, int pid, void *val, int v_strd, 
			       int v_size, int offset) throw(COM_exception) {

  if ( pid==0 && a->location() != 'w')
    throw COM_exception( COM_ERR_NOT_A_WINDOW_DATAITEM, append_frame
			 ( a->fullname(), ComponentInterface::copy_size));

  const_cast<Attr*>(a)->copy_array( val, v_strd, v_size, 
				    offset, DataItem::COPY_OUT);
}
void Window::set_function( const std::string &fname, 
			   Member_func_ptr func,
			   const std::string &intents, 
			   const COM_Type *types, 
			   Attribute *a, 
			   bool) throw(COM_exception) {
  if ( _func_map.find( fname) != _func_map.end()) 
    throw COM_exception(COM_WARN_DUP_FUNC, append_frame
			(_name+"."+fname,Window::init_function));
  
  _func_map[fname] = Function( func, intents, types, a);
}
Exemple #26
0
void ComponentInterface::set_function( const std::string &fname, 
			   Member_func_ptr func,
			   const std::string &intents, 
			   const COM_Type *types, 
			   DataItem *a, 
			   bool) throw(COM_exception) {
  if ( _func_map.find( fname) != _func_map.end()) 
    throw COM_exception(COM_WARN_DUP_FUNC, append_frame
			(_name+"."+fname,ComponentInterface::init_function));
  
  _func_map[fname] = Function( func, intents, types, a);
}
Exemple #27
0
void ComponentInterface::dealloc_array( const std::string &aname, 
			    const int pane_id) throw(COM_exception)
{
  if ( Connectivity::is_element_name( aname)) {
    Pane &pn = pane(pane_id);
    Connectivity *con = ((Pane_friend&)pn).connectivity( aname);
    
    if ( con==NULL) 
      throw COM_exception( COM_ERR_DATAITEM_NOTEXIST, append_frame
			   (name()+"."+aname,ComponentInterface::dealloc_array));

    reinit_conn( con, Pane::OP_DEALLOC);
  }
  else {
    DataItem *a = pane( pane_id).dataitem( aname);

    if ( a==NULL) 
      throw COM_exception( COM_ERR_DATAITEM_NOTEXIST, append_frame
			   (name()+"."+aname,ComponentInterface::dealloc_array));
    reinit_dataitem( a, Pane::OP_DEALLOC);
  }
}
Exemple #28
0
const Pane &ComponentInterface::pane( const int pid) const throw( COM_exception)
{
  if ( pid==0) return _dummy;

  COM_assertion( pid>0);
  Pane_map::const_iterator pit = _pane_map.find( pid);
  if ( pit == _pane_map.end()) {
    throw COM_exception( COM_ERR_PANE_NOTEXIST, append_frame
			 (_name,ComponentInterface::pane));
  }

  return *pit->second;
}
void Window::dealloc_array( const std::string &aname, 
			    const int pane_id) throw(COM_exception)
{
  if ( Connectivity::is_element_name( aname)) {
    Pane &pn = pane(pane_id);
    Connectivity *con = ((Pane_friend&)pn).connectivity( aname);
    
    if ( con==NULL) 
      throw COM_exception( COM_ERR_ATTRIBUTE_NOTEXIST, append_frame
			   (name()+"."+aname,Window::dealloc_array));

    reinit_conn( con, Pane::OP_DEALLOC);
  }
  else {
    Attribute *a = pane( pane_id).attribute( aname);

    if ( a==NULL) 
      throw COM_exception( COM_ERR_ATTRIBUTE_NOTEXIST, append_frame
			   (name()+"."+aname,Window::dealloc_array));
    reinit_attr( a, Pane::OP_DEALLOC);
  }
}
Exemple #30
0
void get_array_common( const Attr *a, int pid, 
		       ComponentInterface::Pointer_descriptor &addr, 
		       int *strd, int *cap, bool is_const) throw(COM_exception) {
  if ( !is_const && a->is_const() )
    throw COM_exception( COM_ERR_DATAITEM_CONST, append_frame
			 (a->fullname(),ComponentInterface::get_array));

  if ( pid==0 && a->location() != 'w')
    throw COM_exception( COM_ERR_NOT_A_WINDOW_DATAITEM, append_frame
			 ( a->fullname(), ComponentInterface::get_array));

  addr.ptr = (void*)(a->pointer());
  if ( addr.dim==1) {
    addr.n1 = a->capacity()*a->stride();
  }
  else if ( addr.dim == 2) {
    if ( a->stride()>=a->size_of_components()) {
      addr.n1 = a->stride();
      addr.n2 = a->capacity();
    }
    else {
      addr.n1 = a->capacity();
      addr.n2 = a->size_of_components();
    }
  }
  else {
    // Scalars must have capacity 1!
    if ( addr.dim==0 && (a->capacity()!=1 || a->size_of_components()!=1))
      throw COM_exception( COM_ERR_INVALID_SIZE, append_frame
			   (a->fullname(),ComponentInterface::get_array));
    if ( addr.dim>2)
      throw COM_exception( COM_ERR_INVALID_DIMENSION, append_frame
			   (a->fullname(),ComponentInterface::get_array));
  }
    
  if ( cap)  *cap = a->capacity();
  if ( strd) *strd = a->stride();
}