void SyncManagerImpl::AddCreateOpForElementRecurs(RemoteSyncPeer& peer, const ElementPtr& element)
{
	// Construct a CreateOperation for this element
	XGuid parentGuid = kInvalidXGuid;
	ElementPtr parent = element->GetParent();
	if (parent)
	{
		parentGuid = parent->GetGUID();
	}

	{
		CreateOperationPtr createOp = new CreateOperation(
			element->GetElementType(),
			element->GetName(),
			element->GetGUID(),
			parentGuid,
			element->GetXValue(),
			m_syncContext->GetAuthorityLevel(),
			m_syncContext);

		// Add to the list of outgoing ops
		peer.SendOp(createOp);
	}

	// If this is an object element...
	ObjectElementPtr objElement = ObjectElement::Cast(element);
	if (objElement)
	{
		// Recurs to the children of this element
		for (int32 i = 0; i < objElement->GetElementCount(); ++i)
		{
			AddCreateOpForElementRecurs(peer, objElement->GetElementAt(i));
		}
	}
	else
	{
		// If the element is an array, add Insert operations for all its entries
		ArrayElement* arrayElement = reflection_cast<ArrayElement>(element);
		if (arrayElement != nullptr)
		{
			int32 numEntries = arrayElement->GetCount();
			for (int32 i = 0; i < numEntries; ++i)
			{
				InsertOperationPtr insertOp = new InsertOperation(
					element->GetGUID(),
					i,
					arrayElement->GetXValue(i),
					m_syncContext->GetAuthorityLevel(),
					m_syncContext);

				// Add to the list of outgoing ops
				peer.SendOp(insertOp);
			}
		}
	}
}
Example #2
0
Handle<Value> ElementJs::setTags(const Arguments& args)
{
  HandleScope scope;

  ElementPtr e = ObjectWrap::Unwrap<ElementJs>(args.This())->getElement();

  if (!e)
  {
    return v8::ThrowException(HootExceptionJs::create(IllegalArgumentException(
      "Unable to set tags on a const Element.")));
  }

  Tags& tags = ObjectWrap::Unwrap<TagsJs>(args[0]->ToObject())->getTags();
  e->setTags(tags);

  return scope.Close(Undefined());
}
        //---------------------------------------------------------------------
        DocumentPtr LockboxContentGetRequest::encode()
        {
          DocumentPtr ret = IMessageHelper::createDocumentWithRoot(*this);
          ElementPtr root = ret->getFirstChildElement();

          String clientNonce = IHelper::randomString(32);

          LockboxInfo lockboxInfo;

          lockboxInfo.mAccessToken = mLockboxInfo.mAccessToken;
          if (mLockboxInfo.mAccessSecret.hasData()) {
            lockboxInfo.mAccessSecretProofExpires = zsLib::now() + Seconds(OPENPEER_STACK_MESSAGE_LOCKBOX_CONTENT_GET_REQUEST_EXPIRES_TIME_IN_SECONDS);
            lockboxInfo.mAccessSecretProof = IHelper::convertToHex(*IHelper::hmac(*IHelper::hmacKeyFromPassphrase(mLockboxInfo.mAccessSecret), "lockbox-access-validate:" + clientNonce + ":" + IHelper::timeToString(lockboxInfo.mAccessSecretProofExpires) + ":" + lockboxInfo.mAccessToken + ":lockbox-content-get"));
          }

          root->adoptAsLastChild(IMessageHelper::createElementWithText("nonce", clientNonce));
          if (lockboxInfo.hasData()) {
            root->adoptAsLastChild(MessageHelper::createElement(lockboxInfo));
          }

          ElementPtr namespacesEl = IMessageHelper::createElement("namespaces");

          for (NamespaceInfoMap::iterator iter = mNamespaceInfos.begin(); iter != mNamespaceInfos.end(); ++iter)
          {
            const NamespaceInfo &namespaceInfo = (*iter).second;
            namespacesEl->adoptAsLastChild(MessageHelper::createElement(namespaceInfo));
          }

          if (namespacesEl->hasChildren()) {
            root->adoptAsLastChild(namespacesEl);
          }

          return ret;
        }
Example #4
0
double RieszRep::getNorm(){

  if (_repsNotComputed){    
    cout << "Computing riesz rep dofs" << endl;
    computeRieszRep();
  }

  vector< ElementPtr > allElems = _mesh->activeElements(); 
  vector< ElementPtr >::iterator elemIt;     
  double normSum = 0.0;
  for (elemIt=allElems.begin();elemIt!=allElems.end();elemIt++){

    ElementPtr elem = *elemIt;
    int cellID = elem->cellID();
    normSum+= _rieszRepNormSquaredGlobal[cellID];
  }
  return sqrt(normSum);
}
Example #5
0
DOMTokenListImp::DOMTokenListImp(const ElementPtr& element, const std::u16string& localName) :
    element(element),
    localName(localName)
{
    if (!element)
        return;
    std::u16string value = element->getAttribute(localName);
    boost::algorithm::split(tokens, value, isSpace);
}
Example #6
0
void Stage::DestroyElement(ElementPtr inElement) {
    wxString name = inElement->GetName();

    // Make sure this element isn't on our drawing context stack.
    if (mDrawingContextStack->ContainsElement(inElement))
        gLog.Fatal("halyard.element",
                   "%s: Tried to delete element with an active drawing context",
                   inElement->GetLogName());

    // Clean up any dangling references to this object.
    if (inElement == mGrabbedElement)
        MouseUngrab(mGrabbedElement);
    if (inElement == mCurrentElement)
        mCurrentElement = ElementPtr();
    if (inElement == mCurrentElementNamedInStatusBar)
        mCurrentElementNamedInStatusBar = ElementPtr();
    MediaElementPtr as_media(inElement, dynamic_cast_tag());
    if (as_media && as_media == mWaitElement)
        EndWait();

    // If the element we're deleting is a CursorElement, then we need to
    // tell it to unregister itself, and then update the cursor we're
    // displaying in case it has changed.  This takes care of
    // mDesiredCursor and mActualCursor.
    shared_ptr<CursorElement> as_cursor_elem(inElement, dynamic_cast_tag());
    if (as_cursor_elem) {
        as_cursor_elem->UnregisterWithCursorManager(mCursorManager);

        Cursor *as_cursor(static_cast<Cursor*>(as_cursor_elem.get()));
        if (as_cursor == mDesiredCursor)
            ReplaceDisplayedCursorWithDefault();
        ASSERT(as_cursor != mDesiredCursor);
        ASSERT(as_cursor != mActualCursor);
    }

    // We don't have to destroy the object explicity, because the
    // ElementPtr smart-pointer class will take care of that for us.
    //
    // TODO - Implemented delayed destruction so element callbacks can
    // destroy the element they're attached to.

    gLog.Trace("halyard.element", "%s: Removed from stage",
               inElement->GetLogName());
}
Example #7
0
 void MenuList::fillComboBox()
 {
     if (MenuPopup * popup = findChildOfType<MenuPopup>())
     {
         for (size_t idx = 0; idx != popup->getChildCount(); ++idx)
         {
             ElementPtr child = popup->el()->children()[idx];
             if (MenuItem * item = child->component()->downcast<MenuItem>())
             {
                 std::string label = item->getLabel();
                 WinAPI::ComboBox_Add(handle(), label);
             }
         }
         if (popup->getChildCount() > 0)
         {
             WinAPI::ComboBox_SetSelectedIndex(handle(), 0);
         }
     }
 }
        //---------------------------------------------------------------------
        DocumentPtr SessionDeleteRequest::encode()
        {
          DocumentPtr ret = IMessageHelper::createDocumentWithRoot(*this);
          ElementPtr root = ret->getFirstChildElement();

          if (hasAttribute(AttributeType_Locations))
          {
            ElementPtr locationsEl = IMessageHelper::createElement("locations");
            root->adoptAsLastChild(locationsEl);

            for(StringList::const_iterator it = mLocations.begin(); it != mLocations.end(); ++it)
            {
              const String &loc = (*it);
              locationsEl->adoptAsLastChild(IMessageHelper::createElementWithID("location", loc));
            }
          }

          return ret;
        }
Example #9
0
double RieszRep::computeAlternativeNormSqOnCell(IPPtr ip, ElementPtr elem){
  GlobalIndexType cellID = elem->cellID();
  Teuchos::RCP<DofOrdering> testOrdering= elem->elementType()->testOrderPtr;
  bool testVsTest = true;
  Teuchos::RCP<BasisCache> basisCache =   BasisCache::basisCacheForCell(_mesh, cellID, testVsTest,1);

  int numDofs = testOrdering->totalDofs();
  FieldContainer<double> ipMat(1,numDofs,numDofs);
  ip->computeInnerProductMatrix(ipMat,testOrdering,basisCache);

  double sum = 0.0;
  for (int i = 0;i<numDofs;i++){
    for (int j = 0;j<numDofs;j++){
      sum += _rieszRepDofsGlobal[cellID](i)*_rieszRepDofsGlobal[cellID](j)*ipMat(0,i,j);
    }
  }
  
  return sum;
}
        DocumentPtr MultiPartyAPNSPushRequest::encode(message::MultiPartyAPNSPushRequest &msg)
        {
          DocumentPtr ret = IMessageHelper::createDocumentWithRoot(msg);
          ElementPtr root = ret->getFirstChildElement();

          if (msg.hasAttribute(message::MultiPartyAPNSPushRequest::AttributeType_UserID)) {
            root->adoptAsLastChild(IMessageHelper::createElementWithText("userID", msg.mUserID));
          }

          if (msg.hasAttribute(message::MultiPartyAPNSPushRequest::AttributeType_AccessKey)) {
            root->adoptAsLastChild(IMessageHelper::createElementWithText("accessKey", msg.mAccessKey));
          }

          if (msg.hasAttribute(message::MultiPartyAPNSPushRequest::AttributeType_AccessSecret)) {
            root->adoptAsLastChild(IMessageHelper::createElementWithText("accessSecret", msg.mAccessSecret));
          }

          if (msg.hasAttribute(message::MultiPartyAPNSPushRequest::AttributeType_LocationID)) {
            root->adoptAsLastChild(IMessageHelper::createElementWithText("locationID", msg.mLocationID));
          }

          if (msg.hasAttribute(message::MultiPartyAPNSPushRequest::AttributeType_MessageType)) {
            root->adoptAsLastChild(IMessageHelper::createElementWithText("messageType", msg.mMessageType));
          }

          if (msg.hasAttribute(message::MultiPartyAPNSPushRequest::AttributeType_MessageData)) {
            root->adoptAsLastChild(IMessageHelper::createElementWithText("messageData", msg.mMessageData));
          }

          if (msg.hasAttribute(message::MultiPartyAPNSPushRequest::AttributeType_UserIDs)) {
            String usersStr;

            typedef provisioning::IAccount::UserIDList UserIDList;
            for (UserIDList::iterator iter = msg.mUserIDs.begin(); iter != msg.mUserIDs.end(); ++iter)
            {
              const String &userID = (*iter);

              if (!userID.isEmpty()) {
                if (!usersStr.isEmpty()) {
                  usersStr += "," + userID;
                } else {
                  usersStr += userID;
                }
              }
            }

            if (!usersStr.isEmpty()) {
              root->adoptAsLastChild(IMessageHelper::createElementWithText("users", usersStr));
            }
          }

          return ret;
        }
Example #11
0
ElementPtr OsmApiDbSqlChangesetFileWriter::_getChangeElement(ConstElementPtr element)
{
  ElementPtr changeElement;
  switch (element->getElementType().getEnum())
  {
    case ElementType::Node:
      changeElement.reset(new Node(*boost::dynamic_pointer_cast<const Node>(element)));
      break;
    case ElementType::Way:
      changeElement.reset(new Way(*boost::dynamic_pointer_cast<const Way>(element)));
      break;
   case ElementType::Relation:
      changeElement.reset(new Relation(*boost::dynamic_pointer_cast<const Relation>(element)));
      break;
    default:
      throw HootException("Unknown element type");
  }
  return changeElement;
}
Example #12
0
      //-----------------------------------------------------------------------
      DocumentPtr MessageResult::encode(IPeerFilesPtr peerFile)
      {
        DocumentPtr ret = IMessageHelper::createDocumentWithRoot(*this);
        ElementPtr root = ret->getFirstChildElement();

        // <error>
        // <reason id=”301”>Moved Permanently</reason>
        // </error>

        ElementPtr reason = IMessageHelper::createElementWithText("reason", mErrorReason);
        if (0 != mErrorCode) {
          IMessageHelper::setAttributeID(reason, Stringize<WORD>(mErrorCode).string());
        }

        ElementPtr error = IMessageHelper::createElement("error");
        error->adoptAsLastChild(reason);

        root->adoptAsLastChild(error);
        return ret;
      }
Example #13
0
    ElementPtr Node::getRootElement() const
    {
      ElementPtr found;
      if (isElement()) {
        found = toElement();
      } else {
        found = getParentElement();
      }

      if (!found)
        return ElementPtr();

      ElementPtr parent = found->getParentElement();
      while (parent)
      {
        found = parent;
        parent = parent->getParentElement();
      }
      return found;
    }
Example #14
0
void Gamefield::addElement(ElementPtr const& elem) {
	{
		lock_guard<mutex> _lock(mMutexElements);
		mQuadTree->add(elem.get());
		mElements.push_back(elem);
	}
	{
		lock_guard<mutex> _lock(mMutexNewElements);
		mNewElements.push_back(elem);
	}
}
Example #15
0
 void XULParser::pushStack(ElementPtr inElement)
 {
     if (inElement)
     {
         if (mStack.empty())
         {
             assert(!mRootElement);
             mRootElement = inElement;
         }
         mStack.push(inElement.get());
     }
 }
Example #16
0
Handle<Value> ElementJs::setStatusString(const Arguments& args)
{
  HandleScope scope;

  try
  {
    QString statusStr = toCpp<QString>(args[0]);

    Status s = Status::fromString(statusStr);

    ElementPtr e = ObjectWrap::Unwrap<ElementJs>(args.This())->getElement();

    e->setStatus(s);
  }
  catch ( const HootException& e )
  {
    return v8::ThrowException(HootExceptionJs::create(e));
  }

  return scope.Close(Undefined());
}
        //---------------------------------------------------------------------
        IdentityAccessWindowRequestPtr IdentityAccessWindowRequest::create(
                                                                         ElementPtr root,
                                                                         IMessageSourcePtr messageSource
                                                                         )
        {
          IdentityAccessWindowRequestPtr ret(new IdentityAccessWindowRequest);
          MessageHelper::fill(*ret, root, messageSource);

          ElementPtr browserEl = root->findFirstChildElement("browser");
          if (browserEl) {
            String ready = IMessageHelper::getElementText(browserEl->findFirstChildElement("ready"));
            if (!ready.isEmpty()) {
              ret->mReady = ("true" == ready ? 1 : 0);
            }
            String visibility = IMessageHelper::getElementText(browserEl->findFirstChildElement("visibility"));
            if (!visibility.isEmpty()) {
              ret->mVisible = ("true" == visibility ? 1 : 0);
            }
          }
          return ret;
        }
Example #18
0
void OgrWriter::writeElement(ElementPtr &element, bool debug)
{
  //Unfortunately, this check also has to happen in addition to checking hasMoreElements.  See
  //explanation in ServicesDbReader::readNextElement.
  if (element.get())
  {
    Tags sourceTags = element->getTags();
    Tags destTags;
    for (Tags::const_iterator it = element->getTags().begin();
         it != element->getTags().end(); ++it)
    {
      if (sourceTags[it.key()] != "")
      {
        destTags.appendValue(it.key(), it.value());
      }
    }
    // Now that all the empties are gone, update our element
    element->setTags(destTags);

    if ( debug == true )
    {
      LOG_DEBUG(element->toString());
    }

    PartialOsmMapWriter::writePartial(element);
  }
}
HTMLFormControlsCollectionImp::HTMLFormControlsCollectionImp(const HTMLFormElementPtr& form) :
    length(0)
{
    ElementPtr i = form;
    while (i = i->getNextElement(form)) {
        if (isListedElement(i)) {
            std::u16string name;
            Nullable<std::u16string> a = i->getAttribute(u"name");
            if (a.hasValue())
                name = a.value();
            if (name.empty()) {
                a = i->getAttribute(u"id");
                if (a.hasValue())
                    name = a.value();
            }
            Object found = namedItem(name);
            if (!found) {
                map.insert(std::pair<const std::u16string, Object>(name, i));
                ++length;
                continue;
            }
            if (html::RadioNodeList::hasInstance(found)) {
                html::RadioNodeList r = interface_cast<html::RadioNodeList>(found);
                if (auto list = std::dynamic_pointer_cast<RadioNodeListImp>(r.self())) {
                    list->addItem(i);
                    ++length;
                }
                continue;
            }
            auto list = std::make_shared<RadioNodeListImp>();
            if (list) {
                list->addItem(interface_cast<Element>(found));
                list->addItem(i);
                ++length;
                map.erase(name);
                map.insert(std::pair<const std::u16string, Object>(name, list));
            }
        }
    }
}
        PeerToPeerPeerIdentifyRequestPtr PeerToPeerPeerIdentifyRequest::create(ElementPtr root)
        {
          PeerToPeerPeerIdentifyRequestPtr ret(new message::PeerToPeerPeerIdentifyRequest);

          if (root)
          {
            try
            {
              ElementPtr el;
              ElementPtr proofEl = root->findFirstChildElementChecked("proofBundle")->findFirstChildElementChecked("proof");

              ret->mID = IMessageHelper::getAttributeID(root);

              ret->mProofID = IMessageHelper::getAttributeID(proofEl);
              ret->mLocationID = IMessageHelper::getAttributeID(proofEl->findFirstChildElement("location"));
              ret->mFindSecret = IMessageHelper::getElementText(proofEl->findFirstChildElement("findSecret"));
              ret->mOneTimeKey = IMessageHelper::getAttributeID(proofEl->findFirstChildElement("oneTimeKey"));
              ret->mExpires = IMessageHelper::stringToTime(IMessageHelper::getElementText(proofEl->findFirstChildElement("expires")));
              ret->mUserAgent = IMessageHelper::getElementTextAndEntityDecode(proofEl->findFirstChildElement("userAgent"));
              ret->mPeerFilePublic = IPeerFilePublic::loadFromXML(proofEl->findFirstChildElement("peer"));
            }
            catch (Exceptions::CheckFailed &e) {}
          }

          return ret;
        }
Example #21
0
        //---------------------------------------------------------------------
        LockboxAccessResultPtr LockboxAccessResult::create(
                                                           ElementPtr rootEl,
                                                           IMessageSourcePtr messageSource
                                                           )
        {
          LockboxAccessResultPtr ret(new LockboxAccessResult);
          IMessageHelper::fill(*ret, rootEl, messageSource);

          ret->mLockboxInfo = MessageHelper::createLockbox(rootEl->findFirstChildElement("lockbox"));
          ret->mNamespaceGrantChallengeInfo = MessageHelper::createNamespaceGrantChallenge(rootEl->findFirstChildElement("namespaceGrantChallenge"));

          ElementPtr identitiesEl = rootEl->findFirstChildElement("identities");
          if (identitiesEl) {
            ElementPtr identityEl = identitiesEl->findFirstChildElement("identity");
            while (identityEl) {
              IdentityInfo info = MessageHelper::createIdentity(identityEl);
              if (info.hasData()) {
                ret->mIdentities.push_back(info);
              }
              identityEl = identityEl->findNextSiblingElement("identity");
            }
          }

          return ret;
        }
void SimpleElementMapSerializer<KeyT>::Serialize(Archive& archive) const
{
    V_Element components;
    components.resize(m_Data->size() * 2);

    {
        DataType::const_iterator itr = m_Data->begin();
        DataType::const_iterator end = m_Data->end();
        for ( int i = 0; itr != end; ++itr )
        {
            if (!itr->second.ReferencesObject())
            {
                continue;
            }

            ElementPtr elem;
            archive.GetCache().Create( Reflect::GetType<KeyT>(), elem );

            Serializer* ser = AssertCast<Serializer>(elem.Ptr());
            ser->ConnectData((void*)&(itr->first));

            components[i++] = ser;
            components[i++] = itr->second;
        }
    }

    archive.Serialize(components);

    {
        V_Element::iterator itr = components.begin();
        V_Element::iterator end = components.end();
        for ( ; itr != end; ++itr )
        {
            Serializer* ser = AssertCast<Serializer>(*itr);
            ser->Disconnect();
            archive.GetCache().Free(ser);
            ++itr;
        }
    }
}
        PeerToFinderPeerLocationFindResultPtr PeerToFinderPeerLocationFindResult::create(ElementPtr root)
        {
          PeerToFinderPeerLocationFindResultPtr ret(new message::PeerToFinderPeerLocationFindResult);

          ret->mID = IMessageHelper::getAttributeID(root);
          ret->mTime = IMessageHelper::getAttributeEpoch(root);

          ElementPtr locs = root->findFirstChildElement("locations");
          if (locs)
          {
            LocationList ll;
            ElementPtr loc = locs->findFirstChildElement("location");
            while (loc)
            {
              Location l = MessageHelper::createLocation(loc->findFirstChildElement("details"));
              l.mID = IMessageHelper::getAttributeID(loc);
              ll.push_back(l);

              loc = loc->getNextSiblingElement();
            }

            if (ll.size() > 0)
              ret->mLocations = ll;
          }

          return ret;
        }
Example #24
0
MultiLineStringLocation PertyWaySplitVisitor::_calcSplitPoint(ConstRelationPtr relation,
                                                              ElementId& wayId) const
{
  const vector<RelationData::Entry>& members = relation->getMembers();
  LOG_VART(members.size());

  //find the way to split on
  boost::uniform_int<> randomWayIndexDistribution(0, members.size() - 1);
  int wayIndex = randomWayIndexDistribution(*_rng);
  wayId = members.at(wayIndex).getElementId();
  LOG_VART(wayIndex);
  LOG_VART(wayId);
  ElementPtr element = _map->getElement(wayId);
  if (element->getElementType() != ElementType::Way)
  {
    throw HootException(
      "PERTY feature splitting for multi-line string relations may only occur on relations which contain only ways.");
  }
  WayPtr way = boost::dynamic_pointer_cast<Way>(element);
  LOG_VART(way->getNodeCount());

  //calculate the split point
  WayLocation wayLocation = _calcSplitPoint(way);
  //return it, if its valid
  if (wayLocation.isValid())
  {
    return
      MultiLineStringLocation(
        _map->shared_from_this(),
        relation,
        wayIndex,
        wayLocation);
  }
  //otherwise, return an empty location
  else
  {
    return MultiLineStringLocation();
  }
}
        //---------------------------------------------------------------------
        LockboxIdentitiesUpdateResultPtr LockboxIdentitiesUpdateResult::create(
                                                                               ElementPtr root,
                                                                               IMessageSourcePtr messageSource
                                                                               )
        {
          LockboxIdentitiesUpdateResultPtr ret(new LockboxIdentitiesUpdateResult);
          IMessageHelper::fill(*ret, root, messageSource);

          ElementPtr identitiesEl = root->findFirstChildElement("identities");
          if (identitiesEl) {
            ElementPtr identityEl = identitiesEl->findFirstChildElement("identity");
            while (identityEl) {
              IdentityInfo info = MessageHelper::createIdentity(identityEl);
              if (info.hasData()) {
                ret->mIdentities.push_back(info);
              }
              identityEl = identityEl->findNextSiblingElement("identity");
            }
          }

          return ret;
        }
        DocumentPtr ProviderAssociateURLGetRequest::encode(message::ProviderAssociateURLGetRequest &msg)
        {
          DocumentPtr ret = IMessageHelper::createDocumentWithRoot(msg);
          ElementPtr root = ret->getFirstChildElement();

          if (msg.hasAttribute(message::ProviderAssociateURLGetRequest::AttributeType_ProviderType)) {
            root->adoptAsLastChild(IMessageHelper::createElementWithText("providerType", provisioning::IAccount::toCodeString(msg.mProviderType)));
          }

          if (msg.hasAttribute(message::ProviderAssociateURLGetRequest::AttributeType_UserID)) {
            root->adoptAsLastChild(IMessageHelper::createElementWithText("userID", msg.mUserID));
          }

          if (msg.hasAttribute(message::ProviderAssociateURLGetRequest::AttributeType_AccessKey)) {
            root->adoptAsLastChild(IMessageHelper::createElementWithText("accessKey", msg.mAccessKey));
          }

          if (msg.hasAttribute(message::ProviderAssociateURLGetRequest::AttributeType_AccessSecret)) {
            root->adoptAsLastChild(IMessageHelper::createElementWithText("accessSecret", msg.mAccessSecret));
          }

          return ret;
        }
        //---------------------------------------------------------------------
        PeerKeepAliveResultPtr PeerKeepAliveResult::create(
                                                           ElementPtr root,
                                                           IMessageSourcePtr messageSource
                                                           )
        {
          PeerKeepAliveResultPtr ret(new PeerKeepAliveResult);

          ret->mID = IMessageHelper::getAttributeID(root);
          ret->mTime = IMessageHelper::getAttributeEpoch(root);

          ret->mExpires = IHelper::stringToTime(IMessageHelper::getElementText(root->findFirstChildElement("expires")));

          return ret;
        }
        DocumentPtr ProviderLoginURLGetRequest::encode(message::ProviderLoginURLGetRequest &msg)
        {
          DocumentPtr ret = IMessageHelper::createDocumentWithRoot(msg);
          ElementPtr root = ret->getFirstChildElement();

          if (msg.hasAttribute(message::ProviderLoginURLGetRequest::AttributeType_ProviderType)) {
            root->adoptAsLastChild(IMessageHelper::createElementWithText("providerType", provisioning::IAccount::toCodeString(msg.mProviderType)));
          }

          if (msg.hasAttribute(message::ProviderLoginURLGetRequest::AttributeType_DeviceUUID)) {
            root->adoptAsLastChild(IMessageHelper::createElementWithText("deviceUUID", msg.mDeviceUUID));
          }

          if (msg.hasAttribute(message::ProviderLoginURLGetRequest::AttributeType_DeviceToken)) {
            root->adoptAsLastChild(IMessageHelper::createElementWithText("deviceToken", msg.mDeviceToken));
          }

          if (msg.hasAttribute(message::ProviderLoginURLGetRequest::AttributeType_AccountSalt)) {
            root->adoptAsLastChild(IMessageHelper::createElementWithText("accountSalt", msg.mAccountSalt));
          }

          return ret;
        }
Example #29
0
	void SyncTestbed::CompareElementRecurs(const ElementPtr& element1, const ElementPtr& element2) const
	{
		Assert::AreEqual(element1->GetName()->GetString(), element2->GetName()->GetString());
		Assert::IsTrue(element1->GetGUID() == element2->GetGUID());
		Assert::IsTrue(element1->GetElementType() == element2->GetElementType());
		Assert::IsTrue(element1->GetXValue() == element2->GetXValue());

		if (element1->GetElementType() == ElementType::ObjectType)
		{
			ObjectElementPtr objElement1 = ObjectElement::Cast(element1);
			Assert::IsNotNull(objElement1.get());
			ObjectElementPtr objElement2 = ObjectElement::Cast(element2);
			Assert::IsNotNull(objElement2.get());

			Assert::AreEqual(objElement1->GetElementCount(), objElement2->GetElementCount());

			for (int32 i = 0; i < objElement1->GetElementCount(); ++i)
			{
				ElementPtr childElement1 = objElement1->GetElementAt(i);

				ElementPtr childElement2 = objElement2->GetElement(childElement1->GetName());
				Assert::IsNotNull(childElement2.get());

				CompareElementRecurs(childElement1, childElement2);
			}
		}
		else if (IsFrom<ArrayElement>(element1))
		{
			ArrayElement* arrayElement1 = reflection_cast<ArrayElement>(element1);
			Assert::IsNotNull(arrayElement1);

			ArrayElement* arrayElement2 = reflection_cast<ArrayElement>(element2);
			Assert::IsNotNull(arrayElement2);

			Assert::AreEqual(arrayElement1->GetCount(), arrayElement2->GetCount());

			for (int32 i = 0; i < arrayElement1->GetCount(); ++i)
			{
				Assert::IsTrue(arrayElement1->GetXValue(i) == arrayElement2->GetXValue(i));
			}
		}
	}
Example #30
0
map< int, vector<DofInfo> > constructGlobalDofToLocalDofInfoMap(MeshPtr mesh)
{
  // go through the mesh as a whole, and collect info for each dof
  map< int, vector<DofInfo> > infoMap;
  DofInfo info;
  set<GlobalIndexType> activeCellIDs = mesh->getActiveCellIDsGlobal();
  for (set<GlobalIndexType>::iterator cellIt = activeCellIDs.begin(); cellIt != activeCellIDs.end(); cellIt++)
  {
    GlobalIndexType cellID = *cellIt;
    info.cellID = cellID;
    ElementPtr element = mesh->getElement(cellID);
    DofOrderingPtr trialOrder = element->elementType()->trialOrderPtr;
    set<int> trialIDs = trialOrder->getVarIDs();
    info.totalDofs = trialOrder->totalDofs();
    for (set<int>::iterator trialIt=trialIDs.begin(); trialIt != trialIDs.end(); trialIt++)
    {
      info.trialID = *trialIt;
      const vector<int>* sidesForVar = &trialOrder->getSidesForVarID(info.trialID);
      for (vector<int>::const_iterator sideIt = sidesForVar->begin(); sideIt != sidesForVar->end(); sideIt++)
      {
        int sideIndex = *sideIt;
        info.sideIndex = sideIndex;
        info.basisCardinality = trialOrder->getBasisCardinality(info.trialID, info.sideIndex);
        for (int basisOrdinal=0; basisOrdinal < info.basisCardinality; basisOrdinal++)
        {
          info.basisOrdinal = basisOrdinal;
          info.localDofIndex = trialOrder->getDofIndex(info.trialID, info.basisOrdinal, info.sideIndex);
          pair<int, int> localDofIndexKey = make_pair(info.cellID, info.localDofIndex);
          int globalDofIndex = mesh->getLocalToGlobalMap().find(localDofIndexKey)->second;
//          cout << "(" << info.cellID << "," << info.localDofIndex << ") --> " << globalDofIndex << endl;
          infoMap[globalDofIndex].push_back(info);
        }
      }
    }
  }
  return infoMap;
}