void OutPort::onController( INT16 controller, FLOAT value ) { for( UINT16 i=0; i<targets_.size(); i++ ) { LinkData* linkData = targets_[i]; if( linkData->scaleController( controller, value )) { linkData->value_ = value; setModulation( i, value ); } } }
void OutPort::onGate( FLOAT gate, UINT16 voice ) { for( UINT16 i=0; i<targets_.size(); i++ ) { LinkData* linkData = targets_[i]; if( linkData->veloSens_ ) { float value = linkData->makeLogarithmic( linkData->value_ ); gate *= linkData->veloSens_; value += gate; setModulation( i, value, voice ); } } }
int main() { LinkData* l; Ethernet e; MACAddress m; l = &e; l = new Ethernet; *l = e; std::cout << "l = &e" << std::endl; std::cout << "Ethernet: " << (l->isEthernet() ? "yes" : "no") << std::endl; std::cout << "MAC: " << (l->isMac() ? "yes" : "no") << std::endl; delete l; l = &m; std::cout << "l = &m" << std::endl; std::cout << "Ethernet: " << (l->isEthernet() ? "yes" : "no") << std::endl; std::cout << "MAC: " << (l->isMac() ? "yes" : "no") << std::endl; std::vector< LinkData* > ldata; l = new Ethernet(e); ldata.push_back( l ); ldata.push_back( (new MACAddress(m)) ); std::cout << "ldata.at(0)" << std::endl; std::cout << "Ethernet: " << (ldata.at(0)->isEthernet() ? "yes" : "no") << std::endl; std::cout << "MAC: " << (ldata.at(0)->isMac() ? "yes" : "no") << std::endl; std::cout << "ldata.at(1)" << std::endl; std::cout << "Ethernet: " << (ldata.at(1)->isEthernet() ? "yes" : "no") << std::endl; std::cout << "MAC: " << (ldata.at(1)->isMac() ? "yes" : "no") << std::endl; std::vector< Link > data; data.push_back( e ); data.push_back( m ); std::cout << ( data.at( 0 ).is<Ethernet>() ? "yes" : "no" ) << std::endl; e = data.at( 0 ).get<Ethernet>(); Ethernet* eptr; l = &e; eptr = (Ethernet*)l; std::cout << "Ethernet: " << (eptr->isEthernet() ? "yes" : "no") << std::endl; std::cout << "MAC: " << (eptr->isMac() ? "yes" : "no") << std::endl; return 0; }
/** @param file INI file object to read from @param nPage Number of page to read from @return true if read successfully, false if failed */ bool CCPrintData::PageData::FromFile(class FileINI& file, int nPage) { // Variables TCHAR cName[32]; TCHARSTR2STR data; TCHARSTR2STR::const_iterator iKey; // Clean this object Clear(); // Get INI key/value pairs from the page's section _stprintf_s(cName, _S(cName), DATAFILE_SECTION_PAGE, nPage); if (!file.GetKeys(cName, data) || ((iKey = data.find(DATAFILE_LINK_COUNT)) == data.end())) // None found, just go on return true; // Get the page link count int nLinkCount = _ttoi((*iKey).second.c_str()); if (nLinkCount < 1) // This shouldn't happen return false; // Read all links for (int iLink = 1; iLink <= nLinkCount; iLink++) { LinkData link; if (link.FromFile(data, iLink)) push_back(link); } // Get page width and height if we found them if ((iKey = data.find(DATAFILE_PAGE_WIDTH)) != data.end()) szPage.cx = _ttoi((*iKey).second.c_str()); if ((iKey = data.find(DATAFILE_PAGE_HEIGHT)) != data.end()) szPage.cy = _ttoi((*iKey).second.c_str()); return true; }
int main (int commands, char *control []) { LinkData *exe = new LinkData (); return (exe->Start_Execution (commands, control)); }
void execute () { try { sock_.join (addr_); auto_ptr<LinkListener> ll (new LinkListener (sock_, in_link_data_)); { AutoLock lock (mutex_); // Loop // // while (true) { cond_.wait (&sync_schedule); // "Loop of Fairness" bool done = false; do { // control message // // if (!in_control_.empty ()) { done = true; break; } // outsync // // if (sync_schedule < ACE_OS::gettimeofday ()) { // OUTSYNC outsync (); // schedule next outsync sync_schedule = ACE_OS::gettimeofday () + ACE_Time_Value (0, Protocol::SYNC_PERIOD); } // link message // // if (!in_link_data_.empty ()) { MessagePtr m (in_link_data_.front ()); in_link_data_.pop (); std::type_info const* exp = &typeid (*m); if (exp == typeid (LinkFailure)) { // cerr << "link failure" << endl; throw false; } else if (exp == typeid (LinkData)) { LinkData* data = dynamic_cast<LinkData*> (m.get ()); // INSYNC, TL, CT // Filter out loopback. // if (ACE_OS::strcmp (data->header().member_id.id, id_) != 0) { insync (); transaction_list (); current_transaction (data->header().current, data->payload (), data->size ()); } } else { // cerr << "unknown message type from link listener: " // << typeid (*m).name () << endl; ACE_OS::abort (); } } // api message // // if (!in_data_.empty ()) { // API api (); } } while (!in_link_data_.empty() || sync_schedule < ACE_OS::gettimeofday ()); if (done) break; } } } catch (...) { // cerr << "Exception in scheduler loop." << endl; MessageQueueAutoLock lock (out_control_); out_control_.push (MessagePtr (new Failure)); } }
/* static */ const uint8_t* Module::deserialize(const uint8_t* cursor, SharedModule* module, Metadata* maybeMetadata) { Bytes code; cursor = DeserializePodVector(cursor, &code); if (!cursor) return nullptr; LinkData linkData; cursor = linkData.deserialize(cursor); if (!cursor) return nullptr; ImportVector imports; cursor = DeserializeVector(cursor, &imports); if (!cursor) return nullptr; ExportVector exports; cursor = DeserializeVector(cursor, &exports); if (!cursor) return nullptr; DataSegmentVector dataSegments; cursor = DeserializePodVector(cursor, &dataSegments); if (!cursor) return nullptr; ElemSegmentVector elemSegments; cursor = DeserializeVector(cursor, &elemSegments); if (!cursor) return nullptr; MutableMetadata metadata; if (maybeMetadata) { metadata = maybeMetadata; } else { metadata = js_new<Metadata>(); if (!metadata) return nullptr; } cursor = metadata->deserialize(cursor); if (!cursor) return nullptr; MOZ_RELEASE_ASSERT(!!maybeMetadata == metadata->isAsmJS()); MutableBytes bytecode = js_new<ShareableBytes>(); if (!bytecode) return nullptr; cursor = DeserializePodVector(cursor, &bytecode->bytes); if (!cursor) return nullptr; *module = js_new<Module>(Move(code), Move(linkData), Move(imports), Move(exports), Move(dataSegments), Move(elemSegments), *metadata, *bytecode); if (!*module) return nullptr; return cursor; }
/* static */ SharedModule Module::deserialize(const uint8_t* bytecodeBegin, size_t bytecodeSize, const uint8_t* compiledBegin, size_t compiledSize, Metadata* maybeMetadata) { MutableBytes bytecode = js_new<ShareableBytes>(); if (!bytecode || !bytecode->bytes.initLengthUninitialized(bytecodeSize)) return nullptr; memcpy(bytecode->bytes.begin(), bytecodeBegin, bytecodeSize); Assumptions assumptions; const uint8_t* cursor = assumptions.deserialize(compiledBegin, compiledSize); if (!cursor) return nullptr; Bytes code; cursor = DeserializePodVector(cursor, &code); if (!cursor) return nullptr; LinkData linkData; cursor = linkData.deserialize(cursor); if (!cursor) return nullptr; ImportVector imports; cursor = DeserializeVector(cursor, &imports); if (!cursor) return nullptr; ExportVector exports; cursor = DeserializeVector(cursor, &exports); if (!cursor) return nullptr; DataSegmentVector dataSegments; cursor = DeserializePodVector(cursor, &dataSegments); if (!cursor) return nullptr; ElemSegmentVector elemSegments; cursor = DeserializeVector(cursor, &elemSegments); if (!cursor) return nullptr; MutableMetadata metadata; if (maybeMetadata) { metadata = maybeMetadata; } else { metadata = js_new<Metadata>(); if (!metadata) return nullptr; } cursor = metadata->deserialize(cursor); if (!cursor) return nullptr; MOZ_RELEASE_ASSERT(cursor == compiledBegin + compiledSize); MOZ_RELEASE_ASSERT(!!maybeMetadata == metadata->isAsmJS()); return js_new<Module>(Move(assumptions), Move(code), Move(linkData), Move(imports), Move(exports), Move(dataSegments), Move(elemSegments), *metadata, *bytecode); }