Exemplo n.º 1
0
  void testDictInterface1()
  {
    ScopedFileCopy copy("empty", ".ogg");
    string newname = copy.fileName();

    Vorbis::File f(newname.c_str());

    CPPUNIT_ASSERT_EQUAL((unsigned int)0, f.tag()->properties().size());

    PropertyMap newTags;
    StringList values("value 1");
    values.append("value 2");
    newTags["ARTIST"] = values;
    f.tag()->setProperties(newTags);

    PropertyMap map = f.tag()->properties();
    CPPUNIT_ASSERT_EQUAL((unsigned int)1, map.size());
    CPPUNIT_ASSERT_EQUAL((unsigned int)2, map["ARTIST"].size());
    CPPUNIT_ASSERT_EQUAL(String("value 1"), map["ARTIST"][0]);
  }
void tst_QDBusXmlParser::properties()
{
    QString xmlHeader = "<node>"
                        "<interface name=\"iface.iface1\">",
            xmlFooter = "</interface>"
                        "</node>";

    QFETCH(QString, xmlDataFragment);

    QDBusIntrospection::Interface iface =
        QDBusIntrospection::parseInterface(xmlHeader + xmlDataFragment + xmlFooter);

    QCOMPARE(iface.name, QString("iface.iface1"));

    QFETCH(PropertyMap, propertyMap);
    PropertyMap parsedMap = iface.properties;

    QCOMPARE(propertyMap.count(), parsedMap.count());
    QCOMPARE(propertyMap, parsedMap);
}
Exemplo n.º 3
0
UT_sint32 TCPAccountHandler::_getPort(const PropertyMap& props)
{
	PropertyMap::const_iterator pi = props.find("port");

	UT_sint32 port = -1;
	if (pi == props.end()) // no port specified, use the default port
	{
		port = DEFAULT_TCP_PORT;
	}
	else
	{
		long portl = strtol(pi->second.c_str(), (char **)NULL, 10);
		if (portl == LONG_MIN || portl == LONG_MAX) // TODO: we should check errno here for ERANGE
			port = DEFAULT_TCP_PORT;
		else
			port = (UT_sint32)portl;	
	}
	
	return port;
}
Exemplo n.º 4
0
void FileDialog::initialise(const Root* r, const PropertyMap& p) {
	Window::initialise(r, p);
	if(m_client->getWidgetCount()==0) return; // Nothing

	// Cache sub widgets
	m_list = getWidget<Listbox>("filelist");
	m_file = getWidget<Textbox>("filename");
	m_dir  = getWidget<Textbox>("path");
	m_confirm = getWidget<Button>("confirm");
	
	// Set up callbacks
	m_list->eventSelected.bind(this, &FileDialog::selectFile);
	m_list->eventMouseDown.bind(this, &FileDialog::clickFile);
	m_confirm->eventPressed.bind(this, &FileDialog::pressConfirm);
	m_file->eventChanged.bind(this, &FileDialog::changedFileName);
	m_file->eventSubmit.bind(this, &FileDialog::submitFileName);
	m_dir->eventSubmit.bind(this, &FileDialog::changedDirectory);
	
	
	Button* btn = getWidget<Button>("up");
	if(btn) btn->eventPressed.bind(this, &FileDialog::pressUp);
	btn = getWidget<Button>("back");
	if(btn) btn->eventPressed.bind(this, &FileDialog::pressBack);
	btn = getWidget<Button>("fwd");
	if(btn) btn->eventPressed.bind(this, &FileDialog::pressForward);

	// Cache icons
	m_folderIcon = m_list->getIconList()->getIconIndex("folder");
	m_fileIcon = m_list->getIconList()->getIconIndex("file");
	

	// Load properties
	const char* initialPath = ".";
	if(p.contains("filter")) setFilter( p["filter"] );
	if(p.contains("dir")) initialPath = p["dir"];

	// Initial directory
	char buffer[FILENAME_MAX];
	Directory::getFullPath(initialPath, buffer);
	setDirectory(buffer);
}
Exemplo n.º 5
0
PropertyMap MP4::Tag::setProperties(const PropertyMap &props)
{
  static Map<String, String> reverseKeyMap;
  if(reverseKeyMap.isEmpty()) {
    int numKeys = sizeof(keyTranslation) / sizeof(keyTranslation[0]);
    for(int i = 0; i < numKeys; i++) {
      reverseKeyMap[keyTranslation[i][1]] = keyTranslation[i][0];
    }
  }

  PropertyMap origProps = properties();
  for(PropertyMap::ConstIterator it = origProps.begin(); it != origProps.end(); ++it) {
    if(!props.contains(it->first) || props[it->first].isEmpty()) {
      d->items.erase(reverseKeyMap[it->first]);
    }
  }

  PropertyMap ignoredProps;
  for(PropertyMap::ConstIterator it = props.begin(); it != props.end(); ++it) {
    if(reverseKeyMap.contains(it->first)) {
      String name = reverseKeyMap[it->first];
      if((it->first == "TRACKNUMBER" || it->first == "DISCNUMBER") && !it->second.isEmpty()) {
        StringList parts = StringList::split(it->second.front(), "/");
        if(!parts.isEmpty()) {
          int first = parts[0].toInt();
          int second = 0;
          if(parts.size() > 1) {
            second = parts[1].toInt();
          }
          d->items[name] = MP4::Item(first, second);
        }
      }
      else if((it->first == "BPM" || it->first == "MOVEMENTNUMBER" || it->first == "MOVEMENTCOUNT") && !it->second.isEmpty()) {
        int value = it->second.front().toInt();
        d->items[name] = MP4::Item(value);
      }
      else if((it->first == "COMPILATION" || it->first == "SHOWWORKMOVEMENT") && !it->second.isEmpty()) {
        bool value = (it->second.front().toInt() != 0);
        d->items[name] = MP4::Item(value);
      }
      else {
        d->items[name] = it->second;
      }
    }
    else {
      ignoredProps.insert(it->first, it->second);
    }
  }

  return ignoredProps;
}
PropertyMap TextIdentificationFrame::makeTMCLProperties() const
{
  PropertyMap map;
  if(fieldList().size() % 2 != 0){
    // according to the ID3 spec, TMCL must contain an even number of entries
    map.unsupportedData().append(frameID());
    return map;
  }
  StringList l = fieldList();
  for(StringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
    String instrument = it->upper();
    if(instrument.isEmpty()) {
      // instrument is not a valid key -> frame unsupported
      map.clear();
      map.unsupportedData().append(frameID());
      return map;
    }
    map.insert(L"PERFORMER:" + instrument, (++it)->split(","));
  }
  return map;
}
Exemplo n.º 7
0
  void testDictInterface2()
  {
    ScopedFileCopy copy("test", ".ogg");
    string newname = copy.fileName();

    Vorbis::File *f = new Vorbis::File(newname.c_str());
    PropertyMap tags = f->tag()->properties();

    CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), tags["UNUSUALTAG"].size());
    CPPUNIT_ASSERT_EQUAL(String("usual value"), tags["UNUSUALTAG"][0]);
    CPPUNIT_ASSERT_EQUAL(String("another value"), tags["UNUSUALTAG"][1]);
    CPPUNIT_ASSERT_EQUAL(String("öäüoΣø", String::UTF8), tags["UNICODETAG"][0]);

    tags["UNICODETAG"][0] = String("νεω ναλυε", String::UTF8);
    tags.erase("UNUSUALTAG");
    f->tag()->setProperties(tags);
    CPPUNIT_ASSERT_EQUAL(String("νεω ναλυε", String::UTF8), f->tag()->properties()["UNICODETAG"][0]);
    CPPUNIT_ASSERT_EQUAL(false, f->tag()->properties().contains("UNUSUALTAG"));

    delete f;
  }
Exemplo n.º 8
0
void SO3CSpace::Properties(PropertyMap& pmap)
{
  pmap.set("cartesian",0);
  pmap.set("geodesic",1);
  pmap.set("metric","so3");
  pmap.set("volume",Pow(Pi,3.0));
  pmap.setArray("minimum",vector<double>(3,-Pi));
  pmap.setArray("maximum",vector<double>(3,Pi));
  pmap.set("diameter",TwoPi);
}
Exemplo n.º 9
0
PropertyMap ASF::Tag::properties() const
{
  PropertyMap props;

  if(!d->title.isEmpty()) {
    props["TITLE"] = d->title;
  }
  if(!d->artist.isEmpty()) {
    props["ARTIST"] = d->artist;
  }
  if(!d->copyright.isEmpty()) {
    props["COPYRIGHT"] = d->copyright;
  }
  if(!d->comment.isEmpty()) {
    props["COMMENT"] = d->comment;
  }

  ASF::AttributeListMap::ConstIterator it = d->attributeListMap.begin();
  for(; it != d->attributeListMap.end(); ++it) {
    const String key = translateKey(it->first);
    if(!key.isEmpty()) {
      AttributeList::ConstIterator it2 = it->second.begin();
      for(; it2 != it->second.end(); ++it2) {
        if(key == "TRACKNUMBER") {
          if(it2->type() == ASF::Attribute::DWordType)
            props.insert(key, String::number(it2->toUInt()));
          else
            props.insert(key, it2->toString());
        }
        else {
          props.insert(key, it2->toString());
        }
      }
    }
    else {
      props.unsupportedData().append(it->first);
    }
  }
  return props;
}
Exemplo n.º 10
0
PropertyMap MP4::Tag::properties() const
{
  static Map<String, String> keyMap;
  if(keyMap.isEmpty()) {
    int numKeys = sizeof(keyTranslation) / sizeof(keyTranslation[0]);
    for(int i = 0; i < numKeys; i++) {
      keyMap[keyTranslation[i][0]] = keyTranslation[i][1];
    }
  }

  PropertyMap props;
  MP4::ItemMap::ConstIterator it = d->items.begin();
  for(; it != d->items.end(); ++it) {
    if(keyMap.contains(it->first)) {
      String key = keyMap[it->first];
      if(key == "TRACKNUMBER" || key == "DISCNUMBER") {
        MP4::Item::IntPair ip = it->second.toIntPair();
        String value = String::number(ip.first);
        if(ip.second) {
          value += "/" + String::number(ip.second);
        }
        props[key] = value;
      }
      else if(key == "BPM") {
        props[key] = String::number(it->second.toInt());
      }
      else if(key == "COMPILATION") {
        props[key] = String::number(it->second.toBool());
      }
      else {
        props[key] = it->second.toStringList();
      }
    }
    else {
      props.unsupportedData().append(it->first);
    }
  }
  return props;
}
Exemplo n.º 11
0
  void testDictInterface1()
  {
    ScopedFileCopy copy("empty", ".ogg");
    string newname = copy.fileName();

    Vorbis::File *f = new Vorbis::File(newname.c_str());

    CPPUNIT_ASSERT_EQUAL(TagLib::uint(0), f->tag()->properties().size());

    PropertyMap newTags;
    StringList values("value 1");
    values.append("value 2");
    newTags["ARTIST"] = values;
    f->tag()->setProperties(newTags);

    PropertyMap map = f->tag()->properties();
    CPPUNIT_ASSERT_EQUAL(TagLib::uint(1), map.size());
    CPPUNIT_ASSERT_EQUAL(TagLib::uint(2), map["ARTIST"].size());
    CPPUNIT_ASSERT_EQUAL(String("value 1"), map["ARTIST"][0]);
    delete f;

  }
Exemplo n.º 12
0
int main ()
{
  printf ("Results of transaction_test:\n");
  
  try
  {
    Transaction transaction;

    printf ("default transaction\n");

    dump (transaction);

    transaction.SetState (TransactionState_Purchased);
    transaction.SetStatus ("Success");
    transaction.SetProductId ("ProductId");
    transaction.SetQuantity (4);
    transaction.SetReceipt (xtl::xstrlen (RECEIPT), RECEIPT);
    transaction.SetHandle ((const void*)1);

    PropertyMap properties;

    properties.SetProperty ("String", "StringValue");
    properties.SetProperty ("IntValue", 10);

    transaction.SetProperties (properties);

    printf ("filled transaction\n");

    dump (transaction);

    transaction.Finish ();
  }
  catch (std::exception& exception)
  {
    printf ("exception: %s\n", exception.what ());
  }

  return 0;
}
Exemplo n.º 13
0
 virtual void GetStats(PropertyMap& stats) const {
   MotionPlannerInterface::GetStats(stats);
   stats.set("configCheckTime",planner.tCheck);
   stats.set("knnTime",planner.tKnn);
   stats.set("connectTime",planner.tConnect);
   if(planner.lazy)
     stats.set("lazyPathCheckTime",planner.tLazy);
   stats.set("shortestPathsTime",planner.tShortestPaths);
   stats.set("numEdgeChecks",planner.numEdgeChecks);
   if(planner.lazy)
     stats.set("numEdgesPrechecked",planner.numEdgePrechecks);
 }
Exemplo n.º 14
0
void Frame::splitProperties(const PropertyMap &original, PropertyMap &singleFrameProperties,
                            PropertyMap &tiplProperties, PropertyMap &tmclProperties)
{

    singleFrameProperties.clear();
    tiplProperties.clear();
    tmclProperties.clear();
    for(PropertyMap::ConstIterator it = original.begin(); it != original.end(); ++it) {
        if(TextIdentificationFrame::involvedPeopleMap().contains(it->first))
            tiplProperties.insert(it->first, it->second);
        else if(it->first.startsWith(TextIdentificationFrame::instrumentPrefix))
            tmclProperties.insert(it->first, it->second);
        else
            singleFrameProperties.insert(it->first, it->second);
    }
}
Exemplo n.º 15
0
void testMisc() {
  PropertyMap *map;

  // test remove() doesn't crash with empty list
  map = new PropertyMap();
  map->remove("nonexistant");
  delete map;
  printf("PASS: remove() doesn't crash with empty list\n");

  // test get() doesn't crash with empty list
  map = new PropertyMap();
  map->get("nonexistant");
  delete map;
  printf("PASS: get() doesn't crash with empty list\n");

  // test get() returns 0 on an empty list
  map = new PropertyMap();
  if (map->get("nonexistant") == 0)
    printf("PASS: get() returns 0 on an empty list\n");
  else
    printf("FAIL: get() returns 0 on an empty list\n");
  delete map;
}
Exemplo n.º 16
0
void RTComponent::setupModules(string& fileName, string& initFuncName, string& componentName, PropertyMap& prop)
{
    RTC::Manager& rtcManager = RTC::Manager::instance();

    rtcManager.load(fileName.c_str(), initFuncName.c_str());

    string option("?");
    for(PropertyMap::iterator it = prop.begin(); it != prop.end(); ){
        option += it->first + "=" + it->second;
        if(++it != prop.end()){
            option += "&";
        }
    }
    rtc_ = createManagedRTC((componentName + option).c_str());

    if(!rtc_){
        mv->putln(fmt(_("RTC \"%1%\" cannot be created by the RTC manager.\n"
                        " RTC module file: \"%2%\"\n"
                        " Init function: %3%\n"
                        " option: %4%"))
                  % componentName % fileName % initFuncName % option);
    }
}
Exemplo n.º 17
0
void GObject::registerProperty ( GObject* obj )
{
    assert ( obj );
    obj->registerAll();

    const CategoryPropertyMap& otherPropMap = obj->getPropertyMap();

    CategoryPropertyMap::const_iterator ibegin = otherPropMap.begin();
    CategoryPropertyMap::const_iterator iend = otherPropMap.end();

    for ( ; ibegin != iend; ++ibegin )
    {
        PropertyMap* myPropMap = 0;
        if ( mOption.Get ( ibegin->first, myPropMap ) )
        {
            assert ( 0 );
        }
        else
        {
            myPropMap = new PropertyMap;
            mOption.Insert ( ibegin->first, myPropMap );
        }
        const PropertyMap* propMap = ibegin->second;
        for ( PropertyMap::const_iterator walk = propMap->begin();
                walk != propMap->end(); ++walk )
        {
            EPropertyVar* evar = new EPropertyVar;
            evar->mPtr = walk->second->mPtr;
            evar->mCategoryName = walk->second->mCategoryName;
            evar->mProp = walk->second->mProp;
            evar->mRefOther = true;
            myPropMap->Insert ( walk->first, evar );
        }
    }
    //mOption.insert ( ibegin, iend );
}
Exemplo n.º 18
0
  PRMStarInterface(CSpace* space) : planner(space)
  {
    //planner.connectByRadius = true;
    planner.connectByRadius = false;
    PropertyMap props;
    space->Properties(props);
    int d;
    if(props.get("intrinsicDimension",d))
      ;
    else {
      Vector q;
      space->Sample(q);
      d = q.n;
    }
    Real v;
    if(props.get("volume",v)) {
      planner.connectRadiusConstant = Pow(v,1.0/Real(d));
    }
    else
      planner.connectRadiusConstant = 1;

    //TEMP: test keeping this at a constant regardless of space volume?
    //planner.connectRadiusConstant = 1;
  }
Exemplo n.º 19
0
  void testDictInterface2()
  {
    ScopedFileCopy copy("test", ".ogg");
    string newname = copy.fileName();

    Vorbis::File f(newname.c_str());
    PropertyMap tags = f.tag()->properties();

    CPPUNIT_ASSERT_EQUAL((unsigned int)2, tags["UNUSUALTAG"].size());
    CPPUNIT_ASSERT_EQUAL(String("usual value"), tags["UNUSUALTAG"][0]);
    CPPUNIT_ASSERT_EQUAL(String("another value"), tags["UNUSUALTAG"][1]);
    CPPUNIT_ASSERT_EQUAL(
      String("\xC3\xB6\xC3\xA4\xC3\xBC\x6F\xCE\xA3\xC3\xB8", String::UTF8),
      tags["UNICODETAG"][0]);

    tags["UNICODETAG"][0] = String(
      "\xCE\xBD\xCE\xB5\xCF\x89\x20\xCE\xBD\xCE\xB1\xCE\xBB\xCF\x85\xCE\xB5", String::UTF8);
    tags.erase("UNUSUALTAG");
    f.tag()->setProperties(tags);
    CPPUNIT_ASSERT_EQUAL(
      String("\xCE\xBD\xCE\xB5\xCF\x89\x20\xCE\xBD\xCE\xB1\xCE\xBB\xCF\x85\xCE\xB5", String::UTF8),
      f.tag()->properties()["UNICODETAG"][0]);
    CPPUNIT_ASSERT_EQUAL(false, f.tag()->properties().contains("UNUSUALTAG"));
  }
Exemplo n.º 20
0
    void List::fromPropertyMap(PropertyMap const& _map)
    {
      clear();
      PropertyMap _children = _map.getValue("inputs",PropertyMap());
      auto _ids = _children.ids();

      for (auto& _id : _ids) {
        _children.getPtr(_id,[&](Id const& _typeId) ->
                         Input *
          {
            return addInput(_typeId);
          });
      }

      
      _map("currentIndex",currentIndex_);
      setCurrentIndex(currentIndex_);
    }
Exemplo n.º 21
0
void Identifier::Private::setProperties(
    const PropertyMap &properties) // throw(InvalidValueTypeException)
{
    {
        const auto pVal = properties.get(AUTHORITY_KEY);
        if (pVal) {
            if (auto genVal = dynamic_cast<const BoxedValue *>(pVal->get())) {
                if (genVal->type() == BoxedValue::Type::STRING) {
                    authority_ = Citation(genVal->stringValue());
                } else {
                    throw InvalidValueTypeException("Invalid value type for " +
                                                    AUTHORITY_KEY);
                }
            } else {
                if (auto citation =
                        dynamic_cast<const Citation *>(pVal->get())) {
                    authority_ = *citation;
                } else {
                    throw InvalidValueTypeException("Invalid value type for " +
                                                    AUTHORITY_KEY);
                }
            }
        }
    }

    {
        const auto pVal = properties.get(CODE_KEY);
        if (pVal) {
            if (auto genVal = dynamic_cast<const BoxedValue *>(pVal->get())) {
                if (genVal->type() == BoxedValue::Type::INTEGER) {
                    code_ = toString(genVal->integerValue());
                } else if (genVal->type() == BoxedValue::Type::STRING) {
                    code_ = genVal->stringValue();
                } else {
                    throw InvalidValueTypeException("Invalid value type for " +
                                                    CODE_KEY);
                }
            } else {
                throw InvalidValueTypeException("Invalid value type for " +
                                                CODE_KEY);
            }
        }
    }

    properties.getStringValue(CODESPACE_KEY, codeSpace_);
    properties.getStringValue(VERSION_KEY, version_);
    properties.getStringValue(DESCRIPTION_KEY, description_);
    properties.getStringValue(URI_KEY, uri_);
}
Exemplo n.º 22
0
TEST(common, identifiedobject) {
    PropertyMap properties;
    properties.set(IdentifiedObject::NAME_KEY, "name");
    properties.set(IdentifiedObject::IDENTIFIERS_KEY,
                   Identifier::create("identifier_code"));
    properties.set(IdentifiedObject::ALIAS_KEY, "alias");
    properties.set(IdentifiedObject::REMARKS_KEY, "remarks");
    properties.set(IdentifiedObject::DEPRECATED_KEY, true);
    auto obj = OperationParameter::create(properties);
    EXPECT_EQ(*(obj->name()->description()), "name");
    ASSERT_EQ(obj->identifiers().size(), 1);
    EXPECT_EQ(obj->identifiers()[0]->code(), "identifier_code");
    ASSERT_EQ(obj->aliases().size(), 1);
    EXPECT_EQ(obj->aliases()[0]->toString(), "alias");
    EXPECT_EQ(obj->remarks(), "remarks");
    EXPECT_TRUE(obj->isDeprecated());
}
Exemplo n.º 23
0
void LabelActorTests::TestLabelActorCreateActorProperties()
{
   using namespace dtActors;

   try
   {
      // Get the actor from the proxy.
      dtABC::LabelActor* actor = NULL;
      mLabelProxy->GetActor(actor);

      dtABC::LabelActor::ActorPropertyArray propArray;
      actor->CreateActorProperties(propArray);

      typedef std::map<dtUtil::RefString, dtDAL::ActorProperty*> PropertyMap;
      PropertyMap propMap;

      // Convert the array to a map keyed on the property names.
      dtDAL::ActorProperty* curProp = NULL; // use this for code readability.
      dtABC::LabelActor::ActorPropertyArray::iterator curPropIter = propArray.begin();
      dtABC::LabelActor::ActorPropertyArray::iterator endPropArray = propArray.end();
      for (; curPropIter != endPropArray; ++curPropIter)
      {
         curProp = curPropIter->get(); // This is better for code readability.
         propMap.insert(std::make_pair(curProp->GetName(),curProp));
      }

      PropertyMap::iterator endMap = propMap.end(); // This is for better code readability.
      CPPUNIT_ASSERT(propMap.find(dtABC::LabelActor::PROPERTY_TEXT) != endMap);
      CPPUNIT_ASSERT(propMap.find(dtABC::LabelActor::PROPERTY_FONT) != endMap);
      CPPUNIT_ASSERT(propMap.find(dtABC::LabelActor::PROPERTY_FONT_SIZE) != endMap);
      CPPUNIT_ASSERT(propMap.find(dtABC::LabelActor::PROPERTY_BACK_SIZE) != endMap);
      CPPUNIT_ASSERT(propMap.find(dtABC::LabelActor::PROPERTY_TEXT_COLOR) != endMap);
      CPPUNIT_ASSERT(propMap.find(dtABC::LabelActor::PROPERTY_BACK_COLOR) != endMap);
      CPPUNIT_ASSERT(propMap.find(dtABC::LabelActor::PROPERTY_BACK_VISIBLE) != endMap);
   }
   catch (const dtUtil::Exception& e)
   {
      CPPUNIT_FAIL(e.ToString());
   }
}
Exemplo n.º 24
0
void ProgramState::computeBetweenness(PropertyMap& propertyMap) {
    IGraphFactory<Graph, Vertex> *factory;
    IBetweenness<Graph, Vertex>* betweenness;
    IGraphFactory<WeightedGraph, WeightedVertex> *wfactory;
    IBetweenness<WeightedGraph, WeightedVertex>* wbetweenness;
    IDegreeDistribution<WeightedGraph, WeightedVertex>* wdegreeDistribution;
    IDegreeDistribution<Graph, Vertex>* degreeDistribution;

    // Calculate betweenness.
    if (this->weighted){
        wfactory = new WeightedGraphFactory<WeightedGraph, WeightedVertex>();
        wbetweenness = wfactory->createBetweenness(this->weightedGraph);
        IBetweenness<WeightedGraph, WeightedVertex>::BetweennessIterator betweennessIterator = wbetweenness->iterator();
        while (!betweennessIterator.end()) {
                propertyMap.addProperty<double>("betweenness", to_string<unsigned int>(betweennessIterator->first), betweennessIterator->second);
                ++betweennessIterator;
        }
	delete wbetweenness;
    }else{
    	factory = new GraphFactory<Graph, Vertex>();
    	betweenness = factory->createBetweenness(this->graph);
    	IBetweenness<Graph, Vertex>::BetweennessIterator betweennessIterator = betweenness->iterator();
    	while (!betweennessIterator.end()) {
       		propertyMap.addProperty<double>("betweenness", to_string<unsigned int>(betweennessIterator->first), betweennessIterator->second);
        	++betweennessIterator;
    	}
	delete betweenness;
    }

    // Calculate degree distribution.
    if (this->weighted){
        wdegreeDistribution = wfactory->createDegreeDistribution(this->weightedGraph);
        DegreeDistribution<WeightedGraph, WeightedVertex>::DistributionIterator degreeIterator = wdegreeDistribution->iterator();
        while (!degreeIterator.end()) {
                propertyMap.addProperty<double>("degreeDistribution", to_string<unsigned int>(degreeIterator->first), degreeIterator->second);
                propertyMap.addProperty<double>("degreeDistributionProbability", to_string<unsigned int>(degreeIterator->first), degreeIterator->second / (double)graph.verticesCount());
                ++degreeIterator;
        }
        delete degreeDistribution;
    } else {
	degreeDistribution = factory->createDegreeDistribution(graph);
    	DegreeDistribution<Graph, Vertex>::DistributionIterator degreeIterator = degreeDistribution->iterator();
    	while (!degreeIterator.end()) {
        	propertyMap.addProperty<double>("degreeDistribution", to_string<unsigned int>(degreeIterator->first), degreeIterator->second);
        	propertyMap.addProperty<double>("degreeDistributionProbability", to_string<unsigned int>(degreeIterator->first), degreeIterator->second / (double)graph.verticesCount());
        	++degreeIterator;
    	}
    	delete degreeDistribution;
    }


    double betweennessAuxAcum;
    unsigned int degreeAmount;
    VariantsSet betweennessVsDegree;
    VariantsSet& betweennessSet = propertyMap.getPropertySet("betweenness");
    VariantsSet& degreeDistributionSet = propertyMap.getPropertySet("degreeDistribution");
    VariantsSet::const_iterator it = degreeDistributionSet.begin();
    VariantsSet::const_iterator betwennessIt = betweennessSet.begin();
    VariantsSet::const_iterator betweennessVsDegreeIt;
    while (it != degreeDistributionSet.end())
    {
        betweennessVsDegree.insert<double>(it->first, 0.0);
        ++it;
    }
    while (betwennessIt != betweennessSet.end())
    {
        unsigned int vertedId = from_string<unsigned int>(betwennessIt->first);
        //Vertex* v = graph.getVertexById(vertedId);
	Vertex* v = this->weighted ? weightedGraph.getVertexById(vertedId) : graph.getVertexById(vertedId);
        betweennessAuxAcum = betweennessVsDegree.get_element<double>(to_string<unsigned int>(v->degree()));
        betweennessVsDegree.insert<double>(to_string<unsigned int>(v->degree()) , betweennessAuxAcum + from_string<unsigned int>(betwennessIt->second));

        ++betwennessIt;
    }


    betweennessVsDegreeIt = betweennessVsDegree.begin();
    while (betweennessVsDegreeIt != betweennessVsDegree.end())
    {
        std::string degree = betweennessVsDegreeIt->first;
        betweennessAuxAcum = from_string<double>(betweennessVsDegreeIt->second);
        degreeAmount = degreeDistributionSet.get_element<unsigned int>(degree);

        propertyMap.addProperty<double>("betweennessVsDegree", degree, betweennessAuxAcum / (double)degreeAmount);
        ++betweennessVsDegreeIt;
    }
}
Exemplo n.º 25
0
PropertyMap ID3v2::Tag::setProperties(const PropertyMap &origProps)
{
  FrameList framesToDelete;
  // we split up the PropertyMap into the "normal" keys and the "complicated" ones,
  // which are those according to TIPL or TMCL frames.
  PropertyMap properties;
  PropertyMap tiplProperties;
  PropertyMap tmclProperties;
  Frame::splitProperties(origProps, properties, tiplProperties, tmclProperties);
  for(FrameListMap::ConstIterator it = frameListMap().begin(); it != frameListMap().end(); ++it){
    for(FrameList::ConstIterator lit = it->second.begin(); lit != it->second.end(); ++lit){
      PropertyMap frameProperties = (*lit)->asProperties();
      if(it->first == "TIPL") {
        if (tiplProperties != frameProperties)
          framesToDelete.append(*lit);
        else
          tiplProperties.erase(frameProperties);
      } else if(it->first == "TMCL") {
        if (tmclProperties != frameProperties)
          framesToDelete.append(*lit);
        else
          tmclProperties.erase(frameProperties);
      } else if(!properties.contains(frameProperties))
        framesToDelete.append(*lit);
      else
        properties.erase(frameProperties);
    }
  }
  for(FrameList::ConstIterator it = framesToDelete.begin(); it != framesToDelete.end(); ++it)
    removeFrame(*it);

  // now create remaining frames:
  // start with the involved people list (TIPL)
  if(!tiplProperties.isEmpty())
      addFrame(TextIdentificationFrame::createTIPLFrame(tiplProperties));
  // proceed with the musician credit list (TMCL)
  if(!tmclProperties.isEmpty())
      addFrame(TextIdentificationFrame::createTMCLFrame(tmclProperties));
  // now create the "one key per frame" frames
  for(PropertyMap::ConstIterator it = properties.begin(); it != properties.end(); ++it)
    addFrame(Frame::createTextualFrame(it->first, it->second));
  return PropertyMap(); // ID3 implements the complete PropertyMap interface, so an empty map is returned
}
Exemplo n.º 26
0
void ProgramState::exportMaxCliqueAprox(string outputPath){
	PropertyMap propertyMap;
    computeMaxCliqueDistr(propertyMap,false,0);
    GrapherUtils utils;
    utils.exportPropertySet(propertyMap.getPropertySet("maxCliqueAproxDistribution"), outputPath);
}
Exemplo n.º 27
0
void MotionPlannerInterface::GetStats(PropertyMap& stats) const
{
  stats.set("numIters",NumIterations());
  stats.set("numMilestones",NumMilestones());
  stats.set("numComponents",NumComponents());
}
Exemplo n.º 28
0
void ProgramState::exportCCBoxplot(string outputPath) {
    PropertyMap propertyMap;
    computeNearestNeighborsDegree(propertyMap);
    GrapherUtils grapherUtils;
    grapherUtils.exportPropertySet(propertyMap.getPropertySet("nearestNeighborDegreeForDegree"), outputPath);
}
Exemplo n.º 29
0
void ProgramState::exportClusteringVsDegree(string outputPath) {
    PropertyMap propertyMap;
    computeClusteringCoefficient(propertyMap);
    GrapherUtils grapherUtils;
    grapherUtils.exportPropertySet(propertyMap.getPropertySet("clusteringCoeficientForDegree"), outputPath);
}
Exemplo n.º 30
0
void ProgramState::exportBetweennessVsDegree(string outputPath) {
    PropertyMap propertyMap;
    computeBetweenness(propertyMap);
    GrapherUtils utils;
    utils.exportPropertySet(propertyMap.getPropertySet("betweennessVsDegree"), outputPath);
}