bool DataSourceXMLSerializer::serializeOutProperties( const DataSource& dataSource, QXmlStreamWriter& stream )
{
    stream.writeAttribute( "DSautoFetch", dataSource.getAutoFetch() ? "1" : "0" );
    stream.writeAttribute( "DSautoFetchDelay", dataSource.getAutoFetchDelay().toString() );
    stream.writeAttribute( "DSasynchronous", dataSource.isAsynchronous() ? "1" : "0" );
    return true;
}
Example #2
0
void
ActivityView::_Refresh()
{
	bigtime_t lastTimeout = system_time() - RefreshInterval();
	BMessenger target(this);

	while (true) {
		status_t status = acquire_sem_etc(fRefreshSem, 1, B_ABSOLUTE_TIMEOUT,
			lastTimeout + RefreshInterval());
		if (status == B_OK || status == B_BAD_SEM_ID)
			break;
		if (status == B_INTERRUPTED)
			continue;

		SystemInfo info(fSystemInfoHandler);
		lastTimeout += RefreshInterval();

		fSourcesLock.Lock();

		for (uint32 i = fSources.CountItems(); i-- > 0;) {
			DataSource* source = fSources.ItemAt(i);
			DataHistory* values = fValues.ItemAt(i);

			int64 value = source->NextValue(info);
			values->AddValue(info.Time(), value);
		}

		fSourcesLock.Unlock();

		target.SendMessage(B_INVALIDATE);
	}
}
Example #3
0
//TEST(PCL_FeaturesGPU, DISABLED_fpfh_low_level)
TEST(PCL_FeaturesGPU, fpfh_low_level)
{   
    DataSource source;

    source.estimateNormals();
    source.findRadiusNeghbors();
    cout << "max_radius_nn_size: " << source.max_nn_size << endl;
                   
    vector<int> data;
    source.getNeghborsArray(data);
    vector<PointXYZ> normals_for_gpu(source.normals->points.size());    
    std::transform(source.normals->points.begin(), source.normals->points.end(), normals_for_gpu.begin(), DataSource::Normal2PointXYZ());
    
    //uploading data to GPU
    pcl::gpu::FPFHEstimation::PointCloud cloud_gpu;
    cloud_gpu.upload(source.cloud->points);

    pcl::gpu::FPFHEstimation::Normals normals_gpu;
    normals_gpu.upload(normals_for_gpu);             
    
    pcl::gpu::NeighborIndices indices;
    indices.upload(data, source.sizes, source.max_nn_size);
    
    DeviceArray2D<FPFHSignature33> fpfh33_features;
    
    gpu::FPFHEstimation fpfh_gpu;            
    fpfh_gpu.compute(cloud_gpu, normals_gpu, indices, fpfh33_features);

    int stub;
    vector<FPFHSignature33> downloaded;
    fpfh33_features.download(downloaded, stub);

    pcl::FPFHEstimation<PointXYZ, Normal, FPFHSignature33> fe;
    fe.setInputCloud (source.cloud);
    fe.setInputNormals (source.normals);
    fe.setSearchMethod (pcl::search::KdTree<PointXYZ>::Ptr (new pcl::search::KdTree<PointXYZ>));
    //fe.setKSearch (k);
    fe.setRadiusSearch (source.radius);

    PointCloud<FPFHSignature33> fpfhs;
    fe.compute (fpfhs);

    for(size_t i = 0; i < downloaded.size(); ++i)
    {
        FPFHSignature33& gpu = downloaded[i];
        FPFHSignature33& cpu = fpfhs.points[i];
        
        size_t FSize = sizeof(FPFHSignature33)/sizeof(gpu.histogram[0]);                                
        
        float norm = 0, norm_diff = 0;
        for(size_t j = 0; j < FSize; ++j)
        {
            norm_diff += (gpu.histogram[j] - cpu.histogram[j]) * (gpu.histogram[j] - cpu.histogram[j]);
            norm += cpu.histogram[j] * cpu.histogram[j];

            //ASSERT_NEAR(gpu.histogram[j], cpu.histogram[j], 0.03f);
        }
        ASSERT_EQ(norm_diff/norm < 0.01f/FSize, true);
    }
}
Example #4
0
void clearDataSource(DataSource& _source, bool _data, bool _tiles) {
    if (!m_tileManager) { return; }
    std::lock_guard<std::mutex> lock(m_tilesMutex);

    if (_tiles) { m_tileManager->clearTileSet(_source.id()); }
    if (_data) { _source.clearData(); }

    requestRender();
}
Example #5
0
/*
* Write the contents of a DataSource into a Pipe
*/
void Pipe::write(DataSource& source)
   {
   SecureVector<byte> buffer(DEFAULT_BUFFERSIZE);
   while(!source.end_of_data())
      {
      size_t got = source.read(&buffer[0], buffer.size());
      write(&buffer[0], got);
      }
   }
Example #6
0
//TEST(PCL_FeaturesGPU, DISABLED_ppf)
TEST(PCL_FeaturesGPU, ppf)
{   
    DataSource source;

    source.generateIndices();
    source.estimateNormals();
                   
    vector<PointXYZ> normals_for_gpu(source.normals->points.size());    
    std::transform(source.normals->points.begin(), source.normals->points.end(), normals_for_gpu.begin(), DataSource::Normal2PointXYZ());
    
    //uploading data to GPU

    //////////////////////////////////////////////////////////////////////////////////////////////  

    pcl::gpu::PPFEstimation::PointCloud cloud_gpu;
    cloud_gpu.upload(source.cloud->points);

    pcl::gpu::PPFEstimation::Normals normals_gpu;
    normals_gpu.upload(normals_for_gpu);             

    pcl::gpu::PPFEstimation::Indices indices_gpu;
    indices_gpu.upload(*source.indices);

    DeviceArray<PPFSignature> ppf_features;
    
    gpu::PPFEstimation pph_gpu;    
    pph_gpu.setInputCloud(cloud_gpu);
    pph_gpu.setInputNormals(normals_gpu);
    pph_gpu.setIndices(indices_gpu);
    pph_gpu.compute(ppf_features);


    vector<PPFSignature> downloaded;
    ppf_features.download(downloaded);

    pcl::PPFEstimation<PointXYZ, Normal, PPFSignature> fe;
    fe.setInputCloud (source.cloud);
    fe.setInputNormals (source.normals);
    fe.setIndices(source.indices);

    PointCloud<PPFSignature> ppfs;
    fe.compute (ppfs);

    for(size_t i = 0; i < downloaded.size(); ++i)
    {
        PPFSignature& gpu = downloaded[i];
        PPFSignature& cpu = ppfs.points[i];        

        ASSERT_NEAR(gpu.f1, cpu.f1, 0.01f);
        ASSERT_NEAR(gpu.f2, cpu.f2, 0.01f);
        ASSERT_NEAR(gpu.f3, cpu.f3, 0.01f);
        ASSERT_NEAR(gpu.f4, cpu.f4, 0.01f);
        ASSERT_NEAR(gpu.alpha_m, cpu.alpha_m, 0.01f);              
    }
}
Example #7
0
/*
 * Disasm memory reader callback
 */
static int disReadMemory(bfd_vma memaddr, bfd_byte *myaddr, unsigned int len,
	struct disassemble_info *info) {

	DataSource *ds = ((DisasmAppData *)info->application_data)->ds;
	if (memaddr + len <= ds->size()) {
		ds->readBytes((char *)myaddr, len, memaddr);
		return 0;
	} else {
		return -1;
	}
}
Example #8
0
void
Decoder::decodeNestedTemplate(
   DataSource & source,
   Messages::ValueMessageBuilder & messageBuilder,
   Messages::FieldIdentityCPtr & identity)
{
  Codecs::PresenceMap pmap(getTemplateRegistry()->presenceMapBits());
  if(this->verboseOut_)
  {
    pmap.setVerbose(verboseOut_);
  }

  static const std::string pmp("PMAP");
  source.beginField(pmp);
  pmap.decode(source);

  static const std::string tid("templateID");
  source.beginField(tid);
  if(pmap.checkNextField())
  {
    template_id_t id;
    FieldInstruction::decodeUnsignedInteger(source, *this, id, tid);
    setTemplateId(id);
  }
  if(verboseOut_)
  {
    (*verboseOut_) << "Nested Template ID: " << getTemplateId() << std::endl;
  }
  Codecs::TemplateCPtr templatePtr;
  if(getTemplateRegistry()->getTemplate(getTemplateId(), templatePtr))
  {
    if(templatePtr->getReset())
    {
      reset(false);
    }
    Messages::ValueMessageBuilder & groupBuilder(
      messageBuilder.startGroup(
        identity,
        templatePtr->getApplicationType(),
        templatePtr->getApplicationTypeNamespace(),
        templatePtr->fieldCount()));

    decodeSegmentBody(source, pmap, templatePtr, groupBuilder);
    messageBuilder.endGroup(identity, groupBuilder);
  }
  else
  {
    std::string error =  "Unknown template ID:";
    error += boost::lexical_cast<std::string>(getTemplateId());
    reportError("[ERR D9]", error);
  }
  return;
}
		bool Parser::readPoint( DataSource& dataSource, Byte* point, Size pointSize )
		{
			Size readLength = min( pointSize, (Size)m_header.pointRecordLength );
			//if( m_header.pointRecordLength > pointSize )
			//	return assert(false), false; //< TODO: error reporting
			
			dataSource->read( (Byte*)point, readLength );			
			if ( readLength < m_header.pointRecordLength )
				dataSource->ignore( m_header.pointRecordLength-readLength ); //, Ignore the rest of this points data!

			return dataSource.valid();
		}
Example #10
0
    bool load( const CacheId& cacheId, DataSource& dataSource )
    {
        const DataType dataType = dataSource.getVolumeInfo().dataType;
        if( dataType == DT_UNDEFINED )
            LBTHROW( std::runtime_error( "Undefined data type" ));

        const NodeId nodeId( cacheId );
        _data = dataSource.getData( nodeId );
        if( !_data )
            return false;
        return true;
    }
Example #11
0
void TermMgrModel::recData()
{
	json::Value jsonModleData;
	QString sValue;
	DataSource dataSorce;
	dataSorce.query(e_Term_Data, sValue);
	if (sValue.size())
	{
		jsonModleData = json::Deserialize(sValue.toStdString());
	}
	if (json::ArrayVal != jsonModleData.GetType())
	{
		json::Array jArray;
		json::Object jObject;
		jObject["id"] = QUuid::createUuid().toString().mid(1, 36).toStdString();
		jObject["orgid"] = "";
		jObject["merchno"] = "440380310000001";
		jObject["termno"] = "10023496";
		jObject["termkey"] = "1234567890abcdef1234567890abcdef";
		jObject["termkeylen"] = 32;
		jObject["date"] = "2015-12-07";
		jArray.push_back(jObject);

		jObject["id"] = QUuid::createUuid().toString().mid(1, 36).toStdString();
		jObject["orgid"] = "";
		jObject["merchno"] = "440380310000002";
		jObject["termno"] = "10023497";
		jObject["termkey"] = "1234567890abcdef1234567890abcdef";
		jObject["termkeylen"] = 32;
		jObject["date"] = "2015-12-07";
		jArray.push_back(jObject);
		jsonModleData = jArray;
	}
	listData.clear();
	if (json::NULLVal != jsonModleData.GetType() && 0 < jsonModleData.size())
	{
		int i = 0;
		for ( ; i < jsonModleData.size(); i++)
		{
			listData.push_back(TERMDATA());
			if (jsonModleData[i].HasKey("id")) listData[i].sId = QString(jsonModleData[i]["id"].ToString().c_str());
			if (jsonModleData[i].HasKey("orgid")) listData[i].sOrgid = QString(jsonModleData[i]["orgid"].ToString().c_str());
			if (jsonModleData[i].HasKey("merchno")) listData[i].sMerchno = QString(jsonModleData[i]["merchno"].ToString().c_str());
			if (jsonModleData[i].HasKey("termno")) listData[i].sTermno = QString(jsonModleData[i]["termno"].ToString().c_str());
			if (jsonModleData[i].HasKey("termkey")) listData[i].sTermkey = QString(jsonModleData[i]["termkey"].ToString().c_str());
			if (jsonModleData[i].HasKey("termkeylen")) listData[i].nTermkeylen = jsonModleData[i]["termkeylen"].ToInt();
			if (jsonModleData[i].HasKey("date")) listData[i].sDate = QString(jsonModleData[i]["date"].ToString().c_str());
			
		}		
	}
	refreshModel();
}
Example #12
0
DataSource*
ActivityView::FindDataSource(const DataSource* search)
{
	BAutolock _(fSourcesLock);

	for (int32 i = fSources.CountItems(); i-- > 0;) {
		DataSource* source = fSources.ItemAt(i);
		if (!strcmp(source->Name(), search->Name()))
			return source;
	}

	return NULL;
}
/*
* Do heuristic tests for BER data
*/
bool maybe_BER(DataSource& source)
   {
   uint8_t first_u8;
   if(!source.peek_byte(first_u8))
      {
      BOTAN_ASSERT_EQUAL(source.read_byte(first_u8), 0, "Expected EOF");
      throw Stream_IO_Error("ASN1::maybe_BER: Source was empty");
      }

   if(first_u8 == (SEQUENCE | CONSTRUCTED))
      return true;
   return false;
   }
Example #14
0
void TileWorker::processTileData(std::unique_ptr<TileTask> _task,
                                 const std::vector<std::unique_ptr<Style>>& _styles,
                                 const View& _view) {

    m_task = std::move(_task);
    m_free = false;
    m_finished = false;
    m_aborted = false;

    m_future = std::async(std::launch::async, [&]() {
        
        const TileID& tileID = m_task->tileID;
        DataSource* dataSource = m_task->source;
        
        auto tile = std::shared_ptr<MapTile>(new MapTile(tileID, _view.getMapProjection()));

        std::shared_ptr<TileData> tileData;

        if (m_task->parsedTileData) {
            // Data has already been parsed!
            tileData = m_task->parsedTileData;
        } else {
            // Data needs to be parsed
            tileData = dataSource->parse(*tile, m_task->rawTileData);

            // Cache parsed data with the original data source
            dataSource->setTileData(tileID, tileData);
        }
        
		tile->update(0, _view);

        //Process data for all styles
        for(const auto& style : _styles) {
            if(m_aborted) {
                m_finished = true;
                return std::move(tile);
            }
            if(tileData) {
                style->addData(*tileData, *tile, _view.getMapProjection());
            }
        }
        m_finished = true;
        
        requestRender();
        
        // Return finished tile
        return std::move(tile);

    });

}
bool DataSourceXMLSerializer::serializeInProperties( DataSource& dataSource, QXmlStreamReader& stream )
{
    bool error( false );
    bool dsAutoFetch = ( stream.attributes().value( "DSautoFetch" ).toInt( &error ) == 1 );
    if ( !error )
        dataSource.setAutoFetch( dsAutoFetch );
    QTime dsAutoFetchDelay = ( QTime::fromString( stream.attributes().value( "DSautoFetchDelay" ).toString( ) ) );
    if ( dsAutoFetchDelay.isValid() )
        dataSource.setAutoFetchDelay( dsAutoFetchDelay );
    bool dsAsynchronous = ( stream.attributes().value( "DSasynchronous" ).toInt( &error ) == 1 );
    if ( !error )
        dataSource.setAsynchronous( dsAsynchronous );
    return true;
}
Example #16
0
/*****************************************************************************
 * FindGRIBMsg() -- Review 12/2002
 *
 * Arthur Taylor / MDL
 *
 * PURPOSE
 *   Jumps through a GRIB2 file looking for a specific message.  Currently
 * that message is determined by msgNum which is in the range of 1..n.
 *   In the future we may be searching based on projection or date.
 *
 * ARGUMENTS
 *      fp = The current GRIB2 file to look through. (Input)
 *  msgNum = Which message to look for. (Input)
 *  offset = Where in the file the message starts (this is before the
 *           wmo ASCII part if there is one.) (Output)
 *  curMsg = The current # of messages we have looked through. (In/Out) 
 *
 * FILES/DATABASES:
 *   An already opened "GRIB2" File
 *
 * RETURNS: int (could use errSprintf())
 *  0 = OK
 * -1 = Problems reading Section 0.
 * -2 = Ran out of file.
 *
 * HISTORY
 *  11/2002 Arthur Taylor (MDL/RSIS): Created.
 *  12/2002 (TK,AC,TB,&MS): Code Review.
 *   6/2003 Matthew T. Kallio ([email protected]):
 *          "wmo" dimension increased to WMO_HEADER_LEN + 1 (for '\0' char)
 *   8/2003 AAT: Removed dependence on offset and fileLen.
 *
 * NOTES
 *****************************************************************************
 */
int FindGRIBMsg (DataSource &fp, int msgNum, sInt4 *offset, int *curMsg)
{
   int cnt;             /* The current message we are looking at. */
   char *buff;          /* Holds the info between records. */
   uInt4 buffLen;       /* Length of info between records. */
   sInt4 sect0[SECT0LEN_WORD]; /* Holds the current Section 0. */
   uInt4 gribLen;       /* Length of the current GRIB message. */
   int version;         /* Which version of GRIB is in this message. */
   int c;               /* Determine if end of the file without fileLen. */
   sInt4 jump;          /* How far to jump to get to past GRIB message. */

   cnt = *curMsg + 1;
   buff = NULL;
   buffLen = 0;
   while ((c = fp.DataSourceFgetc()) != EOF) {
      fp.DataSourceUngetc(c);
      if (cnt >= msgNum) {
         /* 12/1/2004 version 1.63 forgot to free buff */
         free (buff);
         *curMsg = cnt;
         return 0;
      }
      /* Read section 0 to find gribLen and wmoLen. */
      if (ReadSECT0 (fp, &buff, &buffLen, GRIB_LIMIT, sect0, &gribLen,
                     &version) < 0) {
         preErrSprintf ("Inside FindGRIBMsg\n");
         free (buff);
         return -1;
      }
      myAssert ((version == 1) || (version == 2) || (version == -1));
      /* Continue on to the next grib message. */
      if ((version == 1) || (version == -1)) {
         jump = gribLen - 8;
      } else {
         jump = gribLen - 16;
      }
      fp.DataSourceFseek(jump, SEEK_CUR);
      *offset = *offset + gribLen + buffLen;
      cnt++;
   }
   free (buff);
   *curMsg = cnt - 1;
   /* Return -2 since we reached the end of file. This may not be an error
    * (multiple file option). */
   return -2;
/*
   errSprintf ("ERROR: Ran out of file looking for msgNum %d.\n", msgNum);
   errSprintf ("       Current msgNum %d\n", cnt);
*/
}
Example #17
0
    bool loadTextureToGPU(const LODNode& lodNode, const DataSource& dataSource,
                          const TexturePool& texturePool,
                          const ConstDataObjectPtr& data) const
    {
#ifdef LIVRE_DEBUG_RENDERING
        std::cout << "Upload " << lodNode.getNodeId().getLevel() << ' '
                  << lodNode.getRelativePosition() << " to "
                  << _textureState.textureId << std::endl;
#endif
        const Vector3ui& overlap = dataSource.getVolumeInfo().overlap;
        const Vector3ui& voxSizeVec = lodNode.getBlockSize() + overlap * 2;
        _textureState.bind();

        glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, voxSizeVec[0], voxSizeVec[1],
                        voxSizeVec[2], texturePool.getFormat(),
                        texturePool.getTextureType(), data->getDataPtr());

        const GLenum glErr = glGetError();
        if (glErr != GL_NO_ERROR)
        {
            LBERROR << "Error loading the texture into GPU, error number : "
                    << glErr << std::endl;
            return false;
        }

        return true;
    }
 SendStatus get() const {
     try {
         // only try to collect if we didn't do so before:
         if ( mss != SendSuccess ) {
             corba::CAnyArguments_var nargs;
             if ( misblocking->get() ) {
                 mss = SendStatus( static_cast<int>(msh->collect( nargs.out() ) ) - 1 );
             } else {
                 mss = SendStatus( static_cast<int>(msh->collectIfDone( nargs.out() ) ) - 1 );
             }
             // only convert results when we got a success:
             if (mss == SendSuccess) {
                 assert( nargs->length() ==  margs.size() );
                 for (size_t i=0; i < margs.size(); ++i ) {
                     const types::TypeInfo* ti = margs[i]->getTypeInfo();
                     CorbaTypeTransporter* ctt = dynamic_cast<CorbaTypeTransporter*>( ti->getProtocol(ORO_CORBA_PROTOCOL_ID) );
                     assert( ctt );
                     ctt->updateFromAny( &nargs[i], margs[i] );
                 }
             }
         }
         return mss;
     }  catch ( corba::CWrongNumbArgException& ) {
         return mss;
     } catch ( corba::CWrongTypeArgException& ) {
         return mss;
     }
 }
 typename DataSource<T>::result_t value() const
 {
     unsigned int i = mindex->get();
     if (i >= mmax)
         return internal::NA<T>::na();
     return mref[ i ];
 }
 typename AssignableDataSource<T>::const_reference_t rvalue() const
 {
     unsigned int i = mindex->get();
     if (i >= mmax)
         return internal::NA<typename AssignableDataSource<T>::const_reference_t>::na();
     return mref[ i ];
 }
Example #21
0
//TEST(PCL_FeaturesGPU, DISABLED_normals_lowlevel)
TEST(PCL_FeaturesGPU, normals_lowlevel)
{       
    DataSource source;
    cout << "Cloud size: " << source.cloud->points.size() << endl;
    cout << "Radius: " << source.radius << endl;
    cout << "K: " << source.k << endl;

    //source.runCloudViewer();

    source.estimateNormals();
    source.findKNNeghbors();    

    gpu::NormalEstimation::PointCloud cloud;    
    cloud.upload(source.cloud->points);

    // convert to single array format
    vector<int> neighbors_all(source.max_nn_size * cloud.size());
    PtrStep<int> ps(&neighbors_all[0], source.max_nn_size * PtrStep<int>::elem_size);    
    for(size_t i = 0; i < cloud.size(); ++i)
        copy(source.neighbors_all[i].begin(), source.neighbors_all[i].end(), ps.ptr(i));

    NeighborIndices indices;
    indices.upload(neighbors_all, source.sizes, source.max_nn_size);

    gpu::NormalEstimation::Normals normals;
    gpu::NormalEstimation::computeNormals(cloud, indices, normals);
    gpu::NormalEstimation::flipNormalTowardsViewpoint(cloud, 0.f, 0.f, 0.f, normals);

    vector<PointXYZ> downloaded;
    normals.download(downloaded);

    for(size_t i = 0; i < downloaded.size(); ++i)
    {
        Normal n = source.normals->points[i];

        PointXYZ xyz = downloaded[i];
        float curvature = xyz.data[3];               

        float abs_error = 0.01f;
        ASSERT_NEAR(n.normal_x, xyz.x, abs_error);
        ASSERT_NEAR(n.normal_y, xyz.y, abs_error);
        ASSERT_NEAR(n.normal_z, xyz.z, abs_error);

        float abs_error_curv = 0.01f;
        ASSERT_NEAR(n.curvature, curvature, abs_error_curv);
    }
}
 void set( typename AssignableDataSource<T>::param_t t )
 {
     unsigned int i = mindex->get();
     if (i >= mmax)
         return;
     mref[ i ] = t;
     updated();
 }
Example #23
0
bool ResultMatches(DataSource const & dataSource, shared_ptr<MatchingRule> rule,
                   search::Result const & result)
{
  bool matches = false;
  dataSource.ReadFeature([&](FeatureType & ft) { matches = rule->Matches(ft); },
                         result.GetFeatureID());
  return matches;
}
Example #24
0
    void initialize(const uint64_t cacheId, const DataSource& dataSource,
                    const TexturePool& texturePool,
                    const ConstDataObjectPtr& data)
    {
        // TODO: The internal format size should be calculated correctly
        const Vector3f& overlap = dataSource.getVolumeInfo().overlap;
        const LODNode& lodNode = dataSource.getNode(NodeId(cacheId));
        const Vector3f& size = lodNode.getVoxelBox().getSize();
        const Vector3f& maxSize = dataSource.getVolumeInfo().maximumBlockSize;
        const Vector3f& overlapf = overlap / maxSize;
        _textureState.textureCoordsMax = overlapf + size / maxSize;
        _textureState.textureCoordsMin = overlapf;
        _textureState.textureSize =
            _textureState.textureCoordsMax - _textureState.textureCoordsMin;

        loadTextureToGPU(lodNode, dataSource, texturePool, data);
    }
Example #25
0
void HexDoc::Serialize(THSIZE nOffset, THSIZE nSize, uint8 *target)
{
    SerialDataHeader &hdr = *(SerialDataHeader*)target;
    int sOffset = sizeof(hdr);
    hdr.endianMode = NATIVE_ENDIAN_MODE;
    hdr.nSegments = 0;
    hdr.nSources = 0;

    std::vector<DataSource*> sources;
    std::vector<DataSource*>::const_iterator iter;

    THSIZE segStart;
    Segment *ts = GetSegment(nOffset, &segStart);
    THSIZE segOffset = nOffset - segStart;
    while (ts != NULL && segStart < nOffset + nSize)
    {
        hdr.nSegments++;
        int nSource = 0;
        if (ts->pDS)
        {
            iter = std::find(sources.begin(), sources.end(), ts->pDS);
            if (iter == sources.end())
            {
                sources.push_back(ts->pDS);
                hdr.nSources++;
            }
        }
        THSIZE copySize = min(nOffset + nSize, segStart + ts->size) - (segStart + segOffset);
        int sSize = ts->GetSerializedLength(segOffset, copySize);
        ts->Serialize(segOffset, copySize, nSource, target + sOffset);
        sOffset += sSize;
        segStart += ts->size;
        segOffset = 0;
        ts = ts->next;
    }

    for (iter = sources.begin(); iter < sources.end(); iter++)
    {
        DataSource *pDS = *iter;
        int sSize = pDS->GetSerializedLength();
        pDS->Serialize(target + sOffset);
        sOffset += sSize;
    }
}
 value_t get() const
 {
     // put the member's object as first since SequenceFactory does not know about the OperationCallerBase type.
     if (isblocking->get())
         ss = bf::invoke(&SendHandle<Signature>::CBase::collect, SequenceFactory::data(args));
     else
         ss = bf::invoke(&SendHandle<Signature>::CBase::collectIfDone, SequenceFactory::data(args));
     SequenceFactory::update(args);
     return ss;
 }
            virtual ArrayPartDataSource<T>* copy( std::map<const base::DataSourceBase*, base::DataSourceBase*>& replace ) const {
                // if somehow a copy exists, return the copy, otherwise return this (see Attribute copy)
                if ( replace[this] != 0 ) {
                    assert ( dynamic_cast<ArrayPartDataSource<T>*>( replace[this] ) == static_cast<ArrayPartDataSource<T>*>( replace[this] ) );
                    return static_cast<ArrayPartDataSource<T>*>( replace[this] );
                }
                replace[this] = new ArrayPartDataSource<T>(*mref, mindex->copy(replace), mparent->copy(replace), mmax);
                return static_cast<ArrayPartDataSource<T>*>(replace[this]);

            }
Example #28
0
/*
* Do heuristic tests for BER data
*/
bool maybe_BER(DataSource& source)
   {
   byte first_byte;
   if(!source.peek_byte(first_byte))
      throw Stream_IO_Error("ASN1::maybe_BER: Source was empty");

   if(first_byte == (SEQUENCE | CONSTRUCTED))
      return true;
   return false;
   }
Example #29
0
status_t
ActivityView::SaveState(BMessage& state) const
{
	status_t status = state.AddBool("show legend", fShowLegend);
	if (status != B_OK)
		return status;

	status = state.AddInt64("refresh interval", fRefreshInterval);
	if (status != B_OK)
		return status;

	status = state.AddData("history background color", B_RGB_COLOR_TYPE,
		&fHistoryBackgroundColor, sizeof(rgb_color));
	if (status != B_OK)
		return status;

	for (int32 i = 0; i < fSources.CountItems(); i++) {
		DataSource* source = fSources.ItemAt(i);

		if (!source->PerCPU() || source->CPU() == 0)
			status = state.AddString("source", source->InternalName());
		if (status != B_OK)
			return status;

		BString name = source->Name();
		name << " color";
		rgb_color color = source->Color();
		state.AddData(name.String(), B_RGB_COLOR_TYPE, &color,
			sizeof(rgb_color));
	}
	return B_OK;
}
Example #30
0
/*****************************************************************************
 * GRIB2SectJump() --
 *
 * Arthur Taylor / MDL
 *
 * PURPOSE
 *    To jump past a GRIB2 section.  Reads in secLen and checks that the
 * section is valid.
 *
 * ARGUMENTS
 *      fp = Opened file pointing to the section in question. (Input/Output)
 * gribLen = The total length of the grib message. (Input)
 *    sect = Which section we think we are reading.
 *           If it is -1, then set it to the section the file says we are
 *           reading (useful for optional sect 2)) (Input/Output).
 *  secLen = The length of this section (Output)
 *
 * FILES/DATABASES:
 *    An already opened GRIB2 file pointer, already at section in question.
 *
 * RETURNS: int (could use errSprintf())
 *  0 = Ok.
 * -1 = Ran out of file.
 * -2 = Section was miss-labeled.
 *
 * HISTORY
 *   3/2003 Arthur Taylor (MDL/RSIS): Created.
 *   8/2003 AAT: Removed dependence on curTot, which was used to compute if
 *          the file should be large enough for the fseek, but didn't check
 *          if it actually was.
 *
 * NOTES
 *   May want to put this in degrib2.c
 *****************************************************************************
 */
static int GRIB2SectJump (DataSource &fp,
                          CPL_UNUSED sInt4 gribLen, sChar *sect, uInt4 *secLen)
{
   char sectNum;        /* Validates that we are on the correct section. */
   int c;               /* Check that the fseek is still inside the file. */

   if (FREAD_BIG (secLen, sizeof (sInt4), 1, fp) != 1) {
      if (*sect != -1) {
         errSprintf ("ERROR: Ran out of file in Section %d\n", *sect);
      } else {
         errSprintf ("ERROR: Ran out of file in GRIB2SectSkip\n");
      }
      return -1;
   }
   if (fp.DataSourceFread (&sectNum, sizeof (char), 1) != 1) {
      if (*sect != -1) {
         errSprintf ("ERROR: Ran out of file in Section %d\n", *sect);
      } else {
         errSprintf ("ERROR: Ran out of file in GRIB2SectSkip\n");
      }
      return -1;
   }
   if (*sect == -1) {
      *sect = sectNum;
   } else if (sectNum != *sect) {
       errSprintf ("ERROR: Section %d mislabeled\n", *sect);
       return -2;
   }
   /* Since fseek does not give an error if we jump outside the file, we test
    * it by using fgetc / ungetc. */
   fp.DataSourceFseek (*secLen - 5, SEEK_CUR);
   if ((c = fp.DataSourceFgetc()) == EOF) {
       errSprintf ("ERROR: Ran out of file in Section %d\n", *sect);
       return -1;
   } else {
       fp.DataSourceUngetc(c);
   }
   return 0;
}