Пример #1
0
ItemDB::Record ItemDB::getByDisplayId(unsigned int id)
{
	if (!inited) {
		int j=0;
		for(Iterator i=begin(); i!=end(); ++i)
		{
			itemLookup[i->getUInt(ID)] = j;
			itemDisplayLookup[i->getUInt(ItemDisplayInfo)] = j;
			j++;
		}
		inited = true;
	}

    if (itemDisplayLookup.find(id)!=itemDisplayLookup.end()) {
		int i = itemDisplayLookup[id];
		ItemDB::Record rec = itemdb.getRecord(i);
		return rec;
    }
	throw NotFound();

/*
	for(Iterator i=begin(); i!=end(); ++i)
	{
		if (i->getUInt(ItemDisplayInfo)==id)
			return (*i);
	}
	//wxLogMessage(wxT("NotFound: %s:%s#%d id:%d"), __FILE__, __FUNCTION__, __LINE__, id);
*/
	throw NotFound();
}
/**
 * \brief Get the tracking history of a specific guide run
 *
 * Note that the result of this operation can be large. A guide run of an
 * hour with 5 updates per second (using an adaptive optics unit) contains
 * 18000 data points. Normal guide runs with 10 second update intervals
 * are quite manageable in size, about 360 points per hour of guiding.
 */
TrackingHistory	GuiderFactoryI::getTrackingHistory(int id,
			const Ice::Current& /* current */) {
	astro::guiding::TrackingStore	store(database);
	TrackingHistory	history;
	history.guiderunid = id;

	// get other attributes
	try {
		astro::guiding::GuidingRunTable	gt(database);
		astro::guiding::GuidingRunRecord	r = gt.byid(id);
		history.timeago = converttime(r.whenstarted);
		history.guider.cameraname = r.camera;
		history.guider.ccdid = r.ccdid;
		history.guider.guiderportname = r.guiderport;

		// tracking points
		astro::guiding::TrackingStore	store(database);
		std::list<astro::guiding::TrackingPointRecord>	points
			= store.getHistory(id);
		std::list<astro::guiding::TrackingPointRecord>::iterator i;
		for (i = points.begin(); i != points.end(); i++) {
			history.points.push_back(convert(*i));
		}

		// done
		return history;
	} catch (const std::exception& ex) {
		std::string	msg = astro::stringprintf("tracking history %d "
			"not found: %s", id, ex.what());
		debug(LOG_ERR, DEBUG_LOG, 0, "%s", msg.c_str());
		throw NotFound(msg);
	}
}
/**
 * \brief get details about a specific calibration
 */
Calibration	GuiderFactoryI::getCalibration(int id,
			const Ice::Current& /* current */) {
	// use the database to retrieve the complete calibration data
	Calibration	calibration;
	try {
		astro::guiding::CalibrationTable	ct(database);
		astro::guiding::CalibrationRecord	r = ct.byid(id);
		calibration.id = r.id();
		calibration.timeago = converttime(r.when);
		calibration.guider.cameraname = r.camera;
		calibration.guider.ccdid = r.ccdid;
		calibration.guider.guiderportname = r.guiderport;
		for (int i = 0; i < 6; i++) {
			calibration.coefficients.push_back(r.a[i]);
		}

		// add calibration points
		astro::guiding::CalibrationStore	store(database);
		std::list<astro::guiding::CalibrationPointRecord>	points
			= store.getCalibrationPoints(id);
		std::list<astro::guiding::CalibrationPointRecord>::iterator i;
		for (i = points.begin(); i != points.end(); i++) {
			calibration.points.push_back(convert(*i));
		}
		return calibration;
	} catch (std::exception& ex) {
		std::string	msg = astro::stringprintf("calibrationd run %d "
			"not found: %s", id, ex.what());
		debug(LOG_ERR, DEBUG_LOG, 0, "%s", msg.c_str());
		throw NotFound(msg);
	}
}
Пример #4
0
static void InitFromClass( at_waypoint_t *self, hobj_t *cls )
{
	hpair_t		*pair;
	hobj_t		*pref;

	__named_message( "\n" );

	strncpy( self->ati.type, cls->type, ATI_STRINGSIZE );
	strncpy( self->ati.name, cls->name, ATI_STRINGSIZE );
	self->ati.type[ATI_STRINGSIZE-1] = '\0';
	self->ati.name[ATI_STRINGSIZE-1] = '\0';


	pref = FindClass( at_prefs, cls->type );

	pair = FindHPair( cls, "origin" );
	if( pair )
	{
		HPairCastToVec3d( self->origin, pair );
	} else
		NotFound( "origin" );
	

	L_InsertWaypoint( self );
}
Пример #5
0
std::string HashTableDb::get(const std::string& key)
{
	size_t hashCode = getHash(key) & hashMask;
	try
	{
		IndexNode node = ht->get(hashCode, key.c_str());
		DbRecord rec = node.getRecord(*db);
		if (rec.type() == Long)
		{
			std::string value = rec.value();
			while (rec.hasNextExtendedRecord())
			{
				rec = rec.nextExtendedRecord();
				value += rec.value();
			}
			return value;
		}
		else
		{
			return rec.value();
		}
	}
	catch (IndexFile::IndexNotFound)
	{
		throw NotFound();
	}
}
/**
 * \brief Get the simulated CCD
 *
 * The simulator camera only implements a single ccd.
 */
CcdPtr	SimCamera::getCcd0(size_t ccdid) {
	if (0 != ccdid) {
		throw NotFound("only ccd 0 exists");
	}
	CcdInfo	info = getCcdInfo(0);
	return CcdPtr(new SimCcd(info, _locator));
}
Пример #7
0
void CompartmentSpaceVectorImpl::release_species(const Species& sp)
{
    species_map_type::iterator i(index_map_.find(sp));
    if (i == index_map_.end())
    {
        std::ostringstream message;
        message << "Speices [" << sp.serial() << "] not found";
        throw NotFound(message.str()); // use boost::format if it's allowed
    }

    species_map_type::mapped_type
        idx((*i).second), last_idx(num_molecules_.size() - 1);
    if (idx != last_idx)
    {
        species_container_type::size_type const
            idx_(static_cast<species_container_type::size_type>(idx)),
            last_idx_(static_cast<species_container_type::size_type>(last_idx));
        const Species& last_sp(species_[last_idx_]);
        species_[idx_] = last_sp;
        num_molecules_[idx] = num_molecules_[last_idx];
        index_map_[last_sp] = idx;
    }

    species_.pop_back();
    num_molecules_.pop_back();
    index_map_.erase(sp);
}
Пример #8
0
void CompartmentSpaceVectorImpl::remove_molecules(
    const Species& sp, const Integer& num)
{
    if (num < 0)
    {
        std::ostringstream message;
        message << "The number of molecules must be positive. [" << sp.serial() << "]";
        throw std::invalid_argument(message.str());
    }

    species_map_type::const_iterator i(index_map_.find(sp));
    if (i == index_map_.end())
    {
        std::ostringstream message;
        message << "Speices [" << sp.serial() << "] not found";
        throw NotFound(message.str()); // use boost::format if it's allowed
    }

    if (num_molecules_[(*i).second] < num)
    {
        std::ostringstream message;
        message << "The number of molecules cannot be negative. [" << sp.serial() << "]";
        throw std::invalid_argument(message.str());
    }

    num_molecules_[(*i).second] -= num;
}
int CustomerList::FindCustomerLocation (QString userName)
{
	Node<Customer> * traversePtr;

	if(isEmpty())
	{
		throw EmptyList();
	}

	// NEED TO MAKE SURE 2 ACCOUNT NUMBERS CANNOT BE THE SAME //
	traversePtr = _head;
	int index = 0;
	while (index < Size() && traversePtr !=NULL &&
		   traversePtr->GetData().getUserName() != userName)
	{
		traversePtr = traversePtr->GetNext();

		index++;
	}
	if (traversePtr == NULL)
	{
		qDebug() << "12";
		// throw exception class if not found.
		throw NotFound();
	}

	return index;
}
Пример #10
0
void Urls::Impl::handleUrlChanged(const std::string& path) {
    UrlTreeBranch* branch = findBranch(path);
    // If we didn't find any branches to handle the request, this is a bad url
    if (branch == nullptr)
        throw NotFound(path);
    branch->onSelected(path);
}
Customer CustomerList::operator[](int index) const
{
	Node<Customer> * traversePtr;

	if(isEmpty())
	{
		throw EmptyList();
	}

	if (index > _listLimit)
	{
		throw OutOfRange();
	}


	// NEED TO MAKE SURE 2 ACCOUNT NUMBERS CANNOT BE THE SAME //
	traversePtr = _head;
	int i = 0;
	while (i < _listLimit && traversePtr !=NULL &&
		   i != index)
	{
		traversePtr = traversePtr->GetNext();

		i++;
	}

	if (traversePtr == NULL)
	{
		// throw exception class if not found.
		traversePtr = NULL;
		throw NotFound();
	}

	return traversePtr->GetData();
}
Пример #12
0
 /*! @throws NotFound */
 const std::string&
 get (const std::string& key) const
 {
     param_map_t::const_iterator i = params_.find(key);
     if (i == params_.end()) throw NotFound();
     return i->second;
 }
Customer* CustomerList::ReturnCustomerPtr(QString userName)
{
	Node<Customer> * traversePtr;

	if(isEmpty())
	{
		throw EmptyList();
	}

	// NEED TO MAKE SURE 2 ACCOUNT NUMBERS CANNOT BE THE SAME //
	traversePtr = _head;
	int index = 0;
	while (index < _listLimit && traversePtr !=NULL &&
		   traversePtr->GetData().getUserName() != userName)
	{
		traversePtr = traversePtr->GetNext();

		index++;
	}
	if (traversePtr == NULL)
	{
		// throw exception class if not found.
		traversePtr = NULL;
		throw NotFound();
	}

	Customer *dataPtr = traversePtr->GetDataPtr();


	return dataPtr;
}
Пример #14
0
	const RawDataDAT1::s_info& DAT1::getInfo(const std::string& name) const {
		type_filelist::const_iterator i = m_filelist.find(name);
		if (i == m_filelist.end())
			throw NotFound(name);

		return i->second;
	}
Пример #15
0
    Row Connection::selectRow(const std::string& query)
    {
      tntdb::Result result = select(query);
      if (result.empty())
        throw NotFound();

      return result.getRow(0);
    }
Пример #16
0
    Value Connection::selectValue(const std::string& query)
    {
      Row t = selectRow(query);
      if (t.empty())
        throw NotFound();

      return t.getValue(0);
    }
Пример #17
0
	Map* Model::getMap(const std::string& identifier) const {
		std::list<Map*>::const_iterator it = m_maps.begin();
		for(; it != m_maps.end(); ++it) {
			if((*it)->getId() == identifier)
				return *it;
		}

		throw NotFound(std::string("Tried to get non-existent map: ") + identifier + ".");
	}
TaskParameters TaskQueueI::parameters(int taskid, const Ice::Current& /* current */) {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "query parameters of task %d", taskid);
	if (!taskqueue.exists(taskid)) {
		std::string	cause = astro::stringprintf(
			"task %d does not exist", taskid);
		debug(LOG_ERR, DEBUG_LOG, 0, "%s", cause.c_str());
		throw NotFound(cause);
	}
	try {
		return snowstar::convert(taskqueue.parameters(taskid));
	} catch (const std::exception& x) {
		std::string	 cause = astro::stringprintf(
			"cannot get parameters for task %d: %s %s", taskid,
			astro::demangle(typeid(x).name()).c_str(), x.what());
		debug(LOG_ERR, DEBUG_LOG, 0, "%s", cause.c_str());
		throw NotFound(cause);
	}
}
FocuserPtr	SimLocator::getFocuser0(const DeviceName& name) {
	std::string	sname = name;
	if (sname != "focuser:simulator/focuser") {
		debug(LOG_ERR, DEBUG_LOG, 0, "focuser %s does not exist",
			sname.c_str());
		throw NotFound("no such focuser");
	}
	return _focuser;
}
Пример #20
0
	RawData* VFS::open(const std::string& path) {
		FL_DBG(_log, LMsg("Opening: ") << path);

		VFSSource* source = getSourceForFile(path);
		if (!source)
			throw NotFound(path);

		return source->open(path);
	}
CcdPtr	SimLocator::getCcd0(const DeviceName& name) {
	std::string	sname = name;
	if (sname != "ccd:simulator/camera/ccd") {
		debug(LOG_ERR, DEBUG_LOG, 0, "ccd %s does not exist",
			sname.c_str());
		throw NotFound("no such ccd");
	}
	return _ccd;
}
AdaptiveOpticsPtr	SimLocator::getAdaptiveOptics0(const DeviceName& name) {
	std::string	sname = name;
	if (sname != "adaptiveoptics:simulator/adaptiveoptics") {
		debug(LOG_ERR, DEBUG_LOG, 0, "adaptiveoptics %s does not exist",
			sname.c_str());
		throw NotFound("no such adaptiveoptics");
	}
	return _adaptiveoptics;
}
Пример #23
0
	Layer* Map::getLayer(const std::string& id) {
		std::list<Layer*>::const_iterator it = m_layers.begin();
		for(; it != m_layers.end(); ++it) {
			if((*it)->getId() == id)
				return *it;
		}

		throw NotFound(id);
	}
Пример #24
0
 const ParticleID find_particle_id(const coordinate_type& coord) const
 {
     container_type::const_iterator i(this->find(coord));
     if (i == voxels_.end())
     {
         throw NotFound("No corresponding ParticleID was found.");
     }
     return (*i).second;
 }
Пример #25
0
// Classes
CharClassesDB::Record CharClassesDB::getById(unsigned int id)
{
	for(Iterator i=begin(); i!=end(); ++i)
	{
		if (i->getUInt(ClassID)==id) return (*i);
	}
	//wxLogMessage(wxT("NotFound: %s:%s#%d"), __FILE__, __FUNCTION__, __LINE__);
	throw NotFound();
}
Пример #26
0
    Value Connection::selectValue(const std::string& query)
    {
      log_debug("selectValue(\"" << query << "\")");
      Row t = selectRow(query);
      if (t.empty())
        throw NotFound();

      return t.getValue(0);
    }
astro::device::MountPtr	SimLocator::getMount0(const DeviceName& name) {
	std::string	mname = name;
	if (mname != "mount:simulator/mount") {
		debug(LOG_ERR, DEBUG_LOG, 0, "mount %s does not exist",
			mname.c_str());
		throw NotFound("no such mount");
	}
	return _mount;
}
Пример #28
0
    Row Connection::selectRow(const std::string& query)
    {
      log_debug("selectRow(\"" << query << "\")");
      tntdb::Result result = select(query);
      if (result.empty())
        throw NotFound();

      return result.getRow(0);
    }
GuidePortPtr	SimLocator::getGuidePort0(const DeviceName& name) {
	std::string	sname = name;
	if ((sname != "guideport:simulator/guideport") &&
		(sname != "guideport:simulator/camera")) {
		debug(LOG_ERR, DEBUG_LOG, 0, "guideport %s does not exist",
			sname.c_str());
		throw NotFound("no such guideport");
	}
	return _guideport;
}
FilterWheelPtr	SimLocator::getFilterWheel0(const DeviceName& name) {
	std::string	sname = name;
	if ((sname != "filterwheel:simulator/filterwheel") &&
		(sname != "filterwheel:simulator/camera")) {
		debug(LOG_ERR, DEBUG_LOG, 0, "filterwheel %s does not exist",
			sname.c_str());
		throw NotFound("no such filterwheel");
	}
	return _filterwheel;
}