Exemple #1
0
void
io_module_init(void)
{
    cnodeid_t		node;
    lboard_t	       *board;
    nasid_t		nasid;
    int			nserial;
    module_t	       *m;

    DPRINTF("*******module_init\n");

    nserial = 0;

    for (node = 0; node < numnodes; node++) {
	nasid = COMPACT_TO_NASID_NODEID(node);

	board = find_lboard((lboard_t *) KL_CONFIG_INFO(nasid),
			    KLTYPE_IP27);
	ASSERT(board);

	m = module_add_node(board->brd_module, node);

	if (! m->snum_valid && module_probe_snum(m, nasid))
	    nserial++;
    }

    DPRINTF("********found total of %d serial numbers in the system\n",
	    nserial);

    if (nserial == 0)
	PRINT_WARNING("io_module_init: No serial number found.\n");
}
Exemple #2
0
CubitStatus RefEdge::get_center_radius( CubitVector& center, double& radius )
{
   Curve* curve_ptr = get_curve_ptr();

   if( curve_ptr != NULL )
   {

      if( curve_ptr->geometry_type() != ARC_CURVE_TYPE &&
          curve_ptr->geometry_type() != ELLIPSE_CURVE_TYPE )
         return CUBIT_FAILURE;

      if( curve_ptr->get_center_radius( center, radius ) == CUBIT_FAILURE )
         return CUBIT_FAILURE;
   }
   else 
   {
      PRINT_WARNING("In RefEdge::get_center_radius\n"
                    "         %s (curve %d) is not associated with a valid\n"
                    "         underlying geoemtric Curve\n",
                    entity_name().c_str(), id()) ;
      return CUBIT_FAILURE ;
   }
   
   return CUBIT_SUCCESS;
}
Exemple #3
0
//- remove the item at the current location and return a pointer to it.
//- The next node becomes the current node
//- Returns {NULL} if there are no items in list
void* DLList::cut_link ()
{
    if ( !itemCount )
    {
        PRINT_WARNING("Attempted link removal from empty DLList\n");
        return NULL;
    }

    // save the current value

    void *temp = listArray[index];

    // compress memory

    for ( int i = index; i < itemCount-1; i++ )
    {
        listArray[i] = listArray[i+1];
    }

    itemCount--;
    if ( index >= itemCount )
    {
        index = 0;
    }

    return temp;
}
Exemple #4
0
CubitStatus RefEdge::get_point_direction( CubitVector& origin, CubitVector& direction )
{
   Curve* curve_ptr = get_curve_ptr();

   if( curve_ptr != NULL )
   {

      if( curve_ptr->geometry_type() != STRAIGHT_CURVE_TYPE ) 
         return CUBIT_FAILURE;

      if( curve_ptr->get_point_direction( origin, direction ) == CUBIT_FAILURE )
      {
         origin = start_coordinates();
         direction = end_coordinates() - origin;
         direction.normalize();
      }
   }
   else 
   {
      PRINT_WARNING("In RefEdge::get_point_direction\n"
                    "         %s (curve %d) is not associated with a valid\n"
                    "         underlying geometric Curve\n",
                    entity_name().c_str(), id()) ;
      return CUBIT_FAILURE ;
   }
   
   if (curve_ptr->bridge_sense() == CUBIT_REVERSED)
     direction = -direction;
   
   return CUBIT_SUCCESS;

}
Exemple #5
0
void CubitMessage::output_debug_information(CubitString &match)
{
  int count = 0;
  for (int i=1; i <= number_of_debug_flags(); i++) {
    char *tmp = CubitUtil::util_strdup((char*)(debugFlag[i].description));
    if (tmp && strlen(tmp) > 0) {
      CubitString debug_description(tmp);
      debug_description.to_lower();
      if (debug_description.find(match, 0) < debug_description.length()) {
	if (count == 0) {
	  PRINT_INFO("Debug Flag Settings "
		     "(flag number, setting, output to, description):\n");
	}
	debugFlag[i].output();
	count++;
      }
    }
    CubitUtil::util_strdup_free(tmp);
  }
  if (count == 0) {
    PRINT_WARNING("No debug descriptions contain the "
		  "substring '%s'\n", match.c_str());
  }
  PRINT_INFO("\n");
}
Exemple #6
0
static int add_new_connection(struct isert_listener_dev *dev,
			      struct iscsi_conn *conn)
{
	struct isert_conn_dev *conn_dev = get_available_dev(dev, conn);
	int res = 0;

	TRACE_ENTRY();

	if (!conn_dev) {
		PRINT_WARNING("%s", "Unable to allocate new connection");
		res = -ENOSPC;
		goto out;
	}

#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
	INIT_WORK(&conn->close_work, isert_close_conn_fn, conn);
#else
	INIT_WORK(&conn->close_work, isert_close_conn_fn);
#endif

	init_timer(&conn_dev->tmo_timer);
	conn_dev->tmo_timer.function = isert_conn_timer_fn;
	conn_dev->tmo_timer.expires = jiffies + 60 * HZ;
	conn_dev->tmo_timer.data = (unsigned long)conn_dev;
	add_timer(&conn_dev->tmo_timer);
	conn_dev->timer_active = 1;
	wake_up(&dev->waitqueue);

out:
	TRACE_EXIT_RES(res);
	return res;
}
Exemple #7
0
//-------------------------------------------------------------------------
// Purpose       : Initializes the member data of the RefEdge
//
// Special Notes :
//
// Creator       : Malcolm J. Panthaki
//
// Creation Date : 10/07/96
//-------------------------------------------------------------------------
void RefEdge::initialize()
{
    // Initialize some member data
  refEdgeClone = 0;
  markedFlag = CUBIT_FALSE;

    // Make sure the arc length is not zero if there are start and end 
    // RefVertex'es already assigned to this RefEdge
  if ( get_arc_length() < CUBIT_DBL_MIN )  
  {
    if ( start_vertex() && end_vertex() )
    {
      CubitVector start_pt = start_vertex()->coordinates();
      CubitVector end_pt   = end_vertex()->coordinates();
      PRINT_WARNING ( "(RefEdge::initialize): Edge has zero arclength.\n"
                      "  Start vertex location is (%9.2f, %9.2f, %9.2f ).\n"
                      "  End   vertex location is (%9.2f, %9.2f, %9.2f ).\n",
          start_pt.x(), start_pt.y(), start_pt.z(),
          end_pt.x(), end_pt.y(), end_pt.z() );
    }
    else if (!mSuppressEdgeLengthWarning)
    {
      PRINT_WARNING( "Edge found with zero arclength\n"
                     "  For cones, this may be normal.\n");
    }
    
  }
  
    // Set the Entity ID for this new RefEdge
   GeometryEntity* geom_ptr = get_geometry_entity_ptr();
   int saved_id = geom_ptr->get_saved_id();
   if ( !saved_id || RefEntityFactory::instance()->get_ref_edge(saved_id) )
   {
     saved_id =  RefEntityFactory::instance()->next_ref_edge_id();
     geom_ptr->set_saved_id(saved_id);
   }
   entityId = saved_id;
  
     // read and initialize attributes
   auto_read_cubit_attrib();
   auto_actuate_cubit_attrib();

     // Assign a default entity name
   assign_default_name();
}
//Single Setter
void DataEnvelopeParameters::setEnvelopeType(QString type) {
    if (type!=m_envelopeType)
        if (DataEnvelope::isValidEnvelopeType(type)) {
            m_envelopeType=type;
            emit (envelopeTypeChanged(type));
        }
        else
            PRINT_WARNING(ErrorMessage::WARNING(Q_FUNC_INFO,"Unsupported type"));
}
void MainWindow::importData2Pressed() {
    QDomDocument _doc;
    ErrorMessage _err;
    QString _fileName=QString("%1/").arg(FILE_PATH);
    _fileName = QFileDialog::getOpenFileName(this, "Load test1 file",
                                                   _fileName,
                                                   "XML file (*.xml *.XML)");

    if (!DomHelperUtility::load(_fileName,&_doc,&_err)) {
        PRINT_WARNING(_err.message());
    } else {
        if (!(m_data2->getDelegate()->setClassByDomData(_doc,&_err))) {
            PRINT_WARNING(_err.message());
        } else {
            PRINT_DEBUG_LEVEL(ErrorMessage::DEBUG_NOT_SO_IMPORTANT,ErrorMessage::DEBUG(Q_FUNC_INFO,"Imported document from file %1\n%2\n").arg(_fileName).arg(_doc.toString(4)));
        }
    }
}
Exemple #10
0
int isert_login_req_rx(struct iscsi_cmnd *login_req)
{
	struct isert_conn_dev *dev = isert_get_priv(login_req->conn);
	int res = 0;

	TRACE_ENTRY();

	if (!dev) {
		PRINT_ERROR("Received PDU %p on invalid connection",
			    login_req);
		res = -EINVAL;
		goto out;
	}

	switch (dev->state) {
	case CS_INIT:
	case CS_RSP_FINISHED:
		if (unlikely(dev->login_req != NULL)) {
			sBUG();
			res = -EINVAL;
			goto out;
		}
		break;

	case CS_REQ_BHS: /* Got login request before done handling old one */
		break;

	case CS_REQ_DATA:
	case CS_REQ_FINISHED:
	case CS_RSP_BHS:
	case CS_RSP_DATA:
		PRINT_WARNING("Received login PDU while handling previous one. State:%d",
			      dev->state);
		res = -EINVAL;
		goto out;

	default:
		sBUG();
		res = -EINVAL;
		goto out;
	}


	spin_lock(&dev->pdu_lock);
	dev->login_req = login_req;
	dev->read_len = sizeof(login_req->pdu.bhs);
	dev->read_buf = (char *)&login_req->pdu.bhs;
	dev->state = CS_REQ_BHS;
	spin_unlock(&dev->pdu_lock);

	wake_up(&dev->waitqueue);

out:
	TRACE_EXIT_RES(res);
	return res;
}
Exemple #11
0
int CubitMessage::reset_error_count(int value)
{
  int current_value = errorCount;
  if (errorCount != value) {
    errorCount = value;
    PRINT_WARNING("Error count manually changed from %d to %d\n\n",
		  current_value, value);
  }
  return current_value;
}
bool DataEnvelopeParameters::setTimeParameters(qreal attack, qreal hold, qreal decay ,qreal sustain, qreal release) {
    bool retval=false;
    attack=(attack>=0 ? attack : 0);
    hold=(hold>=0 ? hold : 0);
    decay=(decay>=0 ? decay : 0);
    sustain=(sustain>=0 ? sustain : 0);
    release=(release>=0 ? release : 0);
    qreal _total=attack+hold+decay+sustain+release;

    PRINT_DEBUG_LEVEL(ErrorMessage::DEBUG_NOT_SO_IMPORTANT,ErrorMessage::DEBUG(Q_FUNC_INFO,"try to set attack=%1 hold=%2 decay=%3 sustain=%4 release=%5")
                      .arg(attack)
                      .arg(hold)
                      .arg(decay)
                      .arg(sustain)
                      .arg(release));
    PRINT_DEBUG_LEVEL(ErrorMessage::DEBUG_NOT_IMPORTANT,ErrorMessage::DEBUG(Q_FUNC_INFO,"with _total=%1 m_total=%2 comparison (_total <= m_total) is %3")
                      .arg(_total)
                      .arg(m_totalTime)
                      .arg((_total <= m_totalTime)));

    //To avoid prolem of rounding the total is compared with rounding after a multplication by 1000000
    //Set only if _total is adequate
    if (qFloor(1000000*_total) <= qFloor(1000000*m_totalTime)) {
        m_attack=attack;
        m_hold=hold;
        m_decay=decay;
        m_sustain=sustain;
        m_release=release;
        retval=true;
        PRINT_DEBUG_LEVEL(ErrorMessage::DEBUG_NOT_IMPORTANT,ErrorMessage::DEBUG(Q_FUNC_INFO,"set to m_attack=%1 m_hold=%2 m_decay=%3 m_sustain=%4 m_release=%5")
                          .arg(m_attack)
                          .arg(m_hold)
                          .arg(m_decay)
                          .arg(m_sustain)
                          .arg(m_release));
        //emit (timeParametersChanged());
    } else {
        PRINT_WARNING(ErrorMessage::WARNING(Q_FUNC_INFO,"dataset invalid %1+%2+%3+%4+%5=%6").arg(attack).arg(hold).arg(decay).arg(sustain).arg(release).arg(_total));
        PRINT_WARNING(ErrorMessage::WARNING(Q_FUNC_INFO,"should be %1 <=%2").arg(_total).arg(m_totalTime));
    }
    return retval;
}
void ImportNotes::loadRescentEvents()
{
	EventUtil *util=new EventUtil(this);

	try
	{
		int roomID=ui.cmbRoom->itemData(ui.cmbRoom->currentIndex(),Qt::UserRole).toInt();

		allEvents.clear();

		QList<EventInfo> totalEvents=util->loadEventsOFRoom(roomID,logSession->getDriverName());

		int k=0;

		for(int i=totalEvents.size()-1;i>=0;i--)
		{

			if (totalEvents[i].getEventStatus()=="Closed")
			{
				if(logSession->canViewClosedEvent()) allEvents<<totalEvents[i];
				else continue;
			}
			else
			{
				allEvents<<totalEvents[i];
			}

			if(k==6) break;

			k++;
		}
	}	
	catch(DBExeption e)//catching db exeptions
	{
		if(e==ExecutionFailed)
		{
			PRINT_ERROR("insertion failed");	
		}
		if(e==UnableToConnect)
		{
			PRINT_ERROR("Unable to connect to db");	
		}	
		if(e==EmptyResultSet)
		{
			PRINT_WARNING("Empty result set");
		}
	}
	catch(...)//catching unknown wxwptions
	{
		PRINT_ERROR("UNKnown ERROR");
	}

	delete util;
}
void ImportNotes::btnImportNotes_clicked()
{
	int eventID=ui.tblImportSession->item(ui.tblImportSession->currentRow(),0)->data(Qt::UserRole).toInt();
	int roomID=ui.cmbRoom->itemData(ui.cmbRoom->currentIndex(),Qt::UserRole).toInt();
	bool chkState;

	DLCRMain *dlcrs=static_cast<DLCRMain*>(this->parent());
	EventNoteUtil *util=new EventNoteUtil(this);
	try
	{
		QList<EventNoteInfo> allEventNotes=util->selectAllEventNotes(eventID,roomID,logSession->getDriverName());
		if (tabIndex==0)
		{
			if (ui.chkTime->checkState()==Qt::Checked)
			{
				chkState=true;
			}
			else
			{
				chkState=false;
			}
			dlcrs->ui.activeEditor->createEditor();
			dlcrs->ui.activeEditor->insertImportRows(allEventNotes,chkState);
			ui.btnImportNotes->setEnabled(false);
		}
		else
		{
			dlcrs->ui.activeRetriever->createEditor();
			dlcrs->ui.activeRetriever->insertImportRows(allEventNotes);
			ui.btnImportNotes->setEnabled(false);
		}
		
	}
	catch(DBExeption e)//catching db exceptions
	{ 
		if(e==ExecutionFailed)
		{
			PRINT_ERROR("insertion failed");	
		}
		if(e==UnableToConnect)
		{
			PRINT_ERROR("Unable to connect to db");	
		}	
		if(e==EmptyResultSet)
		{
			PRINT_WARNING("Empty result set");
		}
	}
	catch(...)//catching unknown exceptions
	{
		PRINT_ERROR("UNKnown ERROR");
	}
	delete util;
}
Exemple #15
0
CubitBoolean RefEdge::is_tolerant()
{
   Curve* curve_ptr = get_curve_ptr();
   if (curve_ptr == NULL) {
      PRINT_WARNING("\tWARNING: Null underlying curve for %s, (%s %d)\n",
         entity_name().c_str(), class_name(), id());
      return CUBIT_FALSE;
   }

   return curve_ptr->is_tolerant();
}
Exemple #16
0
template <class X> inline X DLIList<X>::get() const
{
  if ( !itemCount )
  {
    PRINT_WARNING("Attempted get of empty DLIList\n");
    return X(0);
  }
  else
  {
    return listArray[index];
  }
}
Exemple #17
0
void* DLList::change_item_to ( void *new_item )
{
  assert(new_item != NULL);
  if ( !itemCount )
    {
      PRINT_WARNING("DLList: Attempted update of empty list\n");
      return NULL;
    }
  void *temp = listArray[index];
    listArray[index] = new_item;
  return temp;
}
Exemple #18
0
void *DLList::get_item_and_back ()
{
    if ( !itemCount )
    {
        PRINT_WARNING("Attempted get_and_back from empty DLList\n");
        return NULL;
    }
    void *temp = listArray[index--];
    if (index < 0) index=itemCount-1;
    assert(temp != NULL);
    return temp;
}
Exemple #19
0
template <class X> inline X DLIList<X>::get_and_back ()
{
   if ( !itemCount )
   {
      PRINT_WARNING("Attempted get_and_back from empty DLIList\n");
      return X(0);
   }
   X temp = listArray[index--];
   if (index < 0)
      index=itemCount-1;
   return temp;
}
Exemple #20
0
template <class X> inline X DLIList<X>::next() const
{
  if (!itemCount)
  {
    PRINT_WARNING("Attempted next of empty DLIList\n");
    return X(0);
  }
  else if (index == itemCount-1)
    return listArray[0];
  else
    return listArray[index+1];
}
Exemple #21
0
//- Change the current item to a null pointer and return a pointer
//- to the item (before nulled). See the discussion for {nullItem}.
void* DLList::nullify_link ()
{
    if ( !itemCount )
    {
        PRINT_WARNING("Attempted link nullify from empty DLList\n");
        return NULL;
    }

    // save the current value
      nullItem = listArray[index];
      listArray[index] = 0;
    return nullItem;
}
void MainWindow::pasteData2Pressed() {
    ErrorMessage _err;
    if (!m_data2->getDelegate()->setClassByDomData(m_clipboard,&_err)){
        PRINT_WARNING(_err.message());
    } else {
//        const QDomNode _rootNode=m_data2->getDelegate()->getRootNode();
//        DomHelperUtility::parseDOMToQTreeWidget(&_rootNode,m_treeWidget);
//        m_treeWidget->setWindowTitle("pasteData2Pressed");
//        m_treeWidget->show();
//        m_treeWidget->expandAll();
        PRINT_DEBUG_LEVEL(ErrorMessage::DEBUG_NOT_SO_IMPORTANT,_err.message());
    }
}
void ImportNotes::cmbLocationName_indexChanged(int index_)
{
	RoomUtil *util =new RoomUtil(this);

	try
	{
		ui.cmbRoom->blockSignals(true);
		ui.cmbRoom->clear();
		ui.cmbRoom->blockSignals(false);

		int locationID=ui.cmbLocation->itemData(index_,Qt::UserRole).toInt();
		//getting all rooms by location
		QList<RoomInfo> locationRooms=util->selectRoomsOfLocation(locationID,logSession->getDriverName());

		QList<int> userRoomList=logSession->getUserRoomIDs();

		for (int i=0;i<userRoomList.size();i++)
		{
			//inserting location details as widget items to tblLocations
			foreach(RoomInfo info,locationRooms)
			{
				if (info.getRoomID()==userRoomList[i])
				{
					ui.cmbRoom->insertItem(i,info.getRoomName(),info.getRoomID());
					break;
				}
			}
		}		
	}
	catch(DBExeption e)//catching db exeptions
	{
		if(e==ExecutionFailed)
		{
			PRINT_ERROR("insertion failed");	
		}
		if(e==UnableToConnect)
		{
			PRINT_ERROR("Unable to connect to db");	
		}	
		if(e==EmptyResultSet)
		{
			PRINT_WARNING("Empty result set");
		}
	}
	catch(...)//catching unknown wxwptions
	{
		PRINT_ERROR("UNKnown ERROR");
	}

	delete util;
}
Exemple #24
0
void *DLList::step_and_get_item () 
{
    if ( !itemCount )
    {
        PRINT_WARNING("Attempted step_and_get from empty DLList\n");
        return NULL;
    }

    if (++index == itemCount)
      index=0;
    void *temp = listArray[index];
    assert(temp != NULL);
    return temp;
}
Exemple #25
0
template <class X> inline X DLIList<X>::change_to (X new_value)
{
  X temp = X(0);
  if ( !itemCount )
  {
    PRINT_WARNING("DLIList: Attempted update of empty list\n");
  }
  else
  {
    temp = listArray[index];
    listArray[index] = new_value;
  }
  return temp;
}
Exemple #26
0
CubitStatus hollow()
{
  GeometryQueryTool *gti = GeometryQueryTool::instance();
  GeometryModifyTool *gmti = GeometryModifyTool::instance();

  // Read in the geometry from files specified on the command line
  const char *argv = STRINGIFY(SRCDIR) "/hollow.sat";
  CubitStatus status = read_geometry(1, &argv);
  if (status == CUBIT_FAILURE) exit(1);
  else if (gti->num_bodies() == 0) {
    PRINT_WARNING("No bodies read; exiting.\n");
    int ret_val = ( CubitMessage::instance()->error_count() );

    exit(ret_val);
  }
  
  //test making thick body.
  DLIList<Body*> new_bodies;
  gti->bodies(new_bodies);
  double d = new_bodies.get()->measure(); //d = 518.3627
  int n = new_bodies.get()->num_ref_faces(); //n = 5
  assert(n == 5);
  assert(d-518.3627 < 0.0001);

  //find the top most surface as the opening of the thick body.
  DLIList<RefFace*> ref_faces;
  new_bodies.get()->ref_faces(ref_faces);
  CubitVector center(0,0,10);
  for(int i = 0; i < n; i++)
  {
    if(ref_faces.step_and_get()->is_planar() &&
       ref_faces.get()->center_point() == center )
      break;
  }
  DLIList<RefFace*> faces_to_remove;
  faces_to_remove.append(ref_faces.get());
  DLIList<Body*> from_bodies;
  from_bodies = new_bodies;
  new_bodies.clean_out();
  CubitStatus stat = gmti->hollow(from_bodies, faces_to_remove, new_bodies, -.2);
  //Created volume(s): 2
  //Destroyed volume(s): 1
  n = new_bodies.get()->num_ref_faces(); //n = 9
  d = new_bodies.get()->measure(); //d = 72.4074
  assert(n == 9);
  assert(d - 72.4074 < 0.0001);
  return stat ;
}
Exemple #27
0
template <class X> inline X DLIList<X>::get_and_step()
{
#ifndef GDSJAAR
  if ( !itemCount )
  {
    PRINT_WARNING("Attempted get_and_step from empty DLIList\n");
    return X(0);
  }
  else
#endif
  {
    X temp = listArray[index++];
    if (index == itemCount)
      index=0;
    return temp;
  }
}
Exemple #28
0
/*
 * Resume execution after an external function call
 */
int XTIER_inject_resume_module_execution(struct kvm_vcpu *vcpu)
{
	struct timespec begin;

	// Did the function return?
	if(kvm_rip_read(vcpu) == _XTIER_inject.external_function_return_rip)
	{
		// Take time
		// Since the execution is still running we do not use starttime!
		XTIER_inject_begin_time_measurement(&begin);

		PRINT_INFO("External function returned. Execution of the injected module will be resumed!\n");
		PRINT_DEBUG("EIP: 0x%lx, RSP: 0x%lx, CR3: 0x%lx\n", kvm_rip_read(vcpu), kvm_register_read(vcpu, VCPU_REGS_RSP), kvm_read_cr3(vcpu));


		// Make the module accessible again
		XTIER_memory_reallow_access(vcpu);

		// Restore RIP
		kvm_rip_write(vcpu, _XTIER_inject.external_function_return_rip);
		_XTIER_inject.external_function_return_rip = 0;

		// Set HALT Exiting
		XTIER_enable_hlt_exiting();

		// Set Exception Exiting
		XTIER_enable_interrupt_exiting(vcpu);

		// Take time
		XTIER_inject_end_time_measurement(&begin, &_XTIER_performance.total_module_temp_resume_time);

		// Return but do not update RIP
		return 2;
	}
	else
	{
		PRINT_WARNING("External function tried to access the protected memory area @ 0x%lx!\n Malware?\n", kvm_rip_read(vcpu));
		return 0;
	}

	return 0;
}
Exemple #29
0
void *DLList::prev_item ( int n )  const
{
    if ( !itemCount )
    {
        PRINT_WARNING("Attempted prev of empty DLList\n");
        return NULL;
    }

    // return the proper index
    // beware of negative n
    int new_index = index - n;

    while (new_index < 0)
      new_index += itemCount;
    // beware of negative n leading to new_index >itemCount
    new_index = new_index%itemCount;

    assert(listArray[new_index] != NULL);
    return listArray[new_index];
}
Exemple #30
0
template <class X> inline X DLIList<X>::next(int n) const
{
  if ( !itemCount )
  {
    PRINT_WARNING("Attempted next of empty DLIList\n");
    return X(0);
  }
  else
  {
      // return the proper index
      // beware of negative n leading to negative new_index
    int new_index = index+n;
    while (new_index < 0)
      new_index += itemCount;
    if (new_index >= itemCount)
      new_index %= itemCount;
    
    return listArray[new_index];
  }
}