Ejemplo n.º 1
0
ErrorCode PlatformSessionImpl::onLaunchDebugServer(Session &session,
                                                   std::string const &host,
                                                   uint16_t &port,
                                                   ProcessId &pid) {
  ProcessSpawner ps;
  StringCollection args;

  ps.setExecutable(Platform::GetSelfExecutablePath());
  args.push_back("slave");
  if (GetLogLevel() == kLogLevelDebug) {
    args.push_back("--debug");
  } else if (GetLogLevel() == kLogLevelPacket) {
    args.push_back("--debug-remote");
  }
  ps.setArguments(args);
  ps.redirectInputToNull();
  ps.redirectOutputToBuffer();

  ErrorCode error;
  error = ps.run();
  if (error != kSuccess)
    return error;
  error = ps.wait();
  if (error != kSuccess)
    return error;

  if (ps.exitStatus() != 0)
    return kErrorInvalidArgument;

  std::istringstream ss;
  ss.str(ps.output());
  ss >> port >> pid;

  return kSuccess;
}
Ejemplo n.º 2
0
void OGDFGemFrick::beforeCall() {
  ogdf::GEMLayout *gem = static_cast<ogdf::GEMLayout*>(ogdfLayoutAlgo);

  if (dataSet != NULL) {
    int ival = 0;
    double dval = 0;
    StringCollection sc;

    if (dataSet->get("number of rounds", ival)) {
      gem->numberOfRounds(ival);
    }

    if (dataSet->get("minimal temperature", dval)) {
      gem->minimalTemperature(dval);
    }

    if (dataSet->get("initial temperature", dval)) {
      gem->initialTemperature(dval);
    }

    if (dataSet->get("gravitational constant", dval)) {
      gem->gravitationalConstant(dval);
    }

    if (dataSet->get("desired length", dval)) {
      gem->desiredLength(dval);
    }

    if (dataSet->get("maximal disturbance", dval)) {
      gem->maximalDisturbance(dval);
    }

    if (dataSet->get("rotation angle", dval)) {
      gem->rotationAngle(dval);
    }

    if (dataSet->get("oscillation angle", dval)) {
      gem->oscillationAngle(dval);
    }

    if (dataSet->get("rotation sensitivity", dval)) {
      gem->rotationSensitivity(dval);
    }

    if (dataSet->get("oscillation sensitivity", dval)) {
      gem->oscillationSensitivity(dval);
    }

    if (dataSet->get(ELT_ATTRACTIONFORMULA, sc)) {
      gem->attractionFormula(sc.getCurrent() + 1);
    }

    if (dataSet->get("minDistCC", dval))
      gem->minDistCC(dval);

    if (dataSet->get("pageRatio", dval))
      gem->pageRatio(dval);

  }
}
Ejemplo n.º 3
0
Archivo: ProcFS.cpp Proyecto: cosql/ds2
bool ProcFS::GetProcessArguments(pid_t pid, StringCollection &args) {
  FILE *fp = ProcFS::OpenFILE(pid, "cmdline");
  if (fp == nullptr)
    return false;

  args.clear();

  std::string arg;
  for (;;) {
    char buf[1024], *end, *bp;
    size_t nread = fread(buf, 1, sizeof(buf), fp);
    if (nread == 0) {
      if (!arg.empty()) {
        args.push_back(arg);
      }
      break;
    }

    bp = buf, end = buf + nread;
    while (bp < end) {
      while (*bp != '\0') {
        arg += *bp++;
      }
      bp++;
      args.push_back(arg);
      arg.clear();
    }
  }

  std::fclose(fp);
  return true;
}
  void beforeCall() {
    ogdf::PlanarizationGridLayout *pgl = static_cast<ogdf::PlanarizationGridLayout*>(ogdfLayoutAlgo);

    if (dataSet != NULL) {
      double dval = 0;
      StringCollection sc;

      if (dataSet->get("page ratio", dval))
        pgl->pageRatio(dval);

      if (dataSet->get(ELT_PLANARSUBGRAPH, sc)) {
        if (sc.getCurrent() == ELT_FASTPLANAR) {
          pgl->setSubgraph(new ogdf::FastPlanarSubgraph());
        }
        else {
          pgl->setSubgraph(new ogdf::MaximalPlanarSubgraphSimple());
        }
      }

      if (dataSet->get(ELT_EDGEINSERTION, sc)) {
        if (sc.getCurrent() == ELT_FIXEDEMBEDDING) {
          pgl->setInserter(new ogdf::FixedEmbeddingInserter());
        }
        else {
          pgl->setInserter(new ogdf::VariableEmbeddingInserter);
        }
      }
    }
  }
Ejemplo n.º 5
0
    GameAsset* Script::Create(StreamReader& reader, GameAsset* /*existingInstance*/)
    {
        const int length = reader.ReadInt();

        Buffer buffer;
        buffer.resize(length);

        reader.Read(&buffer[0], length);
        const int numberOfFunctions = reader.ReadInt();
        FunctionTable functionTable;
        functionTable.resize(numberOfFunctions);
        for (int i = 0; i < numberOfFunctions; i++)
        {
            Function& item = functionTable[i];
            item.Name = reader.ReadString();
            item.Position = reader.ReadInt();
            item.ArgumentStackSize = reader.ReadInt();
            item.ReturnTypes.resize(reader.ReadInt());
            for (std::vector<AnyType>::size_type i = 0; i < item.ReturnTypes.size(); i++)
                item.ReturnTypes[i] = static_cast<AnyType>(reader.ReadInt());
            item.ParameterTypes.resize(reader.ReadInt());
            for (std::vector<AnyType>::size_type i = 0; i < item.ParameterTypes.size(); i++)
                item.ParameterTypes[i] = static_cast<AnyType>(reader.ReadInt());
        }

        const int numberOfStrings = reader.ReadInt();
        StringCollection stringTable;
        stringTable.reserve(numberOfStrings);
        for (int i = 0; i < numberOfStrings; i++)
            stringTable.push_back(reader.ReadString());

        return new Script(buffer, functionTable, stringTable, MoveTag());
    }
Ejemplo n.º 6
0
void IXMLHandler::impl::startElement(const XMLCh * const uri, const XMLCh * const localname, const XMLCh* const qname, const xerces::Attributes &attrs)
{
    HandlerBase::startElement(uri, localname, qname, attrs);

    StringCollection<String> attributes;
    XMLSize_t count = attrs.getLength();
    for(XMLSize_t i = 0; i < count; i++)
    {
        attributes.set(attrs.getLocalName(i), attrs.getValue(i));
    }

    m_handler->onStartElement(localname, attributes);
}
Ejemplo n.º 7
0
void TestDirectory::TestGetFilesWithMask()
{
	typedef std::vector<std::tstring> StringCollection;
	StringCollection fileNames = Workshare::System::IO::Directory::GetFiles(TEST_FOLDER + _T("\\TestGetFiles"), _T("*.doc"));
	assertEquals(2, (long)fileNames.size());

	// make all fileNames lowercase, so we can find them.
	std::for_each(fileNames.begin(), fileNames.end(), MakeFileNameLowerCase);

	StringCollection::iterator fileName = std::find(fileNames.begin(), fileNames.end(), tolower(TEST_FOLDER + _T("\\testgetfiles\\filea.doc")));
	assertMessage(fileName != fileNames.end(), _T("Expected to find [") + TEST_FOLDER + _T("\\testgetfiles\\filea.doc] in the returned list"));

	fileName = std::find(fileNames.begin(), fileNames.end(), tolower(TEST_FOLDER + _T("\\testgetfiles\\fileb.doc")));
	assertMessage(fileName != fileNames.end(), _T("Expected to find [") + TEST_FOLDER + _T("\\testgetfiles\\fileb.doc] in the returned list"));
}
bool TestMultiPackageHostContext::FromClientId(std::wstring const& clientId, TestMultiPackageHostContext & testMultiPackageHostContext)
{
    StringCollection collection;
    StringUtility::Split<wstring>(clientId, collection, TestMultiPackageHostContext::ParamDelimiter);
    if(collection.size() == 2)
    {
        Federation::NodeId nodeId;
        TestSession::FailTestIfNot(Federation::NodeId::TryParse(collection[0], nodeId), "Could not parse NodeId: {0}", clientId);
        testMultiPackageHostContext = TestMultiPackageHostContext(nodeId.ToString(), collection[1]);
        return true;
    }
    else
    {
        return false;
    }
}
Ejemplo n.º 9
0
vector<ServiceMetric> PlacementAndLoadBalancingUnitTest::CreateMetrics(wstring metrics)
{
    StringCollection metricCollection;
    StringUtility::Split<wstring>(metrics, metricCollection, ItemDelimiter);

    vector<ServiceMetric> metricList;
    for (wstring const& metricStr : metricCollection)
    {
        StringCollection metricProperties;
        StringUtility::Split<wstring>(metricStr, metricProperties, PairDelimiter);

        ASSERT_IFNOT(metricProperties.size() == 4, "Metric error");

        metricList.push_back(ServiceMetric(move(metricProperties[0]), Common::Double_Parse(metricProperties[1]), _wtoi(metricProperties[2].c_str()), _wtoi(metricProperties[3].c_str())));
    }

    return metricList;
}
Ejemplo n.º 10
0
vector<ReplicaDescription> PlacementAndLoadBalancingUnitTest::CreateReplicas(wstring replicas, std::vector<bool>& isReplicaUp)
{
    StringCollection replicaSet;
    vector<ReplicaDescription> replicaDescription;
    StringUtility::Split<wstring>(replicas, replicaSet, ItemDelimiter);

    if (replicaSet.size() != isReplicaUp.size())
    {
        return replicaDescription;
    }

    for (int i = 0; i < replicaSet.size(); i++)
    {
        replicaDescription.push_back(CreateReplicas(replicaSet[i], isReplicaUp[i])[0]);
    }

    return replicaDescription;
}
Ejemplo n.º 11
0
map<wstring, uint> PlacementAndLoadBalancingUnitTest::CreateCapacities(std::wstring capacityStr)
{
    map<wstring, uint> capacities;
    if (!capacityStr.empty())
    {
        StringCollection capacityCollection;
        StringUtility::Split<wstring>(capacityStr, capacityCollection, ItemDelimiter);
        for (int i = 0; i < capacityCollection.size(); ++i)
        {
            StringCollection capacityPair;
            StringUtility::Split<wstring>(capacityCollection[i], capacityPair, PairDelimiter);

            ASSERT_IFNOT(capacityPair.size() == 2, "Capacity error");
            capacities.insert(make_pair(capacityPair[0], _wtoi(capacityPair[1].c_str())));
        }
    }

    return capacities;
}
bool UnreliableTransportConfiguration::AddSpecification(std::wstring const & name, std::wstring const & data)
{
    StringCollection params;
    StringUtility::Split<wstring>(data, params, L" ");

    wstring source = (params.size() > 0 ? params[0] : wstring());
    wstring destination = (params.size() > 1 ? params[1] : wstring());
    wstring action = (params.size() > 2 ? params[2] : wstring());
    double probability = (params.size() > 3 ? Common::Double_Parse(params[3]) : 1.0);
    TimeSpan delay = (params.size() > 4 ? ParseTimeSpan(params[4]) : TimeSpan::MaxValue);
    TimeSpan delaySpan = (params.size() > 5 ? ParseTimeSpan(params[5]) : TimeSpan::Zero);
    int priority = (params.size() > 6 ? Common::Int32_Parse(params[6]) : 0);
    int applyCount = (params.size() > 7 ? Common::Int32_Parse(params[7]) : -1);

    return AddSpecification(make_unique<UnreliableTransportSpecification>(name, source, destination, action, probability, delay, delaySpan, priority, applyCount));
}
Ejemplo n.º 13
0
map<wstring, ApplicationCapacitiesDescription> PlacementAndLoadBalancingUnitTest::CreateApplicationCapacities(wstring appCapacities)
{
    map<std::wstring, ApplicationCapacitiesDescription> capacityDesc;

    StringCollection capacityCollection;
    StringUtility::Split<wstring>(appCapacities, capacityCollection, ItemDelimiter);
    for (wstring const& metricStr : capacityCollection)
    {
        StringCollection metricProperties;
        StringUtility::Split<wstring>(metricStr, metricProperties, PairDelimiter);

        ASSERT_IFNOT(metricProperties.size() == 4, "CreateApplicationCapacities metric error");

        wstring metricName = metricProperties[0];
        capacityDesc.insert(make_pair(metricName,
            ApplicationCapacitiesDescription(move(metricProperties[0]), _wtoi(metricProperties[1].c_str()), _wtoi(metricProperties[2].c_str()), _wtoi(metricProperties[3].c_str()))));
    }

    return capacityDesc;
}
Ejemplo n.º 14
0
void GetEthernetList(StringCollection& dev)
{
    CommandModel cmd;
    cmd.FuncName = FuncEthernetGetAll;
    cmd.Password = true;
    Value result;
    Rpc::Call(cmd, result);
    ENUM_LIST(EthernetInterface, List<EthernetInterface>(result), e)
    {
        EthernetInterface eth(*e);
        dev.insert(eth.Dev);
    }
Ejemplo n.º 15
0
  void beforeCall() {
    ogdf::TreeLayout *tree = static_cast<ogdf::TreeLayout*>(ogdfLayoutAlgo);

    if (dataSet != NULL) {
      double dval = 0;
      bool bval = false;
      StringCollection sc;

      if (dataSet->get("siblings distance", dval))
        tree->siblingDistance(dval);

      if (dataSet->get("subtrees distance", dval))
        tree->subtreeDistance(dval);

      if (dataSet->get("levels distance", dval))
        tree->levelDistance(dval);

      if (dataSet->get("trees distance", dval))
        tree->treeDistance(dval);

      if (dataSet->get("orthogonal layout", bval))
        tree->orthogonalLayout(bval);

      if (dataSet->get(ELT_ORIENTATION, sc)) {
        if (sc.getCurrent() == ELT_TOPTOBOTTOM) {
          tree->orientation(ogdf::topToBottom);
        }
        else if (sc.getCurrent() == ELT_BOTTOMTOTOP) {
          tree->orientation(ogdf::bottomToTop);
        }
        else if (sc.getCurrent() == ELT_LEFTTORIGHT) {
          tree->orientation(ogdf::leftToRight);
        }
        else {
          tree->orientation(ogdf::rightToLeft);
        }
      }

      if (dataSet->get(ELT_ROOTSELECTION, sc)) {
        if (sc.getCurrent() == ELT_ROOTSOURCE) {
          tree->rootSelection(ogdf::TreeLayout::rootIsSource);
        }
        else if (sc.getCurrent() == ELT_ROOTSINK) {
          tree->rootSelection(ogdf::TreeLayout::rootIsSink);
        }
        else {
          tree->rootSelection(ogdf::TreeLayout::rootByCoord);
        }
      }
    }
  }
Ejemplo n.º 16
0
  void beforeCall() {
    ogdf::SugiyamaLayout *sugiyama = static_cast<ogdf::SugiyamaLayout*>(ogdfLayoutAlgo);

    if (dataSet != NULL) {
      int ival = 0;
      double dval = 0;
      bool bval = false;
      StringCollection sc;

      if (dataSet->get("fails", ival))
        sugiyama->fails(ival);

      if (dataSet->get("runs", ival))
        sugiyama->runs(ival);

      if (dataSet->get("arrangeCCS", bval))
        sugiyama->arrangeCCs(bval);

      if (dataSet->get("minDistCC", dval))
        sugiyama->minDistCC(dval);

      if (dataSet->get("pageRatio", dval))
        sugiyama->pageRatio(dval);

      if (dataSet->get("alignBaseClasses", bval))
        sugiyama->alignBaseClasses(bval);

      if (dataSet->get("alignSiblings", bval))
        sugiyama->alignSiblings(bval);

      if (dataSet->get(ELT_RANKING, sc)) {
        if (sc.getCurrent() == ELT_LONGESTPATHRANKING) {
          sugiyama->setRanking(new ogdf::LongestPathRanking());
        }
        else if(sc.getCurrent() == ELT_OPTIMALRANKING) {
          sugiyama->setRanking(new ogdf::OptimalRanking());
        }
        else
          sugiyama->setRanking(new ogdf::CoffmanGrahamRanking());
      }

      if (dataSet->get(ELT_TWOLAYERCROSS, sc)) {
        if (sc.getCurrent() == ELT_BARYCENTER) {
          sugiyama->setCrossMin(new ogdf::BarycenterHeuristic());
        }
        else if (sc.getCurrent() == ELT_MEDIAN) {
          sugiyama->setCrossMin(new ogdf::MedianHeuristic());
        }
        else if(sc.getCurrent()==ELT_SPLIT) {
          sugiyama->setCrossMin(new ogdf::SplitHeuristic());
        }
        else if(sc.getCurrent()==ELT_SIFTING) {
          sugiyama->setCrossMin(new ogdf::SiftingHeuristic());
        }
        else if(sc.getCurrent()==ELT_GREEDYINSERT) {
          sugiyama->setCrossMin(new ogdf::GreedyInsertHeuristic());
        }
        else
          sugiyama->setCrossMin(new ogdf::GreedySwitchHeuristic());
      }

      if(dataSet->get(ELT_HIERARCHYLAYOUT, sc)) {
        double nodeDistance = 3;
        double layerDistance = 3;
        bool fixedLayerDistance = true;
        dataSet->get("node distance", nodeDistance);
        dataSet->get("layer distance", layerDistance);
        dataSet->get("fixed layer distance", fixedLayerDistance);

        if(sc.getCurrent()==ELT_FASTHIERARCHY) {
          ogdf::FastHierarchyLayout *fhl = new FastHierarchyLayout();
          fhl->nodeDistance(nodeDistance);
          fhl->layerDistance(layerDistance);
          fhl->fixedLayerDistance(fixedLayerDistance);
          sugiyama->setLayout(fhl);
        }
        else {
          sugiyama->setLayout(new ogdf::FastSimpleHierarchyLayout(static_cast<int>(nodeDistance), static_cast<int>(layerDistance)));
        }
      }
    }
  }
Ejemplo n.º 17
0
		StringCollection::StringCollection(const StringCollection &sc){
#ifdef USE_EMBEDDED_CLASSNAMES
			setClassName(__xvr2_Util_StringCollection);
#endif
			insert(begin(), sc.begin(), sc.end());
		}
//    namespace 
//    {
        static void PrintStringCollection(StringCollection const & coll, wstring const & header)
        {
            Trace.WriteInfo(TraceType, "{0}:", header);
            for_each(coll.begin(), coll.end(), [](wstring const & elem) { Trace.WriteInfo(TraceType, "\t\"{0}\"", elem); });
        }
//====================================================================
bool ConnectedComponentPacking::run() {

  LayoutProperty *layout = NULL;
  SizeProperty *size = NULL;
  DoubleProperty *rotation = NULL;
  string complexity("auto");

  workingGraph = graph->addCloneSubGraph("workingGraph");

  if ( dataSet!=NULL ) {
    dataSet->get("coordinates", layout);
    getNodeSizePropertyParameter(dataSet, size);
    dataSet->get("rotation", rotation);
    StringCollection complexityCol;

    if (dataSet->get("complexity", complexityCol))
      complexity = complexityCol.getCurrentString();
  }

  if (layout==NULL)
    layout = workingGraph->getProperty<LayoutProperty>("viewLayout");

  if (size==NULL)
    size = workingGraph->getProperty<SizeProperty>("viewSize");

  if (rotation==NULL)
    rotation = workingGraph->getProperty<DoubleProperty>("viewRotation");

  if (complexity=="none")
    complexity = "auto";

  // compute the connected components's subgraphs
  std::vector<std::set<node> > components;
  ConnectedTest::computeConnectedComponents(workingGraph, components);

  for (unsigned int i = 0; i < components.size(); ++i) {
    workingGraph->inducedSubGraph(components[i]);
  }

  vector<Rectangle<float> > rectangles;
  Iterator<Graph *> *it = workingGraph->getSubGraphs();

  while(it->hasNext()) {
    Graph *sg = it->next();
    BoundingBox tmp = tlp::computeBoundingBox(sg, layout, size, rotation);
    Rectangle<float> tmpRec;
    tmpRec[1][0] = tmp[1][0] + spacing;
    tmpRec[1][1] = tmp[1][1] + spacing;
    tmpRec[0][0] = tmp[0][0] + spacing;
    tmpRec[0][1] = tmp[0][1] + spacing;
    assert(tmpRec.isValid());
    rectangles.push_back(tmpRec);
  }

  delete it;

  if (complexity == "auto") {
    if (rectangles.size()<25) {
      complexity="n5";
    }
    else if (rectangles.size()<50) {
      complexity="n4logn";
    }
    else if (rectangles.size()<100) {
      complexity="n4";
    }
    else if (rectangles.size()<150) {
      complexity="n3logn";
    }
    else if (rectangles.size()<250) {
      complexity="n3";
    }
    else if (rectangles.size()<500) {
      complexity="n2logn";
    }
    else if (rectangles.size()<1000) {
      complexity="n2";
    }
    else if (rectangles.size()<5000) {
      complexity="nlogn";
    }
    else
      complexity="n";
  }

  vector<Rectangle<float> > rectanglesBackup(rectangles);
  RectanglePackingLimitRectangles(rectangles, complexity.c_str(), pluginProgress);
  Iterator<node> *itN = graph->getNodes();

  while(itN->hasNext()) {
    node n = itN->next();
    layoutResult->setNodeValue(n, layout->getNodeValue(n));
  }

  delete itN;
  Iterator<edge> *itE = graph->getEdges();

  while(itE->hasNext()) {
    edge e = itE->next();
    layoutResult->setEdgeValue(e, layout->getEdgeValue(e));
  }

  delete itE;
  unsigned int i = 0;
  it = workingGraph->getSubGraphs();

  while(it->hasNext()) {
    Graph *sg = it->next();
    Coord move(rectangles[i][0][0]-rectanglesBackup[i][0][0], rectangles[i][0][1]-rectanglesBackup[i][0][1], 0);
    layoutResult->translate(move, sg);
    ++i;
  }

  delete it;
  graph->delAllSubGraphs(workingGraph);

  return true;
}
 static void CheckStringCollectionsEquality(StringCollection & coll1, StringCollection & coll2)
 {
     sort(coll1.begin(), coll1.end());
     sort(coll2.begin(), coll2.end());
     BOOST_REQUIRE(coll1 == coll2);
 }
Ejemplo n.º 21
0
vector<ReplicaDescription> PlacementAndLoadBalancingUnitTest::CreateReplicas(wstring replicas, bool isUp)
{
    vector<ReplicaDescription> replicaVector;

    // format [replica1], [replica2], ...
    // each replica: [replicaRole]/[nodeIndex]/[IsToBePromoted][IsMoveInProgress][IsToBeDropped][IsInBuild]
    // replicaRole: P or S or SB
    // the last three descriptions optional inputs: PDB; treated as false by default
    StringCollection placement;
    StringUtility::Split<wstring>(replicas, placement, ItemDelimiter);

    for (wstring const& replica : placement)
    {
        StringCollection replicaFields;
        StringUtility::Split<wstring>(replica, replicaFields, PairDelimiter);

        ReplicaRole::Enum role = ReplicaRole::None;
        Reliability::ReplicaStates::Enum state = Reliability::ReplicaStates::Ready;
        StringUtility::TrimSpaces(replicaFields[0]);

        if (replicaFields[0] == L"P")
        {
            role = ReplicaRole::Primary;
        }
        else if (replicaFields[0] == L"S" || replicaFields[0] == L"I")
        {
            role = ReplicaRole::Secondary;
        }
        else if (replicaFields[0] == L"N")
        {
            role = ReplicaRole::None;
        }
        else if (replicaFields[0] == L"SB")
        {
            role = ReplicaRole::StandBy;
            state = Reliability::ReplicaStates::StandBy;
        }
        else if (replicaFields[0] == L"D")
        {
            role = ReplicaRole::Dropped;
            state = Reliability::ReplicaStates::Dropped;
        }

        int nodeIndex = _wtoi(replicaFields[1].c_str());
        Reliability::ReplicaFlags::Enum flags = Reliability::ReplicaFlags::None;

        if (replicaFields.size() >= 3)
        {
            wstring properties = replica.substr(replicaFields[0].length() + replicaFields[1].length() + 2);

            if (StringUtility::Contains<wstring>(properties, L"B"))
            {
                state = Reliability::ReplicaStates::InBuild;
            }

            if (StringUtility::Contains<wstring>(properties, L"I"))
            {
                flags = static_cast<Reliability::ReplicaFlags::Enum>(flags ^ Reliability::ReplicaFlags::PrimaryToBeSwappedOut);
            }

            if (StringUtility::Contains<wstring>(properties, L"J"))
            {
                flags = static_cast<Reliability::ReplicaFlags::Enum>(flags ^ Reliability::ReplicaFlags::PrimaryToBePlaced);
            }

            if (StringUtility::Contains<wstring>(properties, L"K"))
            {
                flags = static_cast<Reliability::ReplicaFlags::Enum>(flags ^ Reliability::ReplicaFlags::ReplicaToBePlaced);
            }

            if (StringUtility::Contains<wstring>(properties, L"V"))
            {
                flags = static_cast<Reliability::ReplicaFlags::Enum>(flags ^ Reliability::ReplicaFlags::MoveInProgress);
            }

            if (StringUtility::Contains<wstring>(properties, L"D"))
            {
                flags = static_cast<Reliability::ReplicaFlags::Enum>(flags ^ Reliability::ReplicaFlags::ToBeDroppedByFM);
            }

            if (StringUtility::Contains<wstring>(properties, L"R"))
            {
                flags = static_cast<Reliability::ReplicaFlags::Enum>(flags ^ Reliability::ReplicaFlags::ToBeDroppedByPLB);
            }

            if (StringUtility::Contains<wstring>(properties, L"T"))
            {
                flags = static_cast<Reliability::ReplicaFlags::Enum>(flags ^ Reliability::ReplicaFlags::ToBeDroppedForNodeDeactivation);
            }

            if (StringUtility::Contains<wstring>(properties, L"P"))
            {
                flags = static_cast<Reliability::ReplicaFlags::Enum>(flags ^ Reliability::ReplicaFlags::ToBePromoted);
            }

            if (StringUtility::Contains<wstring>(properties, L"N"))
            {
                flags = static_cast<Reliability::ReplicaFlags::Enum>(flags ^ Reliability::ReplicaFlags::PendingRemove);
            }

            if (StringUtility::Contains<wstring>(properties, L"Z"))
            {
                flags = static_cast<Reliability::ReplicaFlags::Enum>(flags ^ Reliability::ReplicaFlags::Deleted);
            }

            if (StringUtility::Contains<wstring>(properties, L"L"))
            {
                flags = static_cast<Reliability::ReplicaFlags::Enum>(flags ^ Reliability::ReplicaFlags::PreferredPrimaryLocation);
            }

            if (StringUtility::Contains<wstring>(properties, L"E"))
            {
                flags = static_cast<Reliability::ReplicaFlags::Enum>(flags ^ Reliability::ReplicaFlags::EndpointAvailable);
            }

            if (StringUtility::Contains<wstring>(properties, L"M"))
            {
                flags = static_cast<Reliability::ReplicaFlags::Enum>(flags ^ Reliability::ReplicaFlags::PreferredReplicaLocation);
            }
        }

        replicaVector.push_back(ReplicaDescription(
            CreateNodeInstance(nodeIndex, 0),
            role,
            state,
            isUp,   // isUp
            flags));
    }

    return replicaVector;
}
///===========================================================
bool ReachableSubGraphSelection::run() {
  unsigned int maxDistance = 5;
  StringCollection edgeDirectionCollecion;
  EDGE_TYPE edgeDirection=DIRECTED;
  BooleanProperty * startNodes=graph->getProperty<BooleanProperty>("viewSelection");

  if ( dataSet!=NULL) {
    dataSet->get("distance", maxDistance);

    //Get the edge orientation
    if(dataSet->get("edges direction",edgeDirectionCollecion)) {
      if(edgeDirectionCollecion.getCurrentString() == edgesDirectionLabels[0]) {
        edgeDirection = DIRECTED;
      }
      else if(edgeDirectionCollecion.getCurrentString()== edgesDirectionLabels[1]) {
        edgeDirection = INV_DIRECTED;
      }
      else if(edgeDirectionCollecion.getCurrentString()== edgesDirectionLabels[2]) {
        edgeDirection = UNDIRECTED;
      }
    }
    else {
      //If the new parameter is not defined search for the old one.
      int direction=0;

      if(dataSet->get("direction",direction)) {
        switch(direction) {
        case 0:
          edgeDirection = DIRECTED;
          break;

        case 1:
          edgeDirection = INV_DIRECTED;
          break;

        case 2:
          edgeDirection = UNDIRECTED;
        }
      }
    }

    dataSet->get("startingnodes", startNodes);
  }

  result->setAllEdgeValue(false);
  result->setAllNodeValue(false);

  if (startNodes) {
    Iterator<node>* itN = startNodes->getNodesEqualTo(true);
    std::set<node> reachables;

    // iterate on startNodes add them and their reachables
    while (itN->hasNext()) {
      node current = itN->next();
      reachables.insert(current);
      reachableNodes(graph, current, reachables, maxDistance,
                     edgeDirection);
    }

    delete itN;

    std::set<node>::const_iterator itr = reachables.begin();
    std::set<node>::const_iterator ite = reachables.end();

    // select nodes
    while (itr != ite) {
      result->setNodeValue((*itr), true);
      ++itr;
    }

    // select corresponding edges
    Iterator<edge> *itE = graph->getEdges();

    while(itE->hasNext()) {
      edge e = itE->next();
      const std::pair<node, node>& ends = graph->ends(e);

      if (result->getNodeValue(ends.first) &&
          result->getNodeValue(ends.second))
        result->setEdgeValue(e, true);
    }

    delete itE;
  }

  return true;
}