void Intercepter::interceptQBit() { QBit* qbit = qChannel->get_first(); bool type = rand() % 2; bool val = qbit->getValue(type); lastQBitInformation = type + val * 2; key.push_back( KeyDescriptor(type, val, 0) ); qChannel->add( new QBit(type,val) ); }
// Load the keyboard map from a property tree. KeyboardMap &KeyboardMap::load(const boost::property_tree::ptree &data) { // Key-lines std::size_t key_line_count = data.get<std::size_t>("key-line.count"); _line_height = parse_int_list(data.get<std::string>("key-line.height"), key_line_count, 100, MINIMUM_KEY_SIZE); _line_y.resize(key_line_count); if(key_line_count>0) { _line_y[0] = 0; } for(std::size_t k=1; k<key_line_count; ++k) { _line_y[k] = _line_y[k-1] + _line_height[k-1]; } _total_height = key_line_count>0 ? _line_y[key_line_count-1]+_line_height[key_line_count-1] : 0; // Keys const boost::property_tree::ptree &key_data(data.get_child("keys")); _total_width_with_nkp = 0; _total_width_without_nkp = 0; for(const auto &it : key_data) { if(it.first!="key") { continue; } // Load the key descriptor _keys.push_back(KeyDescriptor()); const KeyDescriptor &key(_keys.back().load(it.second)); // Update the geometry flags for(std::size_t line=key.line_top(); line<=key.line_bottom(); ++line) { int x_at_key_right = key.x(line) + key.width(line); _total_width_with_nkp = std::max(_total_width_with_nkp, x_at_key_right); if(!key.in_numeric_keypad()) { _total_width_without_nkp = std::max(_total_width_without_nkp, x_at_key_right); } } } // Return a reference to the object return *this; }
void Intercepter::interceptTypeInfo(int keyLength) { vector<int> typeInfo = interceptMsg(); for(int i=0; i<keyLength; ++i) rcverKey.push_back( KeyDescriptor(typeInfo[i], 0, 0) ); }
/*! \brief Parse key descriptor. \warning Encoded data is modified during parsing. \warning In case of an error, throws either ByteSeqException or IPMPDataException. \param encoded input, encoded data. \returns Key descriptor. */ KeyDescriptor IPMPDataParser::ParseKeyDescriptor(ByteSeq& encoded) { ByteSeq keyBody = encoded.GetBytes((UInt32T)(encoded.GetSizeOfInstance(0))); return KeyDescriptor(keyBody); }