void OwnedAttributeValue::blend(const AttributeValue& source, const AttributeValue& dest) { if (_attribute) { _attribute->destroy(_value); } _attribute = source.getAttribute(); _value = _attribute->blend(source.getValue(), dest.getValue()); }
void OwnedAttributeValue::mix(const AttributeValue& first, const AttributeValue& second, float alpha) { if (_attribute) { _attribute->destroy(_value); } _attribute = first.getAttribute(); _value = _attribute->mix(first.getValue(), second.getValue(), alpha); }
inline PackageWriter::Attribute* PackageWriter::_AddAttribute(const char* attributeName, Type value) { AttributeValue attributeValue; attributeValue.SetTo(value); return _AddAttribute(attributeName, attributeValue); }
Transformer* CreateGraphicFunc::get_transformer(AttributeList* al) { static int transform_symid = symbol_add("transform"); AttributeValue* transformv = nil; Transformer* rel = nil; AttributeValueList* avl = nil; if (al && (transformv=al->find(transform_symid)) && transformv->is_array() && (avl=transformv->array_val()) && avl->Number()==6) { float a00, a01, a10, a11, a20, a21; Iterator it; avl->First(it); a00=avl->GetAttrVal(it)->float_val(); avl->Next(it); a01=avl->GetAttrVal(it)->float_val(); avl->Next(it); a10=avl->GetAttrVal(it)->float_val(); avl->Next(it); a11=avl->GetAttrVal(it)->float_val(); avl->Next(it); a20=avl->GetAttrVal(it)->float_val(); avl->Next(it); a21=avl->GetAttrVal(it)->float_val(); rel = new Transformer(a00, a01, a10, a11, a20, a21); } else { rel = ((OverlayViewer*)_ed->GetViewer())->GetRel(); if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } } return rel; }
PackageWriter::Attribute* PackageWriter::_AddStringAttribute(const char* attributeName, const char* value) { AttributeValue attributeValue; attributeValue.SetTo(_GetCachedString(value)); return _AddAttribute(attributeName, attributeValue); }
PackageWriter::Attribute* PackageWriter::_AddDataAttribute(const char* attributeName, uint64 dataSize, const uint8* data) { AttributeValue attributeValue; attributeValue.SetToData(dataSize, data); return _AddAttribute(attributeName, attributeValue); }
void loop() { int prevSwitchState = switchState; /* Read the state of the tilt switch. */ switchState = digitalRead(SWITCH_PIN); /* If state has changed back to low a button press (or a full tilt if using * a tilt switch) has passed */ if (prevSwitchState == HIGH && switchState == LOW) { /* Create an Item. */ AttributeValue deviceValue; deviceValue.setS(HASH_KEY_VALUE); AttributeValue timeValue; /* Getting current time for Time attribute. */ timeValue.setN(dateTimeProvider.getDateTime()); MinimalKeyValuePair < MinimalString, AttributeValue > att1(HASH_KEY_NAME, deviceValue); MinimalKeyValuePair < MinimalString, AttributeValue > att2(RANGE_KEY_NAME, timeValue); MinimalKeyValuePair < MinimalString, AttributeValue > att3(ATTRIBUTE_KEY_NAME, ATTRIBUTE_KEY_VALUE); MinimalKeyValuePair<MinimalString, AttributeValue> itemArray[] = { att1, att2, att3}; /* Set values for putItemInput. */ putItemInput.setItem(MinimalMap < AttributeValue > (itemArray, 2)); putItemInput.setTableName(TABLE_NAME); /* perform putItem and check for errors. */ PutItemOutput putItemOutput = ddbClient.putItem(putItemInput, actionError); switch (actionError) { case NONE_ACTIONERROR: Serial.println("PutItem succeeded!"); break; case INVALID_REQUEST_ACTIONERROR: Serial.print("ERROR: "); Serial.println(putItemOutput.getErrorMessage().getCStr()); break; case MISSING_REQUIRED_ARGS_ACTIONERROR: Serial.println( "ERROR: Required arguments were not set for PutItemInput"); break; case RESPONSE_PARSING_ACTIONERROR: Serial.println("ERROR: Problem parsing http response of PutItem"); break; case CONNECTION_ACTIONERROR: Serial.println("ERROR: Connection problem"); break; } /* wait to not double-record */ delay(2000); } delay(150); }
AttributeValue hydrator::read_attribute_value() { AttributeValue result; result.value(read_xml_string_attribute(dia_val)); reader_.skip(); BOOST_LOG_SEV(lg, debug) << "Reading generic attribute value: " << result.value(); return result; }
void AttributeValueList::getAttributes(AttributeList* _attributes) { AttributeValue* value; for (std::list<AttributeValue*>::iterator it = this->begin(); it != this->end(); it++) { value = *it; _attributes->push_back(value->getAttribute()); } }
/* This function loops forever --------------------------------------------*/ void loop() { //This will run in a loop rssi = WiFi.RSSI(); /* Create an Item. */ AttributeValue deviceValue; deviceValue.setS(HASH_KEY_VALUE); AttributeValue timeValue; /* Getting current time for Time attribute. */ timeValue.setS(dateTimeProvider.getDateTime()); MinimalKeyValuePair < MinimalString, AttributeValue > att1(HASH_KEY_NAME, deviceValue); MinimalKeyValuePair < MinimalString, AttributeValue > att2(RANGE_KEY_NAME, timeValue); MinimalKeyValuePair<MinimalString, AttributeValue> itemArray[] = { att1, att2}; /* Set values for putItemInput. */ putItemInput.setItem(MinimalMap < AttributeValue > (itemArray, 2)); putItemInput.setTableName(TABLE_NAME); /* perform putItem and check for errors. */ PutItemOutput putItemOutput = ddbClient.putItem(putItemInput, actionError); switch (actionError) { case NONE_ACTIONERROR: Serial.println("PutItem succeeded!"); Serial.println(myIDStr); Serial.println(rssi); break; case INVALID_REQUEST_ACTIONERROR: Serial.print("ERROR: "); Serial.println(putItemOutput.getErrorMessage().getCStr()); break; case MISSING_REQUIRED_ARGS_ACTIONERROR: Serial.println( "ERROR: Required arguments were not set for PutItemInput"); break; case RESPONSE_PARSING_ACTIONERROR: Serial.println("ERROR: Problem parsing http response of PutItem"); break; case CONNECTION_ACTIONERROR: Serial.println("ERROR: Connection problem"); break; } /* wait to not double-record */ delay(5000); }
status_t PackageReaderImpl::ReadAttributeValue(uint8 type, uint8 encoding, AttributeValue& _value) { switch (type) { case B_HPKG_ATTRIBUTE_TYPE_RAW: { uint64 size; status_t error = ReadUnsignedLEB128(size); if (error != B_OK) return error; if (encoding == B_HPKG_ATTRIBUTE_ENCODING_RAW_HEAP) { uint64 offset; error = ReadUnsignedLEB128(offset); if (error != B_OK) return error; if (offset > fHeapSize || size > fHeapSize - offset) { ErrorOutput()->PrintError("Error: Invalid %s section: " "invalid data reference\n", CurrentSection()->name); return B_BAD_DATA; } _value.SetToData(size, offset); } else if (encoding == B_HPKG_ATTRIBUTE_ENCODING_RAW_INLINE) { if (size > B_HPKG_MAX_INLINE_DATA_SIZE) { ErrorOutput()->PrintError("Error: Invalid %s section: " "inline data too long\n", CurrentSection()->name); return B_BAD_DATA; } const void* buffer; error = _GetTOCBuffer(size, buffer); if (error != B_OK) return error; _value.SetToData(size, buffer); } else { ErrorOutput()->PrintError("Error: Invalid %s section: invalid " "raw encoding (%u)\n", CurrentSection()->name, encoding); return B_BAD_DATA; } return B_OK; } default: return inherited::ReadAttributeValue(type, encoding, _value); } }
void OverlayComp::SetAttributeList(AttributeList* al) { if (_attrlist) Unref(_attrlist); _attrlist = al; Resource::ref(_attrlist); #if 0 // experimentation with attribute changing if (al) { static int hidden_symid = symbol_find("hidden"); AttributeValue* av = al->find(hidden_symid); if (av) _gr->Hide(av->is_true()); } #endif Observable::notify(); }
void TransformerFunc::execute() { ComValue objv(stack_arg(0)); ComValue transv(stack_arg(0)); reset_stack(); if (objv.object_compview()) { ComponentView* compview = (ComponentView*)objv.obj_val(); if (compview && compview->GetSubject()) { OverlayComp* comp = (OverlayComp*)compview->GetSubject(); Graphic* gr = comp->GetGraphic(); if (gr) { Transformer* trans = gr->GetTransformer(); if (transv.is_unknown() || !transv.is_array() || transv.array_val()->Number()!=6) { AttributeValueList* avl = new AttributeValueList(); float a00, a01, a10, a11, a20, a21; trans->matrix(a00, a01, a10, a11, a20, a21); avl->Append(new AttributeValue(a00)); avl->Append(new AttributeValue(a01)); avl->Append(new AttributeValue(a10)); avl->Append(new AttributeValue(a11)); avl->Append(new AttributeValue(a20)); avl->Append(new AttributeValue(a21)); ComValue retval(avl); push_stack(retval); } else { float a00, a01, a10, a11, a20, a21; AttributeValueList* avl = transv.array_val(); Iterator it; AttributeValue* av; avl->First(it); av = avl->GetAttrVal(it); a00 = av->float_val(); avl->Next(it); av = avl->GetAttrVal(it); a01 = av->float_val(); avl->Next(it); av = avl->GetAttrVal(it); a10 = av->float_val(); avl->Next(it); av = avl->GetAttrVal(it); a11 = av->float_val(); avl->Next(it); av = avl->GetAttrVal(it); a20 = av->float_val(); avl->Next(it); av = avl->GetAttrVal(it); a21 = av->float_val(); Transformer t(a00, a01, a10, a11, a20, a21); *gr->GetTransformer()=t; ComValue compval(new OverlayViewRef(comp), comp->class_symid()); push_stack(compval); } } } } }
void AttributeListModel::setAttribute(int id, qreal base, qreal mod) { AttributeValue *value = mAttributeValues.value(id); bool needInsert = (value == 0); if (needInsert) { beginInsertRows(QModelIndex(), mAttributeValues.size(), mAttributeValues.size()); value = mAttributeValues[id] = new AttributeValue(id, this); mCachedAttributeList.append(value); } value->setBase(base); value->setModified(mod); if (needInsert) { endInsertRows(); emit attributeAdded(id, value); } }
/******************************************************************************************** > static CCAttrMap * CCAttrMap::MakeAttrMapFromRenderRegion(RenderRegion * pRegion) Author: David_McClarnon (Xara Group Ltd) <*****@*****.**> Created: 24/2/2000 Inputs: The render region to get the attribute map from Outputs: An attribute map (copied) from the render region Returns: - Purpose: Makes an attribute out of the render region's current attribute state Notes: You MUST call DeleteAttributes afterwards to release memory - delete is not sufficient SeeAlso: - ********************************************************************************************/ CCAttrMap * CCAttrMap::MakeAttrMapFromRenderRegion(RenderRegion * pRegion) { CCAttrMap * pMap = new CCAttrMap; ENSURE(pMap,"No mem for attrmap"); if(!pMap) return NULL; // let's get every attribute in the render region AttributeValue * pAttrVal = NULL; NodeAttribute * pNewAttr = NULL; for (UINT32 i = 0; i < ATTR_FIRST_FREE_ID; i++) { pAttrVal = pRegion->GetCurrentAttribute(i); // make a new node out of this attribute value pNewAttr = pAttrVal->MakeNode(); // Karim 12/04/2000 // AttributeValues _do_not_have_to_have_ a corresponding NodeAttribute, // so can we please *check* that MakeNode didn't just return NULL! if (pNewAttr != NULL) { if(!pNewAttr->IsLinkedToNodeGeometry()) pMap->SetAt(pNewAttr->GetAttributeType(),pNewAttr); else { delete pNewAttr; pNewAttr = AttributeManager::GetDefaultAttribute((AttrIndex) i); if(pNewAttr) { ENSURE(pNewAttr->IsLinkedToNodeGeometry(),"Incorrect NodeAttribute returned by GetDefaultAttribute"); pMap->SetAt(pNewAttr->GetAttributeType(), pNewAttr); } else return NULL; } } } pMap->attrMapCreator = NULL; return pMap; }
void Context::addAttributes( std::map<text::attributes::AttributeKey,text::attributes::AttributeValue> & attributes, const Alternative::BindingMap & bindings ) const { for ( Alternative::BindingMap::const_iterator it = bindings.begin(), e = bindings.end(); it != e; ++ it ) { Expression::ValueListPtr v = it->second->evaluate( 0, Variable(), *this ); AttributeKey key = it->first; AttributeValue value = v->empty() ? AttributeValue::UNDEFINED : v->back(); if ( key == AttributeKey::UNDEFINED ) { for ( uint attr = 0; attr < AttributeKey::count(); ++ attr ) { AttributeKey k = AttributeKey( attr ); AttributeValue v = value.getContainer().getAttribute( k ); if ( v != AttributeValue::UNDEFINED ) attributes.insert( std::make_pair( k, v ) ); } } else { attributes.insert( std::make_pair( key, value ) ); } } }
BOOL FreeHandEPSFilter::SaveCurrentFill() { // get rid of any stored fill if(OldFill != 0) delete OldFill; // create a copy of the current fill attribute CCRuntimeClass* ObjectType = CurrentAttrs[ATTR_FILLGEOMETRY].pAttr->GetRuntimeClass(); AttributeValue* AttrClone = (AttributeValue*)ObjectType->CreateObject(); if(AttrClone == 0) return FALSE; AttrClone->SimpleCopy(CurrentAttrs[ATTR_FILLGEOMETRY].pAttr); // set the old fill pointer to the nice clone we've made OldFill = AttrClone; return TRUE; }
IPersistence* IPersistence::setAttributeValue(std::string _attributeName, std::string _attributeValue, IPersistenceList* _objects) { AttributeValue* attributeValue = getValue(_attributeName); if (attributeValue != nullptr) { if (attributeValue->getType() == _object) { for (auto it = _objects->begin(); it != _objects->end(); ++it) { IPersistence* currentObject = (*it); if (_attributeValue == currentObject->toString()) { (*attributeValue->getAddress().ppObject) = currentObject; return currentObject; } } } } return nullptr; }
BOOL AttrWebAddress::Blend(BlendAttrParam* pBlendParam) { //Check our parameter ERROR2IF(pBlendParam == NULL, FALSE, "AttrWebAddress::Blend - NULL parameter"); //Try and blend our WebAddressAttribute member variable if (Value.Blend(pBlendParam)) { // Get the blended attr val. After this call, the ptr is our reponsibility // so we have to delete it if it's no longer needed AttributeValue* pBlendedAttrVal = pBlendParam->GetBlendedAttrVal(); if (pBlendedAttrVal != NULL) { // We have a blended attr val, so ask it to make a NodeAttribute out of itself // and set the pBlendParam's blended NodeAttribute ptr to it NodeAttribute* pBlendedAttr = pBlendedAttrVal->MakeNode(); pBlendParam->SetBlendedAttr(pBlendedAttr); if (pBlendedAttr != NULL) { // We were able to make a blended NodeAttribute // so delete the blended attr val, and return TRUE delete pBlendedAttrVal; return TRUE; } else { // Couldn't make a blended NodeAttribute, so give the blended attr val back // and return FALSE pBlendParam->SetBlendedAttrVal(pBlendedAttrVal); return FALSE; } } } return FALSE; }
void JsonTextWriter::writeAttributeValue( const AttributeValue & value, std::ostream & os ) { switch ( value.type.id ) { case AttributeType::INDEXED_ID: os << value.value; break; case AttributeType::STRING_ID: os << "'" << value.getString() << "'"; break; case AttributeType::COMPOUND_ID: os << "{ "; // TODO Implement os << " }"; break; } }
WordForm MorphAn::convertWordForm(const lspl::morphology::WordForm& wf) const { using lspl::text::attributes::AttributeKey; using lspl::text::attributes::AttributeValue; WordForm result; result.speechPart = utility::convertToUnicode(wf.getSpeechPart().getName()); result.nf = utility::convertToUnicode(wf.getBase()); for(int i = 0;i<wf.getAttributeSetCount();++i){ QVector<QString> currentSet; for(int j = 1;j<AttributeKey::count();++j){ AttributeKey currkey(j); if(currkey == AttributeKey::BASE || currkey == AttributeKey::STEM) continue; AttributeValue val = wf.getAttribute(i,currkey); if (val != AttributeValue::UNDEFINED) { QString stringVal = utility::convertToUnicode(/*currkey.getName() +" : "+*/val.getString()); currentSet.push_back(stringVal); } } result.attributeSets.push_back(currentSet); } return result; }
void putDynamoDb() { // Put device & datestamp record in DynamoDB table // Create an Item. AttributeValue deviceIdValue; deviceIdValue.setS(HASH_KEY_VALUE); AttributeValue timeValue; // Getting current time for Time attribute. timeValue.setN(dateTimeProvider.getDateTime()); AttributeValue deviceValue; deviceValue.setS(ATTRIBUTE_VALUE); MinimalKeyValuePair<MinimalString, AttributeValue> att1(HASH_KEY_NAME, deviceIdValue); MinimalKeyValuePair<MinimalString, AttributeValue> att2(RANGE_KEY_NAME, timeValue); MinimalKeyValuePair<MinimalString, AttributeValue> att3(ATTRIBUTE_NAME, deviceValue); MinimalKeyValuePair<MinimalString, AttributeValue> itemArray[] = { att1, att2, att3 }; // Set values for putItemInput. putItemInput.setItem(MinimalMap<AttributeValue>(itemArray, 3)); putItemInput.setTableName(TABLE_NAME); // perform putItem and check for errors. PutItemOutput putItemOutput = ddbClient.putItem(putItemInput, actionError); switch (actionError) { case NONE_ACTIONERROR: Serial.println("DynamoDB PutItem succeeded!"); break; case INVALID_REQUEST_ACTIONERROR: Serial.print("ERROR: "); Serial.println(putItemOutput.getErrorMessage().getCStr()); break; case MISSING_REQUIRED_ARGS_ACTIONERROR: Serial.println("ERROR: Required arguments were not set for PutItemInput"); break; case RESPONSE_PARSING_ACTIONERROR: Serial.println("ERROR: Problem parsing http response of PutItem"); break; case CONNECTION_ACTIONERROR: Serial.println("ERROR: Connection problem"); break; } }
InterfaceConstructor(ObjectValue* object, std::string iid) : constructor(object), arguments(new FormalParameterList), prototype(new InterfacePrototypeValue), iid(iid) { arguments->add(new Identifier("object")); object->setParameterList(arguments); object->setScope(getGlobal()); Reflect::Interface interface = es::getInterface(iid.c_str()); // PRINTF("interface: %s\n", interface.getName().c_str()); for (int i = 0; i < interface.getMethodCount(); ++i) { // Construct Method object Reflect::Method method(interface.getMethod(i)); if (prototype->hasProperty(method.getName())) { if (method.isOperation()) { // XXX Currently overloaded functions are just ignored. } else { AttributeValue* attribute = static_cast<AttributeValue*>(prototype->get(method.getName())); if (method.isGetter()) { attribute->addGetter(i); } else { attribute->addSetter(i); } } } else { if (method.isOperation()) { ObjectValue* function = new ObjectValue; function->setCode(new InterfaceMethodCode(function, iid.c_str(), i)); prototype->put(method.getName(), function); #if 0 if (method.isIndexGetter()) { AttributeGetterValue* getter = new AttributeGetterValue(iid, i); prototype->setOpObject(InterfacePrototypeValue::IndexGetter, getter); } else if (method.isIndexSetter()) { AttributeSetterValue* setter = new AttributeSetterValue(iid, i); prototype->setOpObject(InterfacePrototypeValue::IndexSetter, setter); } else if (method.isNameGetter()) { AttributeGetterValue* getter = new AttributeGetterValue(iid, i); prototype->setOpObject(InterfacePrototypeValue::NameGetter, getter); } else if (method.isNameSetter()) { AttributeSetterValue* setter = new AttributeSetterValue(iid, i); prototype->setOpObject(InterfacePrototypeValue::NameSetter, setter); } #endif } else { // method is an attribute AttributeValue* attribute = new AttributeValue(iid.c_str()); if (method.isGetter()) { attribute->addGetter(i); } else { attribute->addSetter(i); } prototype->put(method.getName(), attribute); } } } if (interface.getQualifiedSuperName() == "") { prototype->setPrototype(getGlobal()->get("InterfaceStore")->getPrototype()->getPrototype()); } else { Reflect::Interface super = es::getInterface(interface.getQualifiedSuperName().c_str()); prototype->setPrototype(getGlobal()->get(super.getName())->get("prototype")); } // Create Interface.prototype prototype->put("constructor", object); object->put("prototype", prototype); }
OwnedAttributeValue::OwnedAttributeValue(const AttributeValue& other) : AttributeValue(other.getAttribute(), other.getAttribute() ? other.copy() : NULL) { }
AttributeValue SpannerPackedNormalAttribute::inherit(const AttributeValue& parentValue) const { return AttributeValue(parentValue.getAttribute()); }
AttributeValue SpannerQRgbAttribute::inherit(const AttributeValue& parentValue) const { return AttributeValue(parentValue.getAttribute()); }
void CreatureStats::setAttribute(int index, int base) { AttributeValue current = getAttribute(index); current.setBase(base); setAttribute(index, current); }
MetavoxelNode::MetavoxelNode(const AttributeValue& attributeValue) : _referenceCount(1) { _attributeValue = attributeValue.copy(); for (int i = 0; i < CHILD_COUNT; i++) { _children[i] = NULL; } }
void MetavoxelNode::setAttributeValue(const AttributeValue& attributeValue) { attributeValue.getAttribute()->destroy(_attributeValue); _attributeValue = attributeValue.copy(); clearChildren(attributeValue.getAttribute()); }
inline bool operator== (const AttributeValue& left, const AttributeValue& right) { return left.getBase() == right.getBase() && left.getModifier() == right.getModifier() && left.getDamage() == right.getDamage(); }