Пример #1
0
    void State_t::LoadFromXmlNode(CTextNode& node, Agent* pAgent)
    {
        if (pAgent)
        {
            CSerializationID  membersId("members");
            ISerializableNode* membersNode = node.findChild(membersId);
            pAgent->Load(membersNode);
        }

        this->m_vars.Load(&node);
        CSerializationID  btNodeId("BehaviorTree");
        ISerializableNode* btNode = node.findChild(btNodeId);

        if (btNode)
        {
            CSerializationID  sourceId("source");
            behaviac::string btName;

            if (btNode->getAttr(sourceId, btName))
            {
                BEHAVIAC_DELETE this->m_bt;
                this->m_bt = Workspace::GetInstance()->CreateBehaviorTreeTask(btName.c_str());
            }

            CSerializationID  nodeId("node");
            ISerializableNode* n = btNode->findChild(nodeId);
            BEHAVIAC_ASSERT(n);

            this->m_bt->Load(n);
        }
    }
Пример #2
0
    N2npNodeId LocalRelay::attachNode(LocalNode *node)
    {
        std::string nodeName;

        // Make this thread-safe
        this->nodesMutex.lock();
        try {
            // Compute a new Unique ID
            std::ostringstream nodeNameStream;
            nodeNameStream << (++this->lastNodeId);
            nodeName = nodeNameStream.str();
        } catch (Exception e) {
            this->nodesMutex.unlock();
            throw e;
        }
        this->nodesMutex.unlock();

        N2npNodeId nodeId(nodeName.c_str(), this->addr);

        // This may not happen, as this is an auto-increment index
        EPYX_ASSERT(this->nodes.count(nodeName) == 0);

        this->nodesMutex.lock();
        this->nodes.insert(make_pair(nodeName, node));
        this->nodesMutex.unlock();

        return nodeId;
    }
    NodeInfoSPtr FailoverManagerStoreTest::CreateNodeInfo(int64 low)
    {
        NodeId nodeId(LargeInteger(0, low));
        NodeInstance nodeInstance(nodeId, 0);
        Common::FabricVersionInstance versionInstance;
        std::wstring defaultNodeUpgradeDomainId;
        std::vector<Common::Uri> defaultNodeFaultDomainIds;
        std::map<std::wstring, std::wstring> defaultNodeProperties;
        std::map<std::wstring, uint> defaultCapacityRatios;
        std::map<std::wstring, uint> defaultCapacities;
        std::wstring defaultNodeName;
        std::wstring defaultNodeType;
        std::wstring defaultIpAddressOrFQDN;
        ULONG defaultClientConnectionPort = 0;

        NodeDescription nodeDescription(
            versionInstance,
            defaultNodeUpgradeDomainId,
            defaultNodeFaultDomainIds,
            defaultNodeProperties,
            defaultCapacityRatios,
            defaultCapacities,
            defaultNodeName,
            defaultNodeType,
            defaultIpAddressOrFQDN,
            defaultClientConnectionPort);

        return make_shared<NodeInfo>(nodeInstance, move(nodeDescription), true);
    }
Пример #4
0
bool ViewCollection::unBindShader(GLuint shaderId)
{
	bool result= false;
	if (m_ShadedPointerViewInstanceHash.contains(shaderId))
	{
		// Find node which use the shader
		std::vector<unsigned int> nodeId(m_ShaderGroup.keys(shaderId));

		// Move these node in the standard hash and remove them from shader group
		PointerViewInstanceHash* pShaderNodeHash= m_ShadedPointerViewInstanceHash.take(shaderId);
		for (int i= 0; i < nodeId.size(); ++i)
		{
			const unsigned int id= nodeId[i];
			ViewInstance* pInstance= pShaderNodeHash->value(id);

			if (!pInstance->isSelected())
			{
				m_MainInstances.insert(id, pInstance);
			}
			else
			{
				m_SelectedInstances.insert(id, pInstance);
			}
			m_ShaderGroup.remove(id);
		}
		pShaderNodeHash->clear();
		delete pShaderNodeHash;
		result= true;
	}
	Q_ASSERT(!m_ShadedPointerViewInstanceHash.contains(shaderId));
	return result;
}
Пример #5
0
FlowPart* FlowPart::outputPart(const QString& internalNodeId) {
	Node *node = m_pFlowCodeDocument->nodeWithID(nodeId(internalNodeId));

	FPNode *fpnode = dynamic_cast<FPNode*>(node);
	// FIXME dynamic_cast used to replace fpnode::type() call

	if (!fpnode || (dynamic_cast<InputFlowNode*>(fpnode) != 0))
		// if ( !fpnode || fpnode->type() == Node::fp_in )
		return 0l;

	return fpnode->outputFlowPart();
}
Пример #6
0
//--------------------------------------------------------------------------//
// LCOV_EXCL_START :dpm
void CRUTask::DumpGraphNode(CDSString &to)
{
    char fromChr[10];
    sprintf(fromChr,"%d",GetId());
    CDSString nodeId(fromChr);

    to += "\t\t" + nodeId;
    to += " [style=filled,";
    to += "label= \"" + nodeId + "." + GetTaskName() + "\"";
    to += ",color=";
    switch (GetType())
    {
    case REFRESH:
    {
        to += "red";
        break;
    }
    case TABLE_SYNC:
    {
        to += "lightgrey";
        break;
    }
    case DUP_ELIM:
    {
        to += "violet";
        break;
    }
    case LOG_CLEANUP:
    {
        to += "yellowgreen";
        break;
    }
    case RC_RELEASE:
    {
        to += "pink";
        break;
    }
    case EMP_CHECK:
    {
        to += "gold";
        break;
    }
    case LOCK_EQUIV_SET:
    {
        to += "yellow";
        break;
    }
    default:
        RUASSERT(FALSE);
    }
    to += "];\n";
}
Пример #7
0
std::string Environment::nodeId() {
    NodeId id;
    nodeId(id);
    char result[18];
    std::sprintf(result, "%02x:%02x:%02x:%02x:%02x:%02x",
            id[0],
            id[1],
            id[2],
            id[3],
            id[4],
            id[5]);
    return std::string(result);
}
Пример #8
0
    void SingeChildTask::save(ISerializableNode* node) const
    {
        super::save(node);

        if (this->m_status != BT_INVALID)
        {
            if (this->m_root)
            {
                CSerializationID  nodeId("root");
                ISerializableNode* chidlNode = node->newChild(nodeId);
                this->m_root->save(chidlNode);
            }
        }
    }
Пример #9
0
LODNodeSample deserializeDataSample( const ::zeq::Event& event )
{
    LODNodeSample sample;
    sample.first = event.getType();

    auto data = GetLODNode( event.getData( ));
    sample.second = livre::LODNode(
        NodeId( data->nodeId( )),
        _deserializeVector3< int32_t >( data->blockSize( )),
        Boxf( _deserializeVector3< float >( data->worldBoxMin( )),
              _deserializeVector3< float >( data->worldBoxMax( ))));

    return sample;
}
Пример #10
0
    void BehaviorTreeTask::Save(ISerializableNode* node) const
    {
        CSerializationID  btId("BehaviorTree");
        ISerializableNode* btNodeRoot = node->newChild(btId);

        BEHAVIAC_ASSERT(BehaviorTree::DynamicCast(this->GetNode()));
        BehaviorTree* bt = (BehaviorTree*)this->GetNode();

        CSerializationID  sourceId("source");
        btNodeRoot->setAttr(sourceId, bt->GetName());

        CSerializationID  nodeId("node");
        ISerializableNode* btNode = btNodeRoot->newChild(nodeId);

        this->save(btNode);
    }
Пример #11
0
const QString
SipInfo::toJson() const
{
    // build variant map
    QVariantMap m;
    m["visible"] = isVisible();
    if ( isVisible() )
    {
        m["ip"] = host();
        m["port"] = port();
        m["key"] = key();
        m["uniqname"] = nodeId();
    }

    // serialize
    QJson::Serializer serializer;
    QByteArray ba = serializer.serialize( m );

    return QString::fromLatin1( ba );
}
Пример #12
0
    void CompositeTask::save(ISerializableNode* node) const
    {
        super::save(node);

        if (this->m_status != BT_INVALID)
        {
            CSerializationID attrId("activeChildIndex");
            node->setAttr(attrId, this->m_activeChildIndex);

            BehaviorTasks_t::size_type count = this->m_children.size();

            for (BehaviorTasks_t::size_type i = 0; i < count; ++i)
            {
                BehaviorTask* childTask = this->m_children[i];

                CSerializationID  nodeId("node");
                ISerializableNode* chidlNode = node->newChild(nodeId);
                childTask->save(chidlNode);
            }
        }
    }
void NodeGraphNodeConnector::visit( he::io::StructuredVisitor* const visitor )
{
    if (m_Type == eNodeGraphNodeConnectorType_Input)
    {
        if (visitor->enterNode(m_Id))
        {
            if (visitor->isReading())
                disconnectAll();
            visitor->visitCustomList<NodeGraphNodeConnector*>(he::HEFS::strConnections, m_Connections, 
            [this](he::io::StructuredVisitor* visitor, size_t /*index*/, NodeGraphNodeConnector*& val)
            {
                he::Guid nodeId(val->m_Parent->getParent()->getGuid());
                if (visitor->visit(HSFS::strNodeID, nodeId))
                {
                    he::FixedString connectionId(val->getId());
                    if (visitor->visit(HSFS::strConnectionID, connectionId))
                    {
                        if (visitor->isReading())
                        {
                            NodeGraphNode* node(m_Parent->getParent()->getParent()->getNode(nodeId));
                            if (node)
                            {
                                node->getAttachments().forEach([this, &connectionId](NodeGraphNodeAttachment* att)
                                {
                                    NodeGraphNodeConnector* connector(att->getNodeConnector());
                                    if (connector && connector->getId() == connectionId)
                                    {
                                        connector->connect(this);
                                    }
                                });
                            }
                        }
                    }
                }
            });
            visitor->exitNode(m_Id);
        }
    }
}
Пример #14
0
void
ChromiumCDMProxy::Init(PromiseId aPromiseId,
                       const nsAString& aOrigin,
                       const nsAString& aTopLevelOrigin,
                       const nsAString& aGMPName)
{
  MOZ_ASSERT(NS_IsMainThread());
  NS_ENSURE_TRUE_VOID(!mKeys.IsNull());

  EME_LOG(
    "ChromiumCDMProxy::Init (pid=%u, origin=%s, topLevelOrigin=%s, gmp=%s)",
    aPromiseId,
    NS_ConvertUTF16toUTF8(aOrigin).get(),
    NS_ConvertUTF16toUTF8(aTopLevelOrigin).get(),
    NS_ConvertUTF16toUTF8(aGMPName).get());

  if (!mGMPThread) {
    RejectPromise(
      aPromiseId,
      NS_ERROR_DOM_INVALID_STATE_ERR,
      NS_LITERAL_CSTRING("Couldn't get GMP thread ChromiumCDMProxy::Init"));
    return;
  }

  if (aGMPName.IsEmpty()) {
    RejectPromise(aPromiseId,
                  NS_ERROR_DOM_INVALID_STATE_ERR,
                  nsPrintfCString("Unknown GMP for keysystem '%s'",
                                  NS_ConvertUTF16toUTF8(mKeySystem).get()));
    return;
  }

  gmp::NodeId nodeId(aOrigin, aTopLevelOrigin, aGMPName);
  RefPtr<AbstractThread> thread = mGMPThread;
  RefPtr<GMPCrashHelper> helper(mCrashHelper);
  RefPtr<ChromiumCDMProxy> self(this);
  nsCString keySystem = NS_ConvertUTF16toUTF8(mKeySystem);
  RefPtr<Runnable> task(NS_NewRunnableFunction(
    [self, nodeId, helper, aPromiseId, thread, keySystem]() -> void {
      MOZ_ASSERT(self->IsOnOwnerThread());

      RefPtr<gmp::GeckoMediaPluginService> service =
        gmp::GeckoMediaPluginService::GetGeckoMediaPluginService();
      if (!service) {
        self->RejectPromise(
          aPromiseId,
          NS_ERROR_DOM_INVALID_STATE_ERR,
          NS_LITERAL_CSTRING(
            "Couldn't get GeckoMediaPluginService in ChromiumCDMProxy::Init"));
        return;
      }
      RefPtr<gmp::GetCDMParentPromise> promise =
        service->GetCDM(nodeId, { keySystem }, helper);
      promise->Then(
        thread,
        __func__,
        [self, aPromiseId](RefPtr<gmp::ChromiumCDMParent> cdm) {
          if (!cdm->Init(self,
                         self->mDistinctiveIdentifierRequired,
                         self->mPersistentStateRequired)) {
            self->RejectPromise(aPromiseId,
                                NS_ERROR_FAILURE,
                                NS_LITERAL_CSTRING("GetCDM failed."));
            return;
          }
          {
            MutexAutoLock lock(self->mCDMMutex);
            self->mCDM = cdm;
          }
          self->OnCDMCreated(aPromiseId);
        },
        [self, aPromiseId](nsresult rv) {
          self->RejectPromise(
            aPromiseId, NS_ERROR_FAILURE, NS_LITERAL_CSTRING("GetCDM failed."));
        });
    }));

  mGMPThread->Dispatch(task.forget());
}
Пример #15
0
Node *CNItem::childNode( const QString &childId )
{
	return p_icnDocument->nodeWithID( nodeId(childId) );
}
Пример #16
0
NodeId RfidReaderMacData::getSenderId() const
{
	NodeId nodeId(m_senderId, m_senderIdBytes);
	return nodeId;
}
Пример #17
0
NodeId RfidReaderMacData::getReceiverId() const
{
	NodeId nodeId(m_receiverId, m_receiverIdBytes);
	return nodeId;
}
Пример #18
0
/*
 *      Places traces in a particular linear order
 *      to maximize sequential transition.
 *      A good way to achieve this is to construct a
 *      higher level graph, using traces as nodes.
 *      An arc is added between traces whose head
 *      and tail are connected by a transition.
 */
static void
PlaceTraces (FGraph graph)
{
  FGraph new_graph;
  Node node, current;
  Node node_order[MAX_GRAPH_SIZE];
  int i, size;
#ifndef SECOND_LEVEL_SELECT
  int min_trace_id, max_trace_id;
#endif
  if (graph->nodes == 0)
    return;
#ifdef SECOND_LEVEL_SELECT
  new_graph = NewGraph ();      /* create a high level graph */
  for (node = graph->nodes; node != 0; node = nextNode (node))
    {
      int trace_id;
      Node temp;
      trace_id = nodeType (node);
      temp = FindNode (new_graph, trace_id);
      if (temp == 0)
        {
          temp = NewNode ();
          nodeId (temp) = trace_id;
          AddNode (new_graph, temp);
        }
      if (node == graph->root)
        new_graph->root = temp;
    }
  for (node = graph->nodes; node != 0; node = nextNode (node))
    {
      Arc arc;
      if (!(nodeStatus (node) & TRACE_TAIL))
        continue;
      /*
       *      Find transitions to the head of other traces.
       *      Inner loop back-edge is not considered.
       */
      for (arc = destinationArcs (node); arc != 0; arc = nextArc (arc))
        {
          Node dest;
          dest = destinationNode (arc);
          if ((nodeType (dest) != nodeType (node)) &&
              (nodeStatus (dest) & TRACE_HEAD))
            {
              /*
               *      Add a link (trace[node]->trace[dest])
               */
              int src_trace_id, dest_trace_id;
              Node src_node, dest_node;
              Arc ar;
              src_trace_id = nodeType (node);
              dest_trace_id = nodeType (dest);
              src_node = FindNode (new_graph, src_trace_id);
              dest_node = FindNode (new_graph, dest_trace_id);
              ConnectNodes (src_node, dest_node, 0);
              ar = FindSrcArc (src_node, dest_node, 0);
              arcWeight (ar) = arcWeight (arc);
              ar = FindDestArc (src_node, dest_node, 0);
              arcWeight (ar) = arcWeight (arc);
            }
        }
    }
  /*
   *  Simply assign the node weights to max(connecting arc)
   */
  for (node = new_graph->nodes; node != 0; node = nextNode (node))
    {
      Arc arc;
      double max = 1.0;
      for (arc = sourceArcs (node); arc != 0; arc = nextArc (arc))
        if (arcWeight (arc) > max)
          max = arcWeight (arc);
      for (arc = destinationArcs (node); arc != 0; arc = nextArc (arc))
        if (arcWeight (arc) > max)
          max = arcWeight (arc);
      nodeWeight (node) = max;
    }
  /*
   *  Apply SelectTraces() on the new graph.
   *  Use SELECT_BY_ARC_WEIGHT
   */
  best_successor_of = best_successor_2;
  best_predecessor_of = best_predecessor_2;
  SelectTraces (new_graph);
  /*
   *  Determine the best sequential order of the traces.
   *  Essentially, we have the original problem again.
   *  However, after the second level trace selection,
   *  we expect most of the sequential transitions are
   *  captured. A naive heuristic is sufficient here.
   *  The sequential order must start with the ENTRY trace.
   */
#ifdef DEBUG_TRACE1
  printf ("... second level graph = \n");
  WriteGraph ("stdout", new_graph);
#endif
  /*
   *  Clear the valid bit of all nodes.
   */
  for (node = new_graph->nodes; node != 0; node = nextNode (node))
    {
      nodeStatus (node) &= ~VISITED;
    }
  /*
   *  Start from the root node.
   */
  size = 0;
  current = new_graph->root;
  while (current != 0)
    {
      Node ptr;
      Arc ar;
      int trace_id;
      if (nodeStatus (current) & VISITED)
        Punt ("PlaceTraces: reached a VISITed node");
      nodeStatus (current) |= VISITED;
      trace_id = nodeId (current);
      /*
       *      Layout the trace.
       */
      for (ptr = graph->nodes; ptr != 0; ptr = nextNode (ptr))
        {
          if ((nodeType (ptr) == trace_id) && (nodeStatus (ptr) & TRACE_HEAD))
            break;              /* find the starting node of the trace */
        }
      if (ptr == 0)
        Punt ("PlaceTraces: internal error (1)");
      while (ptr != 0)
        {
          Arc next;
          node_order[size++] = ptr;
          /*
           *  Follow the in-trace transition.
           */
          if (nodeStatus (ptr) & TRACE_TAIL)
            break;              /* reached the end of trace */
          for (next = destinationArcs (ptr); next != 0; next = nextArc (next))
            {
              if (arcType (next) == nodeType (ptr))
                break;          /* find a in-trace transition */
            }
          if (next == 0)
            break;
          ptr = destinationNode (next);
        }
      /*
       *      Select the next trace to be visited next.
       *      Follow an in-trace transition (of the higher level
       *      graph) if possible. 
       */
      for (ar = destinationArcs (current); ar != 0; ar = nextArc (ar))
        {
          if (arcType (ar) == nodeType (current))
            break;              /* find an in-trace transition */
        }
      if (ar != 0)
        {                       /* transition is still in-trace */
          current = destinationNode (ar);
        }
      else
        {                       /* must find another trace */
          /*
           *  Find the most important trace left.
           */
          Node nn, best;
          best = 0;
          for (nn = new_graph->nodes; nn != 0; nn = nextNode (nn))
            {
              if (nodeStatus (nn) & VISITED)
                continue;       /* skip over VISITED nodes */
              if (!(nodeStatus (nn) & TRACE_HEAD))
                continue;       /* skip over non-trace headers */
              if (best == 0)
                {
                  best = nn;
                }
              else
                {
                  if (nodeWeight (nn) > nodeWeight (best))
                    best = nn;
                }
            }
          current = best;       /* go out of trace if best=0 */
        }
    }
  /*
   *  Make sure that all traces have been layout.
   */
  for (node = new_graph->nodes; node != 0; node = nextNode (node))
    {
      if (!(nodeStatus (node) & VISITED))
        {
          Punt ("PlaceTraces: missing some traces");
        }
    }
  /*
   *  No longer need the higher level graph.
   */
  FreeGraph (&new_graph);       /* destroy the high level graph */
#else
  min_trace_id = 0x1FFFFFFF;
  max_trace_id = -0x1FFFFFFF;
  for (node = graph->nodes; node != 0; node = nextNode (node))
    {
      int trace_id;
      trace_id = nodeType (node);
      if (trace_id > max_trace_id)
        max_trace_id = trace_id;
      if (trace_id < min_trace_id)
        min_trace_id = trace_id;
    }
  for (node = graph->nodes; node != 0; node = nextNode (node))
    {
      nodeStatus (node) &= ~VISITED;
    }
  size = 0;
  for (i = min_trace_id; i <= max_trace_id; i++)
    {
      Node ptr;
      /*
       * 1. find the trace header.
       */
      for (ptr = graph->nodes; ptr != 0; ptr = nextNode (ptr))
        {
          if ((nodeType (ptr) == i) & ((nodeStatus (ptr) & TRACE_HEAD) != 0))
            break;
        }
      if (ptr == 0)
        continue;
      while (ptr != 0)
        {
          Arc next;
          if (nodeStatus (ptr) & VISITED)
            Punt ("PlaceTraces: visited a node twice");
          nodeStatus (ptr) |= VISITED;
          node_order[size++] = ptr;
          if (nodeStatus (ptr) & TRACE_TAIL)
            break;
          for (next = destinationArcs (ptr); next != 0; next = nextArc (next))
            {
              if (arcType (next) == nodeType (ptr))
                break;
            }
          if (next == 0)
            break;
          ptr = destinationNode (next);
        }
    }
  /*
   *  Make sure that all traces have been layout.
   */
  for (node = graph->nodes; node != 0; node = nextNode (node))
    {
      if (!(nodeStatus (node) & VISITED))
        {
          fprintf (stderr, "min trace id = %d\n", min_trace_id);
          fprintf (stderr, "max trace id = %d\n", max_trace_id);
          fprintf (stderr, "size = %d\n", size);
          WriteGraph ("stderr", graph);
          Punt ("PlaceTraces: missing some traces");
        }
    }
#endif
  /*
   *  Rearrange the order of nodes, according to the
   *  node_order[] order.
   */
  node_order[size] = 0;
  for (i = 0; i < size; i++)
    {
      nextNode (node_order[i]) = node_order[i + 1];
    }
  graph->nodes = node_order[0];
}