コード例 #1
0
ファイル: Strpack.cpp プロジェクト: vortex314/Common
Erc Strpack::unpack(uint64_t* val) {
    uint64_t r=0;
    while (is_digit(peek()) && hasData()) {
        r *= 10;
        r += to_digit(read());
    }
    *val = r;
    return E_OK;
}
コード例 #2
0
ファイル: RingBuffer.cpp プロジェクト: dankreek/Swizzler
T RingBuffer<T>::get() {
  if (hasData()) {
          T data = buf[head];
          head = (head+1) % bufSize;
          return data;
  }

  return 0;
}
コード例 #3
0
ファイル: VCFreader.cpp プロジェクト: grenaud/mistartools
void VCFreader::repositionIterator(string chrName,int start,int end){


    if(!tabixMode){
	cerr<<"The subroutine repositionIterator can only be called on objects constructed using tabix " <<endl;
	exit(1);	
    }


    //re-initializing variables
    needToPopulateQueue =true;
    fullQueue           =false;
    endQueue            =false;
    numberOfTimesHasDataWasCalled=0;
#ifdef DEBUG			
    cout<<"deleteRepo "<<svcfToReturn<<endl;
#endif
    delete svcfToReturn;
    svcfToReturn=0;

    
    indexInQueueOfIndels=-1;
    indexOfLastIndel=0;
    previouslyFoundIndel=false;

    while(!queueOfVCFs.empty()){
#ifdef DEBUG			
    cout<<"deleteQue "<<svcfToReturn<<endl;
#endif
	delete( queueOfVCFs.front() );
	queueOfVCFs.pop_front();
    }

    queueOfVCFs.clear();

    //if(bp
    //we need to jump a bit behind to detect CpG and indels
    int coordinatePrior=max(readAhead,1);
    rt->repositionIterator(chrName,start-coordinatePrior,end);
    

    //need to reposition the queue to the desired coord
    while(hasData()){
	SimpleVCF * current=queueOfVCFs.front();
	//SimpleVCF * current=getData();
	//cout<<current->getPosition()<<endl;
	//when the current position is found, we set the flag repoCalledHasData
	//such that hasData will return true and the first element of the queue will be returned
	if(int(current->getPosition()) >= start){
	    repoCalledHasData=true;
	    break;
	}
	current=getData();
    }
    

}
コード例 #4
0
ファイル: BiomeView.cpp プロジェクト: 1285done/cuberite
void BiomeView::reload()
{
	if (!hasData())
	{
		return;
	}
	m_Cache.reload();

	redraw();
}
コード例 #5
0
String8 AaptFile::getPrintableSource() const
{
    if (hasData()) {
        String8 name(mGroupEntry.locale.string());
        name.appendPath(mGroupEntry.vendor.string());
        name.appendPath(mPath);
        name.append(" #generated");
        return name;
    }
    return mSourceFile;
}
コード例 #6
0
ファイル: DataManager.cpp プロジェクト: nohal/qtVlm
Grib * DataManager::get_grib(int dataType,int levelType, int levelValue) {
    switch(hasData(dataType,levelType,levelValue)) {
        case GRIB_GRIB:
            return grib;
        case GRIB_CURRENT:
            return gribCurrent;
        default:
            return NULL;
    }

}
コード例 #7
0
ファイル: oc3_building_data.cpp プロジェクト: LMG/opencaesar3
void BuildingDataHolder::addData(const BuildingData &data)
{
   BuildingType buildingType = data.getType();

   if (hasData(buildingType))
   {
      THROW("Building is already set " << data.getName());
   }

   _mapDataByName.insert(std::make_pair(buildingType, data));
}
コード例 #8
0
ファイル: rf24g_2.c プロジェクト: vishl/SMS-Buzzer-Embedded
void getBuffer() 
{ 
    int8_t i; 
    for( i=0; i<BUF_MAX ; i++) { 
        RF_24G_Buffer[i] = getByte(); 
    } 
    BIT_CLEAR(RF_24G_CLK1_PORT, RF_24G_CLK1_BIT); 
    //wait for DR1 to go low
    while(hasData());
    BIT_SET(RF_24G_CE_PORT, RF_24G_CE_BIT); 
} 
コード例 #9
0
ファイル: cache.c プロジェクト: armink/EasyDataManager
/**
 * This function will add CacheData to list.
 *
 * @param cache the cache pointer
 * @param name the name of CacheData
 * @param length the value length
 * @param value the value point
 * @param valueChangedListener the changed value's callback function
 *
 * @return error code
 */
static CacheErrCode addData(pCache const cache, const char* name, uint8_t length,
        uint16_t* value, void* (*valueChangedListener)(void *arg)) {
    CacheErrCode errorCode = CACHE_NO_ERR;
    pCacheData data;
    /* lock the thread pool synchronized lock */
    cache->pool->lock(cache->pool);

    data = (pCacheData) malloc(sizeof(CacheData));
    assert(data != NULL);

    if (hasData(cache, name) != NULL) {/* the data must not exist in list */
        log_d("the name of %s data is already exist in cache data list", name);
        errorCode = CACHE_NAME_ERROR;
    } else {
        strcpy(data->name, name);
    }

    if (errorCode == CACHE_NO_ERR) {
        if (length > CACHE_LENGTH_MAX) {
            log_d("the name %s is too long,can't add to list", name);
            errorCode = CACHE_LENGTH_ERROR;
        } else {
            data->length = length;
        }
    }

    if (errorCode == CACHE_NO_ERR) {
        /* malloc data value space */
        data->value = (uint16_t*) malloc(length * sizeof(uint16_t));
        assert(data->value != NULL);
        memcpy(data->value, value, length * sizeof(uint16_t));
        data->valueChangedListener = valueChangedListener;
        data->next = NULL;
        /* if list is NULL ,then head node is equal of tail node*/
        if (cache->dataHead == NULL) {
            cache->dataHead = cache->dataTail = data;
        } else if ((cache->dataHead == cache->dataTail) /* the list has one node */
        && (cache->dataHead != NULL)) {
            cache->dataHead->next = data;
            cache->dataTail = data;
        } else { /* the list has more than one node*/
            cache->dataTail->next = data;
            cache->dataTail = data;
        }
        log_d("add %s to data list is success", name);
    } else if (errorCode != CACHE_NO_ERR) {
        free(data);
        data = NULL;
    }
    /* unlock the thread pool synchronized lock */
    cache->pool->unlock(cache->pool);
    return errorCode;
}
コード例 #10
0
void BuildingDataHolder::addData(const BuildingData &data)
{
  BuildingType buildingType = data.getType();

  if (hasData(buildingType))
  {
    StringHelper::debug( 0xff, "Building is already set %s", data.getName().c_str() );
    return;
  }

  _d->buildings.insert(std::make_pair(buildingType, data));
}
コード例 #11
0
void ProfiledState::setInputRecordedType(int input_index, RecordedType new_type) {
  AvmAssert (hasData());
  AvmAssert (input_index < input_count_);
  RecordedType previous_type = profiled_types_[input_index];

  if ((new_type != previous_type) &&
      (previous_type != kUNINITIALIZED)) {
      new_type = kVARIADIC;
  }

  profiled_types_[input_index] = new_type;
}
コード例 #12
0
ファイル: OSLineEdit.cpp プロジェクト: jtanaa/OpenStudio
void OSLineEdit2::focusInEvent(QFocusEvent * e)
{
  if (e->reason() == Qt::MouseFocusReason && m_hasClickFocus)
  {
    QString style("QLineEdit { background: #ffc627; }");
    setStyleSheet(style);

    emit inFocus(true, hasData());
  }

  QLineEdit::focusInEvent(e);
}
コード例 #13
0
ファイル: DataConnector.hpp プロジェクト: Heikman/picongpu
        /**
         * Registers a new Dataset with data and identifier id.
         *
         * If a Dataset with identifier id already exists, a runtime_error is thrown.
         * (Check with DataConnector::hasData when necessary.)
         *
         * @param data simulation data to store in the Dataset
         * @param id new identifier for the Dataset
         */
        void registerData(ISimulationData &data, uint32_t id)
        {
            if (hasData(id))
                throw std::runtime_error(getExceptionStringForID("DataConnector dataset ID already exists", id));

            Dataset::DatasetStatus status = Dataset::AUTO_INVALID;

            Dataset * dataset = new Dataset(data, status);
            datasets.mapping[id] = dataset;

            datasets.sorter->add(id);
        }
コード例 #14
0
ファイル: MemChunk.cpp プロジェクト: jmickle66666666/SLADE
/* MemChunk::fillData
 * Overwrites all data bytes with [val] (basically is memset).
 * Returns false if no data exists, true otherwise
 *******************************************************************/
bool MemChunk::fillData(uint8_t val)
{
	// Check data exists
	if (!hasData())
		return false;

	// Fill data with value
	memset(data, val, size);

	// Success
	return true;
}
コード例 #15
0
ファイル: StatusArg.cpp プロジェクト: narolez571/firebird
ISC_STATUS StatusVector::ImplStatusVector::copyTo(IStatus* dest) const throw()
{
	if (hasData())
	{
		dest->set(length() + 1u, value());
	}
	else
	{
		ISC_STATUS t[3] = {isc_arg_gds, FB_SUCCESS, isc_arg_end};
		dest->set(3, t);
	}
	return dest->get()[1];
}
コード例 #16
0
ファイル: BiomeView.cpp プロジェクト: 1285done/cuberite
void BiomeView::paintEvent(QPaintEvent * a_Event)
{
	QPainter p(this);
	if (hasData())
	{
		p.drawImage(QPoint(0, 0), m_Image);
	}
	else
	{
		p.drawText(a_Event->rect(), Qt::AlignCenter, "No chunk source selected");
	}
	p.end();
}
コード例 #17
0
ファイル: ARQ.hpp プロジェクト: freiheitsnetz/openwns-library
 virtual const CompoundPtr
 hasSomethingToSend() const
 {
     CompoundPtr it;
     if(preferACK())
     {
         it = hasACK();
         if(!it)
         {
             it = hasData();
         }
     }
     else
     {
         it = hasData();
         if(!it)
         {
             it = hasACK();
         }
     }
     return it;
 } // hasSomethingToSend()
コード例 #18
0
ファイル: MemChunk.cpp プロジェクト: jmickle66666666/SLADE
/* MemChunk::clear
 * Deletes the memory chunk.
 * Returns false if no data exists, true otherwise.
 *******************************************************************/
bool MemChunk::clear()
{
	if (hasData())
	{
		delete[] data;
		data = NULL;
		size = 0;
		cur_ptr = 0;
		return true;
	}

	return false;
}
コード例 #19
0
ファイル: StatusArg.cpp プロジェクト: RAvenGEr/opencvr
ISC_STATUS StatusVector::ImplStatusVector::copyTo(ISC_STATUS* dest) const throw()
{
    if (hasData())
    {
        fb_utils::copyStatus(dest, ISC_STATUS_LENGTH, value(), length() + 1u);
    }
    else
    {
        dest[0] = isc_arg_gds;
        dest[1] = FB_SUCCESS;
        dest[2] = isc_arg_end;
    }
    return dest[1];
}
コード例 #20
0
/**
 * Update content of texture from message
 */
bool srs_ui_but::CRosDepthTexture::convertDepth(const sensor_msgs::ImageConstPtr& raw_msg)
{
	CDepthImageConvertor::convertDepth( raw_msg );

//	std::cerr << "...Depth: Converting image. M_COUNTER: " << m_counter << std::endl;

	if( hasData() )
	{
//		std::cerr << "...Depth: Converting image..." << std::endl;
		return m_texture_converter.convert( m_depth_msg, false );
	}

	return false;
}
コード例 #21
0
ファイル: StatusArg.cpp プロジェクト: narolez571/firebird
ISC_STATUS StatusVector::ImplStatusVector::copyTo(ISC_STATUS* dest) const throw()
{
	if (hasData())
	{
		memcpy(dest, value(), (length() + 1u) * sizeof(ISC_STATUS));
	}
	else
	{
		dest[0] = isc_arg_gds;
		dest[1] = FB_SUCCESS;
		dest[2] = isc_arg_end;
	}
	return dest[1];
}
コード例 #22
0
ファイル: geometryport.cpp プロジェクト: MKLab-ITI/gnorasi
void GeometryPort::saveData(const std::string& path) const throw (VoreenException) {
    if (!hasData())
        throw VoreenException("Port is empty");
    tgtAssert(!path.empty(), "empty path");

    // append .xml if no extension specified
    std::string filename = path;
    if (tgt::FileSystem::fileExtension(filename).empty())
        filename += ".xml";

    // serialize workspace
    XmlSerializer s(filename);
    s.setUseAttributes(true);

    s.serialize("Geometry", getData());

    // write serialization data to temporary string stream
    std::ostringstream textStream;
    try {
        s.write(textStream);
        if (textStream.fail())
            throw SerializationException("Failed to write serialization data to string stream.");
    }
    catch (std::exception& e) {
        throw SerializationException("Failed to write serialization data to string stream: " + std::string(e.what()));
    }
    catch (...) {
        throw SerializationException("Failed to write serialization data to string stream (unknown exception).");
    }

    // Now we have a valid StringStream containing the serialization data.
    // => Open output file and write it to the file.
    std::fstream fileStream(filename.c_str(), std::ios_base::out);
    if (fileStream.fail())
        throw SerializationException("Failed to open file '" + filename + "' for writing.");

    try {
        fileStream << textStream.str();
    }
    catch (std::exception& e) {
        throw SerializationException("Failed to write serialization data stream to file '"
            + filename + "': " + std::string(e.what()));
    }
    catch (...) {
        throw SerializationException("Failed to write serialization data stream to file '"
            + filename + "' (unknown exception).");
    }
    fileStream.close();
}
コード例 #23
0
ファイル: YSFEcho.cpp プロジェクト: mathisschmieder/OpenDV
unsigned int CYSFEcho::readData(unsigned char* data)
{
	if (!hasData())
		return 0U;

	unsigned char len;
	m_buffer.getData(&len, 1U);

	m_buffer.getData(data, len);

	// If the FICH is valid, regenerate the sync
	if ((data[1U] & 0x01U) == 0x01U) {
		data[2U] = YSF_SYNC_BYTES[0U];
		data[3U] = YSF_SYNC_BYTES[1U];
		data[4U] = YSF_SYNC_BYTES[2U];
		data[5U] = YSF_SYNC_BYTES[3U];
		data[6U] = YSF_SYNC_BYTES[4U];
	}

	if (!hasData())
		m_timer.stop();

	return len;
}
コード例 #24
0
void Configuration::addProperty(const string &fileName, const string &key, const string &value)
{
    Data data(key,value);
    if(files.find(fileName) == files.end())
    {
        //cout << "call addsource first " << endl;
        return;
    }
    
    if(true == hasData(fileName, data))
    {
        return;
    }
    files[fileName].insert(data);
}
コード例 #25
0
ファイル: geometryport.cpp プロジェクト: MKLab-ITI/gnorasi
std::string GeometryPort::getHash() const {
    if (!hasData())
        return "";

    std::string hashes;
    std::vector<const Geometry*> geometries = getAllData();
    if (geometries.size() == 1)
        return geometries.front()->getHash();
    else {
        for (size_t i=0; i<geometries.size(); i++)
            hashes += geometries.at(i)->getHash();
        return VoreenHash::getHash(hashes);
    }

}
コード例 #26
0
ファイル: MockSupport.cpp プロジェクト: Mindtribe/cpputest
MockSupport* MockSupport::getMockSupportScope(const SimpleString& name)
{
    SimpleString mockingSupportName = MOCK_SUPPORT_SCOPE_PREFIX;
    mockingSupportName += name;

    if (hasData(mockingSupportName)) {
        STRCMP_EQUAL("MockSupport", getData(mockingSupportName).getType().asCharString());
        return (MockSupport*) getData(mockingSupportName).getObjectPointer();
    }

    MockSupport *newMock = clone(name);

    setDataObject(mockingSupportName, "MockSupport", newMock);
    return newMock;
}
コード例 #27
0
ファイル: OSComboBox.cpp プロジェクト: Anto-F/OpenStudio
void OSComboBox2::onCurrentIndexChanged(const QString & text)
{
  emit inFocus(true, hasData());

  OS_ASSERT(m_modelObject);

  if( m_choiceConcept )
  {
    std::string value = text.toStdString();

    this->blockSignals(true);
    m_choiceConcept->set(value);
    onModelObjectChanged(); // will be sure to display actual value
    this->blockSignals(false);
  }
}
コード例 #28
0
ファイル: OSLineEdit.cpp プロジェクト: jamiebull1/OpenStudio
void OSLineEdit2::onEditingFinished() {
    if(m_modelObject && m_set) {
        if (m_text != this->text().toStdString()) {
            m_text = this->text().toStdString();
            bool result = (*m_set)(m_text);
            if (!result) {
                //restore
                onModelObjectChange();
            }
            else {
                emit inFocus(true, hasData());
                adjustWidth();
            }
        }
    }
}
コード例 #29
0
ファイル: Strpack.cpp プロジェクト: vortex314/Common
Erc Strpack::unpack(bool* pv) {
    char line[10];
    int i=0;
    while (hasData() && i < 6) {
        line[i++] = read();
    }
    line[i] = '\0';
    if (strcmp(line, "true") == 0) {
        *pv = true;
        return E_OK;
    };
    if (strcmp(line, "false") == 0) {
        *pv = false;
        return E_OK;
    };
    return E_INVAL;
}
コード例 #30
0
void ODBCStatementImpl::makeInternalExtractors()
{
	if (hasData() && !extractions().size()) 
	{
		try
		{
			fillColumns();
		} catch (DataFormatException&)
		{
			if (isStoredProcedure()) return;
			throw;
		}
		
		makeExtractors(columnsReturned());
		fixupExtraction();
	}
}