Beispiel #1
0
bool QvernoteStorage::createNotebook(Notebook& newNotebook)
{
	newNotebook.guid = getGuid().toStdString();
	newNotebook.updateSequenceNum = 0;
	QNotebook::store(getDB(), newNotebook);
	return true;
}
void CellAutomataAgent::handleOpPartition(PPtr<Message> msg) {
  Ptr<KGrid> partitionMap = msg->getPayload().AS(KGrid);
  Ptr<KRecord> r = new KRecord(partitionMap);
  Ptr< ManagedArray<Partition> > allPartitions = new ManagedArray<Partition>();
  for(RangeIterator i(partitionMap->getRange()); i.hasMore(); i.next()) {
    Ptr<Partition> p = new Partition(partitionMap->at(i, r));
    if(p->guid == getGuid()) {
      _local = p;
    } else {
      allPartitions->push(p);
    }
  }
  
  if(_local.isNull()) {
    LOG_ERR << "No partition for this node" << EL;
    return;
  }
  
  for(int i = allPartitions->getSize() - 1; i >= 0; i--) {
    if(allPartitions->at(i)->rect.isAdjecentTo(_local->rect)) {
      _neighbours->push(allPartitions->at(i));
    }
  }
  
  _computeThread->start();
}
Beispiel #3
0
bool QvernoteStorage::createTag(Tag& newTag)
{
	newTag.guid = getGuid().toStdString();
	newTag.updateSequenceNum = 0;
	QTag::store(getDB(), newTag);
	return true;
}
Beispiel #4
0
Creature* Transporter::AddNPCPassengerInInstance(uint32 entry, float x, float y, float z, float o, uint32 /*anim*/)
{
    MapMgr* map = GetMapMgr();

    CreatureProperties const* creature_properties = sMySQLStore.getCreatureProperties(entry);
    if (creature_properties == nullptr || map == nullptr)
        return nullptr;

#if VERSION_STRING != Cata
    float transporter_x = obj_movement_info.transport_data.relativePosition.x + x;
    float transporter_y = obj_movement_info.transport_data.relativePosition.y + y;
    float transporter_z = obj_movement_info.transport_data.relativePosition.z + z;
#else
    float transporter_x = obj_movement_info.getTransportPosition()->x + x;
    float transporter_y = obj_movement_info.getTransportPosition()->y + y;
    float transporter_z = obj_movement_info.getTransportPosition()->z + z;
#endif

    Creature* pCreature = map->CreateCreature(entry);
    pCreature->Create(map->GetMapId(), transporter_x, transporter_y, transporter_z, (std::atan2(transporter_x, transporter_y) + float(M_PI)) + o);
    pCreature->Load(creature_properties, transporter_x, transporter_y, transporter_z, (std::atan2(transporter_x, transporter_y) + float(M_PI)) + o);
    pCreature->AddToWorld(map);
    pCreature->SetUnitMovementFlags(MOVEFLAG_TRANSPORT);
#if VERSION_STRING != Cata
    pCreature->obj_movement_info.transport_data.relativePosition.x = x;
    pCreature->obj_movement_info.transport_data.relativePosition.y = y;
    pCreature->obj_movement_info.transport_data.relativePosition.z = z;
    pCreature->obj_movement_info.transport_data.relativePosition.o = o;
    pCreature->obj_movement_info.transport_data.transportGuid = getGuid();
#else
    pCreature->obj_movement_info.setTransportData(getGuid(), x, y, z, o, 0, 0);
#endif

    pCreature->m_transportData.transportGuid = this->getGuid();
    pCreature->m_transportData.relativePosition.x = x;
    pCreature->m_transportData.relativePosition.y = y;
    pCreature->m_transportData.relativePosition.z = z;
    pCreature->m_transportData.relativePosition.o = o;
    m_creatureSetMutex.Acquire();
    m_NPCPassengerSet.insert(pCreature);
    m_creatureSetMutex.Release();
    return pCreature;
}
Beispiel #5
0
bool QvernoteStorage::createNote(Note& newNote)
{
	newNote.guid = getGuid().toStdString();
	newNote.active = true;
	qlonglong creationTime = QDateTime::currentDateTime().toUTC().toTime_t();
	creationTime *= 1000;
	newNote.created = creationTime;
	newNote.updateSequenceNum = 0;

	// Update resource Guid
	for(vector<Resource>::iterator i = newNote.resources.begin(); i != newNote.resources.end(); i++)
	{
		(*i).guid = getGuid().toStdString();
		(*i).noteGuid = newNote.guid;
		(*i).active = true;
		(*i).updateSequenceNum = 0;
	}

	QNote::store(getDB(), newNote);
	return true;
}
//
// Creation of the string representing the GUID, the buffer must be able
// to hold 22 characters + 1 for the terminating 0
//
char * CreateCompressedGuidString( char * buf, int len )
{
	GUID				guid;

	guid = GUID_NULL;

   //
   // Call to the function from Microsoft
   //
	getGuid(&guid);

	if (memcmp (&GUID_NULL, &guid, sizeof (GUID)) == 0) {
		return 0;
	}
	return getString64FromGuid (&guid, buf, len);
}
std::wstring CreateCompressedGuidString22()
{
	GUID guid = GUID_NULL;

	char guid_buf[23];
	int len = 23;

	// Call to the function from Microsoft
	getGuid(&guid);

	if (memcmp (&GUID_NULL, &guid, sizeof (GUID)) == 0)
	{
		return 0;
	}
	std::string guid_str = getString64FromGuid (&guid, guid_buf, len);
	std::wstring guid_wstr;
	guid_wstr.assign(guid_str.begin(), guid_str.end());
	return guid_wstr;
}
Beispiel #8
0
bool QvernoteStorage::updateNote(Note& existingNote)
{
	// Do not increment usn on new notes, otherwise we wont sync them with server as new notes
	if(existingNote.updateSequenceNum != 0)
		existingNote.updateSequenceNum++;

	// Update resource Guid
	for(vector<Resource>::iterator i = existingNote.resources.begin(); i != existingNote.resources.end(); i++)
	{
		if((*i).guid.empty())
			(*i).guid = getGuid().toStdString();

		(*i).noteGuid = existingNote.guid;
	}

	QNote::update(getDB(), existingNote);

	if(existingNote.updateSequenceNum != 0)
		QItem::setDirtyFlag(getDB(), "notes", "guid", QString::fromStdString(existingNote.guid), 1);

	return true;
}
	void LeapMotionHandler::leapDraw(bool& lockCurrentFrame, bool proxActive, drawing::Illustrator& illustrator)
	{
		proxActive = false;
		if (proxActive)
		{
			return;
		}

		//Get all pointables from current leap frame
		Leap::PointableList pointables = this->currentFrame.pointables();
		//Gets a virtual rectangular prism which is within the field of view of Leap
		Leap::InteractionBox iBox = this->currentFrame.interactionBox();

		auto fingerLocationCircles = vector<drawing::TouchCircle>();
		auto drawEventsToSendToIllustrator = vector<drawing::DrawEvent>();

		//Traverse all pointables
		for (auto& point : pointables)
		{
			//Normalize points from iBox
			Leap::Vector normalizedPosition = iBox.normalizePoint(point.stabilizedTipPosition());
			//Get x and y coordinate value form normalized value within given window
			float leapXCoordinate = normalizedPosition.x * windowWidth;
			float leapYCoordinate = windowHeight - normalizedPosition.y * windowHeight;

			float touchDistance = point.touchDistance();

			auto currentPoint = vec2(leapXCoordinate, leapYCoordinate);
			auto pointId = point.id();
			auto guid = getGuid(pointId);
			int eventMaxLifeSpan = 1;

			if (touchDistance > 0 && point.touchZone() != Leap::Pointable::Zone::ZONE_NONE)
			{
				auto color = distanceToColor(touchDistance);
				fingerLocationCircles.push_back(drawing::TouchCircle(currentPoint, 40.0f, color, 50.0f, true, 1));

				auto finalizableDrawEventIterator = finalizeableDrawEvents.find(guid);
				bool finilizableDrawEventWasFound = finalizableDrawEventIterator != finalizeableDrawEvents.end();
				if (finilizableDrawEventWasFound)
				{
					auto finalizableEvent = finalizableDrawEventIterator->second;
					//finalize that sumbitch send it to the illustrator
					finalizableEvent.SetEndPoint(currentPoint);
					drawEventsToSendToIllustrator.push_back(finalizableEvent);
					//delete it from finalizeableDrawEvents
					finalizeableDrawEvents.erase(finalizableDrawEventIterator);
					//remove guid associated with this event
					pointIdToGuidMap.erase(pointId);
				}
			}
			if(touchDistance < 0)
			{
				lockCurrentFrame = true;

				auto finalizableDrawEventIterator = finalizeableDrawEvents.find(guid);
				bool finalizableDrawEventWasFound = finalizableDrawEventIterator != finalizeableDrawEvents.end();
				
				if(finalizableDrawEventWasFound) //continuation of series of draw events
				{
					auto finalizableEvent = finalizableDrawEventIterator->second;

					//reset life of finilizable draw event, so it doesnt die
					finalizableEvent.ResetCurrentAge();

					//check if we are continuing any temp draw events
					auto tempDrawEventIterator = temporaryDrawEvents.find(guid);
					bool tempDrawEventWasFound = tempDrawEventIterator != temporaryDrawEvents.end();
					
					if (tempDrawEventWasFound) //continuation of previous temp draw event
					{
						auto tempDrawEvent = tempDrawEventIterator->second;
						//finish temp draw event
						tempDrawEvent.SetEndPoint(currentPoint);
						//send it off
						drawEventsToSendToIllustrator.push_back(tempDrawEvent);
						//remove from temporaryDrawEvents
						temporaryDrawEvents.erase(tempDrawEventIterator);
					}
					else
					{
						auto parentStartLocation = finalizableEvent.GetStartPoint();
						//create new temp draw event
						auto newTempDrawEvent = drawing::DrawEvent(currentPoint, parentStartLocation, guid, false, eventMaxLifeSpan);
						temporaryDrawEvents.insert_or_assign(guid, newTempDrawEvent);
					}
				}
				else //should be a new series of drawing events
				{
					//create new finilizable draw event
					auto newFinalizableDrawEvent = drawing::DrawEvent(currentPoint, guid, true, eventMaxLifeSpan);
					createPointIdToGuidMapping(pointId, guid);
					finalizeableDrawEvents.insert_or_assign(guid, newFinalizableDrawEvent);
				}
			}
		}

		if (fingerLocationCircles.size() > 0)
		{
			illustrator.addToTemporaryCircles(fingerLocationCircles);
		}

		if (drawEventsToSendToIllustrator.size() > 0)
		{
			illustrator.addDrawEventsToQueue(drawEventsToSendToIllustrator);
		}

		//increment all draw events lifespan
		//remove all those that exceed max life span
		for (auto it = begin(temporaryDrawEvents); it != end(temporaryDrawEvents);)
		{
			if (!it->second.ShouldBeAlive())
			{
				it = temporaryDrawEvents.erase(it);
			}
			else
				++it;
		}
		for (auto it = begin(finalizeableDrawEvents); it != end(finalizeableDrawEvents);)
		{
			if (!it->second.ShouldBeAlive())
			{
				it = finalizeableDrawEvents.erase(it);
			}
			else
				++it;
		}
	}
Beispiel #10
0
bool MHSyncItemInfo::isRemotelyAvailable() {
    return getGuid().empty() == false && getStatus() != EStatusUploading;
}
Beispiel #11
0
bool MHSyncItemInfo::isSynced() {
    return isLocallyAvailable() && getGuid().empty() == false &&
           (status != EStatusUploading) &&
           (status != EStatusLocalMetaDataChanged);
}
Beispiel #12
0
PEGASUS_NAMESPACE_BEGIN

String Guid::getGuid()
{
  return getGuid(String::EMPTY);
}