DataContainer GraphicsImpl::getData(const DataIdentifier& id) { if (id == "window.handle") { std::ostringstream windowHndStr; size_t windowHnd = 0; window->getCustomAttribute("WINDOW", &windowHnd); windowHndStr << windowHnd; return DataContainer(windowHndStr.str()); } return DataContainer(); }
void GraphicsImpl::guiCallback(MyGUI::WidgetPtr sender) { std::string name = sender->getName(); if (name == "do") { InformationManager::Instance()->postDataToFeed("gui_event", DataContainer(DO_BUTTON)); } if (name == "exit") { InformationManager::Instance()->postDataToFeed("gui_event", DataContainer(EXIT_BUTTON)); } }
void CameraBuffer::execute(DataProvider& provider) { // get the input data Id2DataPair inputMapper(INPUT); provider.receiveInputData(inputMapper); // try to get a free buffer Data* buffer = 0; try { buffer = m_buffers(0); } catch(Timeout&) { } if(buffer) { // there was a free buffer DataContainer bufferContainer(buffer); // remember it in the recycling access m_buffers.add(bufferContainer); Id2DataPair outputMapper(OUTPUT, inputMapper.data()); Id2DataPair bufferMapper(BUFFER, bufferContainer); Id2DataPair idMapper(INDEX, DataContainer(new UInt32(m_id))); // send it to the output (together with the input image and the current index) provider.sendOutputData(outputMapper && bufferMapper && idMapper); } // increase the index ++m_id; }
int AIMNetManager::GrabCapabilityStuff( DataContainer block ) { int ret = 0; int offset = 0; while( offset < block.length() ) { for( int32 i = 0; i < (int32)(sizeof(AIMCaps)/16); ++i ) { if( DataContainer(AIMCaps[i],16) == block.getrange(offset,16) ) { switch(i) { case 0: ret |= CAPS_BUDDYICON; break; case 1: ret |= CAPS_VOICE; break; case 2: ret |= CAPS_IMIMAGE; break; case 3: ret |= CAPS_CHAT; break; case 4: ret |= CAPS_GETFILE; break; case 5: ret |= CAPS_SENDFILE; break; default: ret |= 0xff00; break; } } } offset += 16; } return ret; }
void Id2DataPairTest::setUp ( void ) { std::vector<const Description*> descriptions; descriptions.push_back(new Description(0, Variant::NONE)); descriptions.push_back(new Description(1, Variant::NONE)); descriptions.push_back(new Description(2, Variant::NONE)); m_map = new impl::Id2DataMap(descriptions); m_dataContainer = DataContainer(new None()); }
bool GraphicsImpl::windowClosing(Ogre::RenderWindow* rw) { //Only close for window that created OIS (the main window in these demos) if (rw == window) { InformationManager::Instance()->postDataToFeed("gui_event", DataContainer(EXIT_BUTTON)); } return true; }
void ConstData::execute(DataProvider& provider) { if (! valuePtr()) throw InternalError("Value has not been set"); DataContainer data; if (m_allocateData) { data = DataContainer(valuePtr()->clone()); } else { Data* dataPtr = 0; if (m_recycleAccess.empty()) { // if this is the first time the operator executes the value must // be cloned dataPtr = valuePtr()->clone(); } else { // otherwise the value in the recycler can be reused dataPtr = m_recycleAccess.get(); } if (dataPtr != valuePtr()) { // if the value was changed by the user since the last execution // update it delete dataPtr; dataPtr = valuePtr()->clone(); } // send and remember for the next execution data = DataContainer(dataPtr); m_recycleAccess.add(data); } Id2DataPair outputDataMapper(OUTPUT, data); provider.sendOutputData( outputDataMapper); }
void Id2DataPair::get(runtime::impl::Id2DataMap& id2DataMap) const { if(! m_data.empty()) throw WrongState("Data has already been assigned to this ID-data pair."); if(id2DataMap.get(m_id).empty()) throw WrongState("The requested output is empty."); m_data = id2DataMap.get(m_id); id2DataMap.set(m_id, DataContainer()); }
void Id2DataPair::set(runtime::impl::Id2DataMap& id2DataMap) const { if(m_data.empty()) throw WrongState("This ID-data pair contains no data"); if(! id2DataMap.get(m_id).empty()) throw WrongState("Data has already been assigned to this connector ID."); id2DataMap.set(m_id, m_data); m_data = DataContainer(); }
void AIMNetManager::ReceiveWarning( SNAC_Object& snac ) { BString warnMessage; char strNewWLevel[15]; unsigned short wLevel, i=0; DataContainer screenName; bool anon = false; char snLength; wLevel = (unsigned short)( rint( (double)GetWord(snac.data,i) / 10.0 ) ); i += 2; printf( "New warning level: %u%%\n", wLevel ); printf( "... came from " ); // 'twas an anonymous warning if( i >= snac.data.length() ) { anon = true; printf( "Anonymous\n" ); } // grab the length, and then the screen name if( !anon ) { snLength = snac.data[i++]; screenName = DataContainer( snac.data.getrange(i,snLength) ); i += snLength; screenName << char(0); printf( "%s\n", screenName.c_ptr() ); } // is our warning level going DOWN? if so, don't annoy the user by telling them about it if( wLevel < client->WarningLevel() ) { client->SetWarningLevel( wLevel ); return; } // make the "warned" message client->SetWarningLevel( wLevel ); sprintf( strNewWLevel, "%u%%", wLevel ); warnMessage = BString( Language.get("ERR_GOT_WARNED") ); warnMessage.ReplaceAll( "%WLEVEL", strNewWLevel ); if( anon ) { BString anonLabel = "["; anonLabel.Append( Language.get("ANONYMOUS_LABEL") ); anonLabel.Append( "]" ); warnMessage.ReplaceAll( "%USER", anonLabel.String() ); } else warnMessage.ReplaceAll( "%USER", screenName.c_ptr() ); // now display it windows->ShowMessage( warnMessage, B_STOP_ALERT, Language.get("BEHAVE_LABEL"), WS_WARNED ); }
DataContainer PackageHandle::ReadAsset(const std::string& _assetName) { std::ifstream fs; std::vector<std::string> path = SplitPathName(_assetName); Asset* a = root->ReadAsset(path, 0); if (a == nullptr) return DataContainer(PackageResult::FILE_NOT_FOUND); fs.open(packageName.c_str(), std::ifstream::binary); char* result = (char*)allocator->FlatAllocate(a->GetSize()); if (result == nullptr) return DataContainer(PackageResult::OUT_OF_MEMORY); fs.seekg(a->GetStart()); fs.read(result, a->GetSize()); fs.close(); return DataContainer(result, a->GetSize()); }
DataContainer getData ( const DataIdentifier& id ) { if ( id.isPartOf ( "system" ) ) { if ( id.isPartOf ( "system.greeting" ) ) { return DataContainer ( std::string ( "Sample Data" ) ); } else if ( id.isPartOf ( "system.number" ) ) { return DataContainer ( 3232 ); } else { return DataContainer ( std::string ( "data n/a" ) ); } } else { return DataContainer ( std::string ( "not responsible for this" ) ); } }
void CameraBuffer::activate() { Data* buffer = 0; // delete all remaining buffers in the recycling access while((buffer = m_buffers())) delete buffer; // allocate all buffers and add them to the recycler for(unsigned int i = 0; i < m_numBuffers; ++i) m_buffers.add(DataContainer(new cvsupport::Image(m_bufferSize))); m_id = 0; }
void Id2DataMapTest::testObserver() { DataContainer data1(new UInt8()); m_inputMap->set(1, data1); CPPUNIT_ASSERT_EQUAL((unsigned int)(1), m_observer->lastId()); CPPUNIT_ASSERT_EQUAL(DataContainer(), m_observer->lastOldData()); CPPUNIT_ASSERT_EQUAL(data1, m_observer->lastNewData()); DataContainer data2(new UInt8()); m_inputMap->set(0, data2); CPPUNIT_ASSERT_EQUAL((unsigned int)(0), m_observer->lastId()); CPPUNIT_ASSERT_EQUAL(DataContainer(), m_observer->lastOldData()); CPPUNIT_ASSERT_EQUAL(data2, m_observer->lastNewData()); DataContainer data3(new UInt8()); m_inputMap->set(0, data3); CPPUNIT_ASSERT_EQUAL((unsigned int)(0), m_observer->lastId()); CPPUNIT_ASSERT_EQUAL(data2, m_observer->lastOldData()); CPPUNIT_ASSERT_EQUAL(data3, m_observer->lastNewData()); }
std::vector<DataContainer> PackageHandle::ReadAllAssetsInDir(const std::string& _directoryName) { std::vector<DataContainer> result; std::ifstream fs; std::vector<std::string> path = SplitPathName(_directoryName); std::map<std::string, Asset*>::iterator it; std::map<std::string, Asset*> amap = root->ReadAllAssetsInDir(path, 0); if (amap.size() == 0) { result.push_back(DataContainer(PackageResult::DIRECTORY_NOT_FOUND)); return result; } fs.open(packageName.c_str(), std::ifstream::binary); for (it = amap.begin(); it != amap.end(); it++) { char* buffer = (char*)allocator->FlatAllocate(it->second->GetSize()); if (buffer == nullptr) { result.push_back(DataContainer(PackageResult::OUT_OF_MEMORY)); return result; } fs.seekg(it->second->GetStart()); fs.read(buffer, it->second->GetSize()); result.push_back(DataContainer(buffer, it->second->GetSize())); } fs.close(); return result; }
void Split::execute(DataProvider& provider) { if (m_storedItems.size() == 0) { RecycleAccess recycle; { Id2DataPair input(INPUT); provider.receiveInputData(input); recycle.add(input.data()); } Data* data = recycle.get(); List* list = data_cast<List>(data); if (list == 0) throw InputError(INPUT, *this, "Input data must be a 'List' object."); for (std::vector<Data*>::iterator iter = list->content().begin(); iter != list->content().end(); ++iter) { m_storedItems.push_back(DataContainer(*iter)); } uint64_t size = list->content().size(); list->content().clear(); delete list; DataContainer outNumItems(new UInt64(size)); Id2DataPair dataMapper(OUTPUT_NUM_ITEMS, outNumItems); provider.sendOutputData(dataMapper); } if (m_storedItems.size() != 0) { DataContainer outData = m_storedItems.front(); Id2DataPair dataMapper(OUTPUT_DATA, outData); m_storedItems.pop_front(); provider.sendOutputData(dataMapper); } }
short AIMNetManager::TackOnCapabilityStuff( DataContainer& data ) { //int caps = CAPS_CHAT | CAPS_GETFILE | CAPS_SENDFILE; int caps = 0; int offset = 0; // tack on all the required capabilities info if( caps & CAPS_BUDDYICON ) { data << DataContainer( AIMCaps[0], sizeof(AIMCaps[0]) ); offset += sizeof(AIMCaps[0]); printf( "tacking on cap: CAPS_BUDDYICON\n" ); } if( caps & CAPS_VOICE ) { data << DataContainer( AIMCaps[1], sizeof(AIMCaps[1]) ); offset += sizeof(AIMCaps[1]); printf( "tacking on cap: CAPS_VOICE\n" ); } if( caps & CAPS_IMIMAGE ) { data << DataContainer( AIMCaps[2], sizeof(AIMCaps[2]) ); offset += sizeof(AIMCaps[2]); printf( "tacking on cap: CAPS_IMIMAGE\n" ); } if( caps & CAPS_CHAT ) { data << DataContainer( AIMCaps[3], sizeof(AIMCaps[3]) ); offset += sizeof(AIMCaps[3]); printf( "tacking on cap: CAPS_CHAT\n" ); } if( caps & CAPS_GETFILE ) { data << DataContainer( AIMCaps[4], sizeof(AIMCaps[4]) ); offset += sizeof(AIMCaps[4]); printf( "tacking on cap: CAPS_GETFILE\n" ); } if( caps & CAPS_SENDFILE ) { data << DataContainer( AIMCaps[5], sizeof(AIMCaps[5]) ); offset += sizeof(AIMCaps[5]); printf( "tacking on cap: CAPS_SENDFILE\n" ); } return offset; }
void Baz::threadWillStart() { InformationManager::Instance()->postDataToFeed ( "system", DataContainer ( std::string ( "Thread started" ) ) ); }