void NTNDArrayRecord::update()
{
    lock();
    try
    {
        beginGroupPut();
        PVUByteArray::svector bytes;
        imageGen->fillSharedVector(bytes,angle);
        setValue(freeze(bytes));
        if (firstTime)
        {
            int dims[] = { imageGen->getWidth(), imageGen->getHeight() };
            setDimension(dims, 2);
            setAttributes();
            setSizes(static_cast<int64_t>(imageGen->getSize()));
            firstTime = false;
        }
        setDataTimeStamp();
        setUniqueId(count++);
        process();
        endGroupPut();
    }
    catch(...)
    {
        unlock();
        throw;
    }
    angle += 1;
    unlock();
}
Example #2
0
LadspaPluginInfo::LadspaPluginInfo (const QString &path, 
    const LADSPA_Descriptor *desc) :
  PluginInfo(),
  m_path(path),
  m_descriptor(desc)
{
  printf("PATH %s %s\n",qPrintable(path), desc->Name);
  setName(desc->Name);
  setAuthorName(desc->Maker);
  setUniqueId(QString("%1%2").arg( UriRoot ).arg( m_descriptor->UniqueID ));

  int inCnt = 0, outCnt = 0;
  for (unsigned long i=0; i < desc->PortCount; ++i) {
    LADSPA_PortDescriptor p = desc->PortDescriptors[i];
    if (LADSPA_IS_PORT_AUDIO(p)) {
      if (LADSPA_IS_PORT_INPUT(p)) {
        ++inCnt;
      }
      else if (LADSPA_IS_PORT_OUTPUT(p)) {
        ++outCnt;
      }
    }
  }

  setAudioInputCount(inCnt);
  setAudioOutputCount(outCnt);
}
Example #3
0
MockInputDeviceNode* getAsusGamepad() {
    auto node = new MockInputDeviceNode();
    node->setPath("/dev/input/event3");
    node->setName("ASUS Gamepad");
    // Location not set
    node->setUniqueId("C5:30:CD:50:A0:54");
    node->setBusType(0x0005);
    node->setVendorId(0x0b05);
    node->setProductId(0x4500);
    node->setVersion(0x0040);
    node->addKeys(KEY_BACK, KEY_HOMEPAGE, BTN_A, BTN_B, BTN_X, BTN_Y, BTN_TL, BTN_TR,
            BTN_MODE, BTN_THUMBL, BTN_THUMBR);
    // No relative axes
    node->addAbsAxis(ABS_X, nullptr);
    node->addAbsAxis(ABS_Y, nullptr);
    node->addAbsAxis(ABS_Z, nullptr);
    node->addAbsAxis(ABS_RZ, nullptr);
    node->addAbsAxis(ABS_GAS, nullptr);
    node->addAbsAxis(ABS_BRAKE, nullptr);
    node->addAbsAxis(ABS_HAT0X, nullptr);
    node->addAbsAxis(ABS_HAT0Y, nullptr);
    node->addAbsAxis(ABS_MISC, nullptr);
    node->addAbsAxis(0x29, nullptr);
    node->addAbsAxis(0x2a, nullptr);
    // No switches
    node->addInputProperty(INPUT_PROP_DIRECT);
    // Note: this device has MSC and LED bitmaps as well.
    return node;
}
Example #4
0
 FeatureHandle::FeatureHandle(UInt64 map_index, const Peak2D& point, UInt64 element_index) :
   Peak2D(point),
   map_index_(map_index),
   charge_(0),
   width_(0)
 {
   setUniqueId(element_index);
 }
Example #5
0
 /**
  * Creates completely new ConnectionSettings by cloning this record.
  */
 ConnectionSettings *ConnectionSettings::clone() const
 {
     auto settings = new ConnectionSettings(true);
     settings->setUniqueId(_uniqueId);
     settings->setUuid(_uuid);
     settings->apply(this);
     return settings;
 }
Example #6
0
void Item::makeUnique(Item* parent)
{
	if(!parent || !parent->getUniqueId())
		return;

	ScriptEnviroment::removeUniqueThing(parent);
	setUniqueId(parent->getUniqueId());
	parent->eraseAttribute("uid");
}
Example #7
0
void Association::readXml(QDomElement node, QuLC::XmlModelReader& reader) {
    reader.ensureLoaded(node.attribute("source"));
    reader.ensureLoaded(node.attribute("target"));

    setUniqueId(node.attribute("id"));
    setSource(dynamic_cast<Classifier*>(
                Element::byId(node.attribute("source"))));
    setTarget(dynamic_cast<Classifier*>(
                Element::byId(node.attribute("target"))));
    setAggregation(aggregationKindFromString(node.attribute("aggregation")));
}
Example #8
0
bool Item::unserialize(xmlNodePtr nodeItem)
{
	int intValue;
	std::string strValue;

	if(readXMLInteger(nodeItem, "id", intValue)){
		id = intValue;
	}
	else{
		return false;
	}

	if(readXMLInteger(nodeItem, "count", intValue)){
		setSubType(intValue);
	}

	if(readXMLString(nodeItem, "special_description", strValue)){
		setSpecialDescription(strValue);
	}

	if(readXMLString(nodeItem, "text", strValue)){
		setText(strValue);
	}

	if(readXMLInteger(nodeItem, "written_date", intValue)){
		setWrittenDate(intValue);
	}

	if(readXMLString(nodeItem, "writer", strValue)){
		setWriter(strValue);
	}

	if(readXMLInteger(nodeItem, "actionId", intValue)){
		setActionId(intValue);
	}

	if(readXMLInteger(nodeItem, "uniqueId", intValue)){
		setUniqueId(intValue);
	}

	if(readXMLInteger(nodeItem, "duration", intValue)){
		setDuration(intValue);
	}

	if(readXMLInteger(nodeItem, "decayState", intValue)){
		ItemDecayState_t decayState = (ItemDecayState_t)intValue;
		if(decayState != DECAYING_FALSE){
			setDecaying(DECAYING_PENDING);
		}
	}

	return true;
}
Example #9
0
MockInputDeviceNode* getNexusRemote() {
    auto node = new MockInputDeviceNode();
    node->setPath("/dev/input/event2");
    node->setName("Nexus Remote");
    // Location not set
    node->setUniqueId("78:86:D9:50:A0:54");
    node->setBusType(0x0005);
    node->setVendorId(0x18d1);
    node->setProductId(0x2c42);
    node->setVersion(0);
    node->addKeys(KEY_UP, KEY_LEFT, KEY_RIGHT, KEY_DOWN, KEY_BACK, KEY_PLAYPAUSE,
            KEY_HOMEPAGE, KEY_SEARCH, KEY_SELECT);
    // No relative axes
    node->addAbsAxis(ABS_MISC, nullptr);
    // No switches
    node->addInputProperty(INPUT_PROP_DIRECT);
    return node;
}
Example #10
0
bool Item::unserialize(xmlNodePtr nodeItem)
{
	char* nodeValue;
	nodeValue = (char*)xmlGetProp(nodeItem, (const xmlChar *) "id");
	if(nodeValue){
		id = atoi(nodeValue);
		xmlFreeOTSERV(nodeValue);
	}
	else
		return false;
	
	nodeValue = (char*)xmlGetProp(nodeItem, (const xmlChar *) "count");
	if(nodeValue){
		setItemCountOrSubtype(atoi(nodeValue));
		xmlFreeOTSERV(nodeValue);
	}

	nodeValue = (char*)xmlGetProp(nodeItem, (const xmlChar *) "special_description");
	if(nodeValue){
		specialDescription = new std::string(nodeValue);
		xmlFreeOTSERV(nodeValue);
	}
		
	nodeValue = (char*)xmlGetProp(nodeItem, (const xmlChar *) "text");
	if(nodeValue){
		text = new std::string(nodeValue);
		xmlFreeOTSERV(nodeValue);
	}
		
	nodeValue = (char*)xmlGetProp(nodeItem, (const xmlChar *) "actionId");
	if(nodeValue){
		setActionId(atoi(nodeValue));
		xmlFreeOTSERV(nodeValue);
	}
	
	nodeValue = (char*)xmlGetProp(nodeItem, (const xmlChar *) "uniqueId");
	if(nodeValue){
		setUniqueId(atoi(nodeValue));
		xmlFreeOTSERV(nodeValue);
	}
	
	return true;
}
Example #11
0
Attr_ReadValue Item::readAttr(AttrTypes_t attr, PropStream& propStream)
{
	switch (attr) {
		case ATTR_COUNT: {
			uint8_t _count = 0;

			if (!propStream.GET_UCHAR(_count)) {
				return ATTR_READ_ERROR;
			}

			setSubType(_count);
			break;
		}

		case ATTR_ACTION_ID: {
			uint16_t _actionid = 0;

			if (!propStream.GET_USHORT(_actionid)) {
				return ATTR_READ_ERROR;
			}

			setActionId(_actionid);
			break;
		}

		case ATTR_UNIQUE_ID: {
			uint16_t _uniqueid;

			if (!propStream.GET_USHORT(_uniqueid)) {
				return ATTR_READ_ERROR;
			}

			setUniqueId(_uniqueid);
			break;
		}

		case ATTR_TEXT: {
			std::string _text;

			if (!propStream.GET_STRING(_text)) {
				return ATTR_READ_ERROR;
			}

			setText(_text);
			break;
		}

		case ATTR_WRITTENDATE: {
			uint32_t _writtenDate;

			if (!propStream.GET_ULONG(_writtenDate)) {
				return ATTR_READ_ERROR;
			}

			setDate(_writtenDate);
			break;
		}

		case ATTR_WRITTENBY: {
			std::string _writer;

			if (!propStream.GET_STRING(_writer)) {
				return ATTR_READ_ERROR;
			}

			setWriter(_writer);
			break;
		}

		case ATTR_DESC: {
			std::string _text;

			if (!propStream.GET_STRING(_text)) {
				return ATTR_READ_ERROR;
			}

			setSpecialDescription(_text);
			break;
		}

		case ATTR_RUNE_CHARGES: {
			uint8_t _charges = 1;

			if (!propStream.GET_UCHAR(_charges)) {
				return ATTR_READ_ERROR;
			}

			setSubType(_charges);
			break;
		}

		case ATTR_CHARGES: {
			uint16_t _charges = 1;

			if (!propStream.GET_USHORT(_charges)) {
				return ATTR_READ_ERROR;
			}

			setSubType(_charges);
			break;
		}

		case ATTR_DURATION: {
			uint32_t duration = 0;

			if (!propStream.GET_ULONG(duration)) {
				return ATTR_READ_ERROR;
			}

			if (((int32_t)duration) < 0) {
				duration = 0;
			}

			setDuration(duration);
			break;
		}

		case ATTR_DECAYING_STATE: {
			uint8_t state = 0;

			if (!propStream.GET_UCHAR(state)) {
				return ATTR_READ_ERROR;
			}

			if (state != DECAYING_FALSE) {
				setDecaying(DECAYING_PENDING);
			}

			break;
		}

		//these should be handled through derived classes
		//If these are called then something has changed in the items.xml since the map was saved
		//just read the values

		//Depot class
		case ATTR_DEPOT_ID: {
			uint16_t _depotId;

			if (!propStream.GET_USHORT(_depotId)) {
				return ATTR_READ_ERROR;
			}

			return ATTR_READ_CONTINUE;
		}

		//Door class
		case ATTR_HOUSEDOORID: {
			uint8_t _doorId;

			if (!propStream.GET_UCHAR(_doorId)) {
				return ATTR_READ_ERROR;
			}

			return ATTR_READ_CONTINUE;
		}

		//Bed class
		case ATTR_SLEEPERGUID: {
			uint32_t _guid;

			if (!propStream.GET_ULONG(_guid)) {
				return ATTR_READ_ERROR;
			}

			return ATTR_READ_CONTINUE;
		}

		case ATTR_SLEEPSTART: {
			uint32_t sleep_start;

			if (!propStream.GET_ULONG(sleep_start)) {
				return ATTR_READ_ERROR;
			}

			return ATTR_READ_CONTINUE;
		}

		//Teleport class
		case ATTR_TELE_DEST: {
			TeleportDest* tele_dest;

			if (!propStream.GET_STRUCT(tele_dest)) {
				return ATTR_READ_ERROR;
			}

			return ATTR_READ_CONTINUE;
		}

		//Container class
		case ATTR_CONTAINER_ITEMS: {
			uint32_t count;

			if (!propStream.GET_ULONG(count)) {
				return ATTR_READ_ERROR;
			}

			return ATTR_READ_ERROR;
		}

		default:
			return ATTR_READ_ERROR;
	}

	return ATTR_READ_CONTINUE;
}
Example #12
0
Attr_ReadValue Item::readAttr(AttrTypes_t attr, PropStream& propStream)
{
	switch(attr)
	{
		case ATTR_COUNT:
		{
			uint8_t _count;
			if(!propStream.getByte(_count))
				return ATTR_READ_ERROR;

			setSubType((uint16_t)_count);
			break;
		}

		case ATTR_ACTION_ID:
		{
			uint16_t aid;
			if(!propStream.getShort(aid))
				return ATTR_READ_ERROR;

			setAttribute("aid", aid);
			break;
		}

		case ATTR_UNIQUE_ID:
		{
			uint16_t uid;
			if(!propStream.getShort(uid))
				return ATTR_READ_ERROR;

			setUniqueId(uid);
			break;
		}

		case ATTR_NAME:
		{
			std::string name;
			if(!propStream.getString(name))
				return ATTR_READ_ERROR;

			setAttribute("name", name);
			break;
		}

		case ATTR_PLURALNAME:
		{
			std::string name;
			if(!propStream.getString(name))
				return ATTR_READ_ERROR;

			setAttribute("pluralname", name);
			break;
		}

		case ATTR_ARTICLE:
		{
			std::string article;
			if(!propStream.getString(article))
				return ATTR_READ_ERROR;

			setAttribute("article", article);
			break;
		}

		case ATTR_ATTACK:
		{
			int32_t attack;
			if(!propStream.getLong((uint32_t&)attack))
				return ATTR_READ_ERROR;

			setAttribute("attack", attack);
			break;
		}

		case ATTR_EXTRAATTACK:
		{
			int32_t attack;
			if(!propStream.getLong((uint32_t&)attack))
				return ATTR_READ_ERROR;

			setAttribute("extraattack", attack);
			break;
		}

		case ATTR_DEFENSE:
		{
			int32_t defense;
			if(!propStream.getLong((uint32_t&)defense))
				return ATTR_READ_ERROR;

			setAttribute("defense", defense);
			break;
		}

		case ATTR_EXTRADEFENSE:
		{
			int32_t defense;
			if(!propStream.getLong((uint32_t&)defense))
				return ATTR_READ_ERROR;

			setAttribute("extradefense", defense);
			break;
		}

		case ATTR_ARMOR:
		{
			int32_t armor;
			if(!propStream.getLong((uint32_t&)armor))
				return ATTR_READ_ERROR;

			setAttribute("armor", armor);
			break;
		}

		case ATTR_ATTACKSPEED:
		{
			int32_t attackSpeed;
			if(!propStream.getLong((uint32_t&)attackSpeed))
				return ATTR_READ_ERROR;

			setAttribute("attackspeed", attackSpeed);
			break;
		}

		case ATTR_HITCHANCE:
		{
			int32_t hitChance;
			if(!propStream.getLong((uint32_t&)hitChance))
				return ATTR_READ_ERROR;

			setAttribute("hitchance", hitChance);
			break;
		}

		case ATTR_SCRIPTPROTECTED:
		{
			uint8_t protection;
			if(!propStream.getByte(protection))
				return ATTR_READ_ERROR;

			setAttribute("scriptprotected", protection != 0);
			break;
		}

		case ATTR_DUALWIELD:
		{
			uint8_t wield;
			if(!propStream.getByte(wield))
				return ATTR_READ_ERROR;

			setAttribute("dualwield", wield != 0);
			break;
		}

		case ATTR_TEXT:
		{
			std::string text;
			if(!propStream.getString(text))
				return ATTR_READ_ERROR;

			setAttribute("text", text);
			break;
		}

		case ATTR_WRITTENDATE:
		{
			int32_t date;
			if(!propStream.getLong((uint32_t&)date))
				return ATTR_READ_ERROR;

			setAttribute("date", date);
			break;
		}

		case ATTR_WRITTENBY:
		{
			std::string writer;
			if(!propStream.getString(writer))
				return ATTR_READ_ERROR;

			setAttribute("writer", writer);
			break;
		}

		case ATTR_DESC:
		{
			std::string text;
			if(!propStream.getString(text))
				return ATTR_READ_ERROR;

			setAttribute("description", text);
			break;
		}

		case ATTR_RUNE_CHARGES:
		{
			uint8_t charges;
			if(!propStream.getByte(charges))
				return ATTR_READ_ERROR;

			setSubType((uint16_t)charges);
			break;
		}

		case ATTR_CHARGES:
		{
			uint16_t charges;
			if(!propStream.getShort(charges))
				return ATTR_READ_ERROR;

			setSubType(charges);
			break;
		}

		case ATTR_DURATION:
		{
			int32_t duration;
			if(!propStream.getLong((uint32_t&)duration))
				return ATTR_READ_ERROR;

			setAttribute("duration", duration);
			break;
		}

		case ATTR_DECAYING_STATE:
		{
			uint8_t state;
			if(!propStream.getByte(state))
				return ATTR_READ_ERROR;

			if((ItemDecayState_t)state != DECAYING_FALSE)
				setAttribute("decaying", (int32_t)DECAYING_PENDING);

			break;
		}

		//these should be handled through derived classes
		//if these are called then something has changed in the items.otb since the map was saved
		//just read the values

		//Depot class
		case ATTR_DEPOT_ID:
		{
			uint16_t depot;
			if(!propStream.getShort(depot))
				return ATTR_READ_ERROR;

			break;
		}

		//Door class
		case ATTR_HOUSEDOORID:
		{
			uint8_t door;
			if(!propStream.getByte(door))
				return ATTR_READ_ERROR;

			break;
		}

		//Teleport class
		case ATTR_TELE_DEST:
		{
			TeleportDest* dest;
			if(!propStream.getStruct(dest))
				return ATTR_READ_ERROR;

			break;
		}

		//Bed class
		case ATTR_SLEEPERGUID:
		{
			uint32_t sleeper;
			if(!propStream.getLong(sleeper))
				return ATTR_READ_ERROR;

			break;
		}

		case ATTR_SLEEPSTART:
		{
			uint32_t sleepStart;
			if(!propStream.getLong(sleepStart))
				return ATTR_READ_ERROR;

			break;
		}

		//Container class
		case ATTR_CONTAINER_ITEMS:
		{
			uint32_t _count;
			propStream.getLong(_count);
			return ATTR_READ_ERROR;
		}

		//ItemAttributes class
		case ATTR_ATTRIBUTE_MAP:
		{
			bool unique = hasIntegerAttribute("uid"), ret = unserializeMap(propStream);
			if(!unique && hasIntegerAttribute("uid")) // unfortunately we have to do this
				ScriptEnviroment::addUniqueThing(this);

			// this attribute has a custom behavior as well
			if(getDecaying() != DECAYING_FALSE)
				setDecaying(DECAYING_PENDING);

			if(ret)
				break;
		}

		default:
			return ATTR_READ_ERROR;
	}

	return ATTR_READ_CONTINUE;
}
Example #13
0
bool Item::readAttr(AttrTypes_t attr, PropStream& propStream)
{
	switch(attr){
		case ATTR_COUNT:
		{
			unsigned char _count = 0;
			if(!propStream.GET_UCHAR(_count)){
				return false;
			}

			setItemCountOrSubtype(_count);
			break;
		}

		case ATTR_ACTION_ID:
		{
			unsigned short _actionid = 0;
			if(!propStream.GET_USHORT(_actionid)){
				return false;
			}

			setActionId(_actionid);
			break;
		}

		case ATTR_UNIQUE_ID:
		{
			unsigned short _uniqueid;
			if(!propStream.GET_USHORT(_uniqueid)){
				return false;
			}
			
			setUniqueId(_uniqueid);
			break;
		}

		case ATTR_TEXT:
		{
			std::string _text;
			if(!propStream.GET_STRING(_text)){
				return false;
			}

			setText(_text);
			break;
		}

		case ATTR_DESC:
		{
			std::string _text;
			if(!propStream.GET_STRING(_text)){
				return false;
			}

			setSpecialDescription(_text);
			break;
		}

		case ATTR_RUNE_CHARGES:
		{
			unsigned char _charges = 1;
			if(!propStream.GET_UCHAR(_charges)){
				return false;
			}

			setItemCountOrSubtype(_charges);
			break;
		}

		//these should be handled through derived classes
		//If these are called then something has changed in the items.otb since the map was saved
		//just read the values

		//Depot class
		case ATTR_DEPOT_ID:
		{
			unsigned short _depotId;
			if(!propStream.GET_USHORT(_depotId)){
				return false;
			}
			
			return true;
		}

		//Door class
		case ATTR_HOUSEDOORID:
		{
			unsigned char _doorId;
			if(!propStream.GET_UCHAR(_doorId)){
				return false;
			}
			
			return true;
		}
	
		//Teleport class
		case ATTR_TELE_DEST:
		{
			TeleportDest* tele_dest;
			if(!propStream.GET_STRUCT(tele_dest)){
				return false;
			}

			return true;
		}

		default:
			return false;
		break;
	}

	return true;
}