本文整理汇总了C++中SharedArray类的典型用法代码示例。如果您正苦于以下问题:C++ SharedArray类的具体用法?C++ SharedArray怎么用?C++ SharedArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SharedArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runOpenPanel
void ChromeClientBlackBerry::runOpenPanel(WebCore::Frame*, WTF::PassRefPtr<WebCore::FileChooser> chooser)
{
SharedArray<WebString> initialFiles;
unsigned int initialFileSize = chooser->filenames().size();
if (initialFileSize > 0)
initialFiles.reset(new WebString[initialFileSize]);
for (unsigned i = 0; i < initialFileSize; ++i)
initialFiles[i] = chooser->filenames()[i];
SharedArray<WebString> chosenFiles;
unsigned int chosenFileSize;
{
PageGroupLoadDeferrer deferrer(m_webPage->d->m_page, true);
TimerBase::fireTimersInNestedEventLoop();
if (!m_webPage->client()->chooseFilenames(chooser->allowsMultipleFiles(), chooser->acceptTypes(), initialFiles, initialFileSize, chosenFiles, chosenFileSize))
return;
}
Vector<WTF::String> files(chosenFileSize);
for (unsigned i = 0; i < chosenFileSize; ++i)
files[i] = chosenFiles[i];
chooser->chooseFiles(files);
}
示例2: runOpenPanel
void ChromeClientBlackBerry::runOpenPanel(Frame*, PassRefPtr<FileChooser> chooser)
{
SharedArray<WebString> initialFiles;
unsigned int initialFileSize = chooser->settings().selectedFiles.size();
if (initialFileSize > 0)
initialFiles.reset(new WebString[initialFileSize]);
for (unsigned i = 0; i < initialFileSize; ++i)
initialFiles[i] = chooser->settings().selectedFiles[i];
SharedArray<WebString> chosenFiles;
unsigned int chosenFileSize;
{
PageGroupLoadDeferrer deferrer(m_webPagePrivate->m_page, true);
TimerBase::fireTimersInNestedEventLoop();
// FIXME: Use chooser->settings().acceptMIMETypes instead of WebString() for the second parameter.
if (!m_webPagePrivate->m_client->chooseFilenames(chooser->settings().allowsMultipleFiles, WebString(), initialFiles, initialFileSize, chosenFiles, chosenFileSize))
return;
}
Vector<String> files(chosenFileSize);
for (unsigned i = 0; i < chosenFileSize; ++i)
files[i] = chosenFiles[i];
chooser->chooseFiles(files);
}
示例3: loadBspDirEntry
bool BspSceneFile::loadBspDirEntry(std::istream& bspStream, const Q3Bsp::DirEntry& entry, SharedArray<uint8_t>::Type& outData) {
if (!bspStream.seekg(entry.offset, std::ios::beg)) {
return false;
}
outData.reset(new uint8_t[entry.length]);
if (!bspStream.read(reinterpret_cast<char*>(outData.get()), entry.length)) {
return false;
}
return true;
}
示例4: updateCamPosition
void RendererService::updateCamPosition(SharedArray positionValue,
SharedArray focalValue,
SharedArray viewUpValue)
{
vtkCamera* camera = m_render->GetActiveCamera();
camera->SetPosition(positionValue.get());
camera->SetFocalPoint(focalValue.get());
camera->SetViewUp(viewUpValue.get());
camera->SetClippingRange(0.1, 1000000);
m_interactorManager->getInteractor()->Render();
}
示例5: ArgumentSizeMismatch
inline ExecStatus
Weights<View>::post(Home home, const SharedArray<int>& elements,
const SharedArray<int>& weights,
View x, Gecode::Int::IntView y) {
if (elements.size() != weights.size())
throw ArgumentSizeMismatch("Weights");
Region r(home);
int* els_arr = r.alloc<int>(elements.size());
for (int i=elements.size(); i--;)
els_arr[i] = elements[i];
IntSet els(els_arr, elements.size());
IntSetRanges er(els);
GECODE_ME_CHECK(x.intersectI(home, er));
(void) new (home) Weights(home,elements,weights,x,y);
return ES_OK;
}
示例6: loadSTLFromStream
bool Model::loadSTLFromStream(std::fstream &file, SharedArray vertexArray, SharedArray normalsArray)
{
int bufferSize = 80;
char buffer[bufferSize];
if (file.readsome(buffer, bufferSize * sizeof(char)) != bufferSize) {
return false;
}
unsigned int numberOfTriangles = 0;
if (file.readsome((char *)&numberOfTriangles, sizeof(unsigned int)) != sizeof(unsigned int)) {
return false;
}
vertexArray->resize(numberOfTriangles*9);
normalsArray->resize(numberOfTriangles*3);
STLTriangle triangle;
for(unsigned int i = 0; i < numberOfTriangles; i++){
if(file.readsome((char *)&triangle.normal, sizeof(float)*3) != sizeof(float)*3){
return false;
}
if(file.readsome((char *)&triangle.vertex, sizeof(float)*9) != sizeof(float)*9){
return false;
}
if(file.readsome((char *)&triangle.attribute, sizeof(unsigned short)) != sizeof(unsigned short)){
return false;
}
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
vertexArray->push_back(triangle.vertex[i][j]);
}
normalsArray->push_back(triangle.normal[i]);
}
}
}
示例7: SharedArray
void RendererService::notifyCamPositionUpdated()
{
vtkCamera* camera = m_render->GetActiveCamera();
SharedArray position = SharedArray(new double[3]);
SharedArray focal = SharedArray(new double[3]);
SharedArray viewUp = SharedArray(new double[3]);
std::copy(camera->GetPosition(), camera->GetPosition()+3, position.get());
std::copy(camera->GetFocalPoint(), camera->GetFocalPoint()+3, focal.get());
std::copy(camera->GetViewUp(), camera->GetViewUp()+3, viewUp.get());
fwServicesBlockAndNotifyMacro( this->getLightID(), m_sigCamUpdated,
(position, focal, viewUp),
m_slotUpdateCamPosition );
}
示例8: ENABLE
void ChromeClientBlackBerry::runOpenPanel(Frame*, PassRefPtr<FileChooser> chooser)
{
SharedArray<BlackBerry::Platform::String> initialFiles;
unsigned numberOfInitialFiles = chooser->settings().selectedFiles.size();
if (numberOfInitialFiles > 0)
initialFiles.reset(new BlackBerry::Platform::String[numberOfInitialFiles], numberOfInitialFiles);
for (unsigned i = 0; i < numberOfInitialFiles; ++i)
initialFiles[i] = chooser->settings().selectedFiles[i];
SharedArray<BlackBerry::Platform::String> acceptMIMETypes;
unsigned numberOfTypes = chooser->settings().acceptMIMETypes.size();
if (numberOfTypes > 0)
acceptMIMETypes.reset(new BlackBerry::Platform::String[numberOfTypes], numberOfTypes);
for (unsigned i = 0; i < numberOfTypes; ++i)
acceptMIMETypes[i] = chooser->settings().acceptMIMETypes[i];
BlackBerry::Platform::String capture;
#if ENABLE(MEDIA_CAPTURE)
capture = chooser->settings().capture;
#endif
SharedArray<BlackBerry::Platform::String> chosenFiles;
{
PageGroupLoadDeferrer deferrer(m_webPagePrivate->m_page, true);
TimerBase::fireTimersInNestedEventLoop();
if (!m_webPagePrivate->m_client->chooseFilenames(chooser->settings().allowsMultipleFiles, acceptMIMETypes, initialFiles, capture, chosenFiles))
return;
}
Vector<String> files(chosenFiles.length());
for (unsigned i = 0; i < chosenFiles.length(); ++i)
files[i] = chosenFiles[i];
chooser->chooseFiles(files);
}
示例9: webHistoryItemCount
size_t TestRunner::webHistoryItemCount()
{
SharedArray<BlackBerry::WebKit::WebPage::BackForwardEntry> backForwardList;
BlackBerry::WebKit::DumpRenderTree::currentInstance()->page()->getBackForwardList(backForwardList);
return backForwardList.length();
}
示例10:
forceinline
FloatValArgs::FloatValArgs(const SharedArray<FloatVal>& x)
: PrimArgArray<FloatVal>(x.size()) {
for (int i=x.size(); i--;)
a[i] = x[i];
}
示例11:
forceinline
IntArgs::IntArgs(const SharedArray<int>& x)
: PrimArgArray<int>(x.size()) {
for (int i=x.size(); i--;)
a[i] = x[i];
}
示例12: basicSample
void basicSample()
{
poco_assert( UDT_use_count == 0 ); // reality check
// test shared_array with a built-in type
char * cap = new char [ 100 ];
SharedArray<char> ca ( cap );
poco_assert( ca.get() == cap );
poco_assert( cap == ca.get() );
poco_assert( &ca[0] == cap );
strcpy( ca.get(), "Hot Dog with mustard and relish" );
poco_assert( strcmp( ca.get(), "Hot Dog with mustard and relish" ) == 0 );
poco_assert( strcmp( cap, "Hot Dog with mustard and relish" ) == 0 );
poco_assert( ca[0] == 'H' );
poco_assert( ca[30] == 'h' );
SharedArray<char> ca2 ( ca );
SharedArray<char> ca3 ( ca2 );
ca[0] = 'N';
ca[4] = 'd';
poco_assert( strcmp( ca.get(), "Not dog with mustard and relish" ) == 0 );
poco_assert( strcmp( ca2.get(), "Not dog with mustard and relish" ) == 0 );
poco_assert( strcmp( ca3.get(), "Not dog with mustard and relish" ) == 0 );
ca2.reset();
ca.reset();
poco_assert( ca.get() == 0 );
SharedArray<char> ca4;
swap( ca3, ca4 );
poco_assert( strcmp( ca4.get(), "Not dog with mustard and relish" ) == 0 );
poco_assert( ca3.get() == 0 );
std::set< SharedArray<char> > sca;
sca.insert(ca4);
poco_assert( sca.find(ca4) != sca.end() );
poco_assert( sca.find(ca4) == sca.find( SharedArray<char>(ca4) ) );
// test shared_array with user defined type
SharedArray<UDT> udta ( new UDT[3] );
udta[0].value( 111 );
udta[1].value( 222 );
udta[2].value( 333 );
SharedArray<UDT> udta2 ( udta );
poco_assert( udta[0].value() == 111 );
poco_assert( udta[1].value() == 222 );
poco_assert( udta[2].value() == 333 );
poco_assert( udta2[0].value() == 111 );
poco_assert( udta2[1].value() == 222 );
poco_assert( udta2[2].value() == 333 );
udta2.reset();
poco_assert( udta2.get() == 0 );
poco_assert( UDT_use_count == 3 ); // reality check
std::cout << "OK\n";
}
示例13: CreateSharedBuffers
void CreateSharedBuffers( const int bytesPerBuffer ) {
// setup shared memory buffers
for ( int i = 0; i < constants::NUM_BUFFERS; ++i ) {
// create unique buffer file names
std::string bufferName = constants::BUFFER_BASE_NAME +
boost::lexical_cast<string> ( i ) + ".buf";
// create shared buffers
SharedBufferPtr bufPtr (
new SharedMemory (
bufferName,
bytesPerBuffer,
SHM::CreateShared,
0666 )
);
// store buffer in a vector
array_.push_back ( bufPtr );
}
}
示例14: settings
virtual const gnuradar::ResponseMessage Execute( gnuradar::ControlMessage& msg ){
gnuradar::ResponseMessage response_msg;
try{
// reset any existing configuration
producer_.reset();
consumer_.reset();
bufferManager_.reset();
hdf5_.reset();
array_.clear();
gnuradar::File* file = msg.mutable_file();
// standardizes units of input file.
gr_helper::FormatFileFromMessage( file );
gnuradar::RadarParameters* rp = file->mutable_radarparameters();
// setup shared buffer header to assist in real-time processing
header_ = SharedBufferHeaderPtr
(
new ::yml::SharedBufferHeader
(
constants::NUM_BUFFERS,
rp->bytesperbuffer(),
file->samplerate(),
file->numchannels(),
rp->prisperbuffer(),
rp->samplesperbuffer()
)
);
// setup gnuradar settings pointer
GnuRadarSettingsPtr settings( new GnuRadarSettings() );
// read and parse configuration file->
GetSettings( settings, file );
// create a device to communicate with hardware
GnuRadarDevicePtr gnuRadarDevice( new GnuRadarDevice( settings ) );
// make sure we don't have an existing data set
if( gr_helper::HdfFileExists( file->basefilename() ))
{
throw std::runtime_error( "HDF5 File set " + fileName +
" exists and cannot be overwritten. Change your "
"base file set name and try again");
}
// setup HDF5 attributes and file->set.
hdf5_ = SetupHDF5( file );
// setup shared memory buffers
CreateSharedBuffers( rp->bytesperbuffer() );
// setup the buffer manager
bufferManager_ = SynchronizedBufferManagerPtr(
new SynchronizedBufferManager(
array_, constants::NUM_BUFFERS, rp->bytesperbuffer()) );
// setup table dimensions column = samples per ipp , row = IPP number
std::vector<hsize_t> dims;
dims.push_back(rp->prisperbuffer());
dims.push_back (static_cast<int> (rp->samplesperpri()));
// setup producer thread
producer_ = gnuradar::ProducerThreadPtr (
new ProducerThread ( bufferManager_, gnuRadarDevice ) );
// flush header information
header_->Write(0,0,0);
// setup consumer thread
consumer_ = gnuradar::ConsumerThreadPtr(
new ConsumerThread ( bufferManager_ , header_, hdf5_, dims ) );
// new model
pcModel_->Initialize( bufferManager_, producer_, consumer_);
// start producer thread
pcModel_->Start();
response_msg.set_value(gnuradar::ResponseMessage::OK);
response_msg.set_message("Data collection successfully started.");
// Start status thread to broadcast status packets to any subscribers.
if( statusServer_->IsActive() == false )
{
statusServer_->Start();
}
std::cout << "System is running..." << std::endl;
}
catch( std::runtime_error& e ){
response_msg.set_value(gnuradar::ResponseMessage::ERROR);
response_msg.set_message(e.what());
//.........这里部分代码省略.........
示例15: configFile
virtual const std::string Execute( const xml::XmlPacketArgs& args ) {
// reset any existing configuration
producer_.reset();
consumer_.reset();
bufferManager_.reset();
hdf5_.reset();
array_.clear();
std::string response;
std::string xml_data = command::ParseArg( "file", args );
// incoming "file" is self-contained xml data.
bool data_is_xml = true;
xml_data = xml::XmlPacket::DecodeXml( xml_data );
// parse configuration file
ConfigFile configFile( xml_data, data_is_xml );
// create constants
const int BUFFER_SIZE = configFile.BytesPerSecond();
const double SAMPLE_RATE = configFile.SampleRate();
const int NUM_CHANNELS = configFile.NumChannels();
const int IPPS_PER_BUFFER = static_cast<int>( ceil(1.0/configFile.IPP()));
const int SAMPLES_PER_BUFFER = static_cast<int> ( configFile.SamplesPerIpp() * configFile.NumChannels() );
// setup shared buffer header to assist in real-time processing
header_ = SharedBufferHeaderPtr( new ::xml::SharedBufferHeader(
constants::NUM_BUFFERS,
BUFFER_SIZE,
SAMPLE_RATE,
NUM_CHANNELS,
IPPS_PER_BUFFER,
SAMPLES_PER_BUFFER
));
// create a response packet and return to requester
std::string destination = command::ParseArg( "source", args );
xml::XmlPacketArgs responsePacket;
responsePacket["destination"] = destination;
responsePacket["type"] = "response";
gnuradar::xml::XmlPacket packet("gnuradar_server");
try{
// make sure we don't have an existing data set
CheckForExistingFileSet ( configFile.DataFileBaseName() ) ;
// setup HDF5 attributes and file set.
hdf5_ = SetupHDF5( configFile );
// read and parse configuration file.
GnuRadarSettingsPtr settings = GetSettings( configFile );
// create a device to communicate with hardware
GnuRadarDevicePtr gnuRadarDevice( new GnuRadarDevice( settings ) );
// setup shared memory buffers
CreateSharedBuffers( BUFFER_SIZE );
// setup the buffer manager
bufferManager_ = SynchronizedBufferManagerPtr(
new SynchronizedBufferManager(
array_, constants::NUM_BUFFERS, BUFFER_SIZE) );
// setup table dimensions column = samples per ipp , row = IPP number
vector<hsize_t> dims;
dims.push_back( IPPS_PER_BUFFER );
dims.push_back (
static_cast<int> (
configFile.SamplesPerIpp() * configFile.NumChannels() )
);
// setup producer thread
producer_ = gnuradar::ProducerThreadPtr (
new ProducerThread ( bufferManager_, gnuRadarDevice ) );
// flush header information
header_->Close();
// setup consumer thread
consumer_ = gnuradar::ConsumerThreadPtr(
new ConsumerThread ( bufferManager_ , header_, hdf5_, dims ) );
// new model
pcModel_->Initialize( bufferManager_, producer_, consumer_);
// start producer thread
pcModel_->Start();
responsePacket["value"] = "OK";
responsePacket["message"] = "Data collection successfully started.";
response = packet.Format( responsePacket );
// Start status thread to broadcast status packets to any subscribers.
statusThread_->Stop();
statusThread_->Start();
//.........这里部分代码省略.........