Exemplo n.º 1
0
void Card::update(const pa_card_info *info)
{
    updatePulseObject(info);

    QString infoName = QString::fromUtf8(info->name);
    if (m_name != infoName) {
        m_name = infoName;
        emit nameChanged();
    }

    qDeleteAll(m_profiles);
    m_profiles.clear();
    for (auto **it = info->profiles2; it && *it != nullptr; ++it) {
        Profile *profile = new Profile(this);
        profile->setInfo(*it);
        m_profiles.append(profile);
        if (info->active_profile2 == *it) {
            m_activeProfileIndex = m_profiles.length() - 1;
        }
    }
    emit profilesChanged();
    emit activeProfileIndexChanged();

    qDeleteAll(m_ports);
    m_ports.clear();
    for (auto **it = info->ports; it && *it != nullptr; ++it) {
        CardPort *port = new CardPort(this);
        port->update(*it);
        m_ports.append(port);
    }
    emit portsChanged();
}
Exemplo n.º 2
0
QVariant ProfileList::data ( const QModelIndex & index, int role ) const
{
    //qDebug() << "Qml asking for entry " << index.row();

    if( _profiles == 0 )
        return QVariant();
    if (!index.isValid())
        return QVariant(); // Return Null variant if index is invalid
    if (index.row() > (_profiles->count()) )
        return QVariant();

    Profile *dobj = _profiles->values().at(index.row());

    if( dobj )
    {
        //qDebug() << "Bitrate: " << dobj->getBitrate()
                // << "Name: " << dobj->getName()
                // << "Id: " << dobj->getId();

        switch (role) {
        case Qt::DisplayRole: // The default display role now displays the first name as well
        case IdRole:
            return QVariant::fromValue(dobj->getId());
        case NameRole:
            return QVariant::fromValue(dobj->getName());
        default:
            return QVariant();
        }
    } else {
        return QVariant();
    }

}
//tabulates (sin(qr)/qr - cos(qr))/r^2 over the range of qs of the profile
//and up to max_distance for r.
void DerivativeCalculator::compute_sinc_cos(Float pr_resolution,
                                            Float max_distance,
                                            const Profile& model_profile,
                                std::vector<Floats>& output_values) const
{
  //can be input
  unsigned int nr=algebra::get_rounded(max_distance/pr_resolution) + 1;
  output_values.clear();
  unsigned int profile_size = std::min(model_profile.size(),
                                       exp_profile_.size());
  Floats r_size(nr, 0.0);
  output_values.insert(output_values.begin(),
                       profile_size, r_size);
  for(unsigned int iq = 0; iq<profile_size; iq++) {
    Float q = model_profile.get_q(iq);
    for (unsigned int ir=0; ir<nr; ir++) {
      Float r = pr_resolution * ir;
      Float qr = q * r;
      if(fabs(qr) < 1.0e-16) {
        output_values[iq][ir] = 0;
      } else {
        output_values[iq][ir] = (boost::math::sinc_pi(qr) - cos(qr)) /square(r);
      }
    }
  }
}
Exemplo n.º 4
0
Handle<Value> HoneydConfigBinding::GetPortSet(const Arguments& args)
{
	HandleScope scope;
	HoneydConfigBinding* obj = ObjectWrap::Unwrap<HoneydConfigBinding>(args.This());

	if(args.Length() != 2)
	{
		return ThrowException(Exception::TypeError(String::New("Must be invoked with 2 parameters")));
	}

	std::string profileName = cvv8::CastFromJS<string>(args[0]);
	int portSetIndex = cvv8::CastFromJS<int>(args[1]);

	Profile *profile = obj->m_conf->GetProfile(profileName);
	if(profile == NULL)
	{
		return scope.Close( Null() );
	}
	PortSet *portSet = profile->GetPortSet(portSetIndex);
	if(portSet == NULL)
	{
		return scope.Close( Null() );
	}

	return scope.Close( HoneydNodeJs::WrapPortSet( portSet ));
}
Exemplo n.º 5
0
void MFolderFromProfile::DontTryToCreate()
{
   if ( m_profile->HasEntry(MP_FOLDER_TRY_CREATE) )
   {
      m_profile->DeleteEntry(MP_FOLDER_TRY_CREATE);
   }
}
Exemplo n.º 6
0
void Profile::store(profile_ptr p, ostream& os) { 
    
    // get profile ptr
    Profile *istore = p.get();
    
    if (!p) {
        cerr << "Can't store empty profile pointer" << endl;
        return;
    }
    
    
    // update stores
    istore->update_stores();
    
    // clear loaded instances
    istore->unload_instances();
    
    try {
        boost::archive::text_oarchive oa(os);
        oa << istore;
        
    } catch (exception& e) {
        cerr << e.what() << endl;
    }
}
Exemplo n.º 7
0
void Pulsar::RemoveBaseline::Each::transform (Archive* archive)
{
  const unsigned nsub = archive->get_nsubint();
  const unsigned nchan = archive->get_nchan();
  const unsigned npol = archive->get_npol();

  bool pscrunch = (archive->get_state() == Signal::Coherence ||
		   archive->get_state() == Signal::PPQQ);

  for (unsigned isub=0; isub < nsub; isub++)
  {
    Integration* subint = archive->get_Integration (isub);
    for (unsigned ichan=0; ichan < nchan; ichan++)
    {
      Reference::To<Profile> profile = subint->get_Profile (0,ichan);
      if (pscrunch)
      {
	profile = profile->clone();
	profile->sum (subint->get_Profile (1,ichan));
      }

      Reference::To<PhaseWeight> baseline = profile->baseline();

      for (unsigned ipol=0; ipol < npol; ipol++)
      {
	Profile* p = subint->get_Profile(ipol, ichan);
	baseline->set_Profile (p);
	p->offset (-baseline->get_mean().val);
      }
    }
  }
};
Exemplo n.º 8
0
Profile *Profiles::processProfile(Profile *parent, pugi::xml_node config)
{
	std::string name = config.attribute("name").value();

	if (name.empty()) {
		throw std::runtime_error("Missing profile name");
	}
	
	/* Create new profile */
	Profile *profile = new Profile(name);
	profile->setParent(parent);
	profile->setNode(config);

	pugi::xpath_node_set profiles = config.select_nodes("profile");
	pugi::xpath_node_set channels = config.select_nodes("channel");

	for (auto& node: channels) {
		Channel *channel = processChannel(profile, node.node());
		profile->addChannel(channel, true);
	}

	for (auto& node: profiles) {
		Profile *child = processProfile(profile, node.node());
		profile->addProfile(child, true);
	}

	return profile;
}
Exemplo n.º 9
0
 void
 setProfile(const Profile& profile)
 {
   m_name = profile.get("name");
   m_institution = profile.get("institution");
   m_profile = profile;
 }
Exemplo n.º 10
0
void TargetView::repopulateList()
{
	// Prevent ugly repaints
	setUpdatesEnabled(false);

	// Clear existing list
	for(int i = 0; i < m_panes.count(); i++)
		delete m_panes.at(i);
	m_panes.clear();

	// Repopulate list
	Profile *profile = App->getProfile();
	TargetList targets = profile->getTargets();
	for(int i = 0; i < targets.count(); i++) {
		Target *target = targets.at(i);
		TargetPane *pane = new TargetPane(target, this);
		target->setupTargetPane(pane);
		m_panes.append(pane);
		m_layout.addWidget(pane);
		connect(pane, &TargetPane::rightClicked,
			this, &TargetView::targetPaneRightClicked,
			Qt::UniqueConnection);
	}

	// HACK: This must be delayed in order to actually do anything
	QTimer::singleShot(10, this, SLOT(enableUpdatesTimeout()));
}
Exemplo n.º 11
0
void Mesh::getPointBasic(std::vector<qglviewer::Vec*>* points)
{
    FloorVertex* floorVertexTmp = floorPlan;

    float normalX(0.0f);
    float normalY(0.0f);

    for(unsigned int i(0); i < floorPlanSize; ++i) {

        Profile* profile = floorVertexTmp->getProfile();
        if (profile != 0) {
           Vertex* pVertex = profile->getProfileVertex();
            while(pVertex != 0)
            {
                float w = pVertex->getX();
                float z = pVertex->getY();

                //float x = floorVertexTmp->getX()* (1.0f - w) + centerX * w;
                //float y = floorVertexTmp->getY()* (1.0f - w) + centerY * w;

                floorVertexTmp->getNormal(normalX, normalY);
                float x = floorVertexTmp->getX() + (-normalX) * w;
                float y = floorVertexTmp->getY() + (-normalY) * w;

                points->push_back(new qglviewer::Vec(x, y, z));
                pVertex = pVertex->getNeighbor2();
            }
        }
        floorVertexTmp = (FloorVertex*)floorVertexTmp->getNeighbor2();
    }
}
void ProfileManager::store_active() {
    Profile *p = active_profile.get();
    
    // Store only if active
    if (p)
        store_profile(p->profilename(), active_profile);    
}
Exemplo n.º 13
0
void ProfileDB::dumpProfilesXML(vector<Profile*> profiles,
        map<string, Profile*> profileMappings, string profileName) {
	ostringstream output;
	XMLWriter writer = XMLWriter(&output);
	writer.start();
	writer.startTag("db");
	writer.setAttr("version", "1.0");
	writer.setAttr("id", "main");

	string line;

	if (profiles.size() > 0) {
		for (size_t i = 0; i < profiles.size(); i++) {
			Profile* profile = profiles.at(i);
			if (profile) {
				profile->toXML(writer, fIncludeCapabilities);
			}
		}
		if (fOutputMappings) {
			dumpProfileMappings(&writer, profileMappings);
		}
	} else {
		writer.startTag("error");
		writer.text(string("Could find no matching profile for ") + profileName);
		writer.endTag();
	}

	writer.endTag();

	printf("%s", output.str().c_str());
}
Exemplo n.º 14
0
void ProfileDB::listCapabilities(string statePattern) {
	vector<Profile*> profiles;
	set<string> aggregateCapabilities;
	getProfiles("*", profiles);
	for (size_t i = 0; i < profiles.size(); i++) {
		Profile* profile = profiles.at(i);
		set<string> capabilities = profile->getCapabilities();
		for (set<string>::iterator capabilityIt = capabilities.begin(); capabilityIt
		        != capabilities.end(); capabilityIt++) {
			Capability capability = profile->getCapability(*capabilityIt);
			if (capability.matchCapability(statePattern)) {
				aggregateCapabilities.insert(*capabilityIt);
			}
		}
	}

	ostringstream output;
	XMLWriter writer = XMLWriter(&output);
	writer.start();
	writer.startTag("db");
	writer.setAttr("version", "1.0");
	writer.setAttr("id", "main");
	for (set<string>::iterator capabilityIt = aggregateCapabilities.begin(); capabilityIt
	        != aggregateCapabilities.end(); capabilityIt++) {
		writer.startTag(ELEMENT_CAPABILITY);
		writer.setAttr(ATTR_NAME, *capabilityIt);
		writer.endTag();
	}
	writer.endTag();
	writer.end();
	writer.dump();
}
Exemplo n.º 15
0
void DashboardGUI::on_latestMultimediaButton_clicked()
{
    // clear the previous list
    ui->latestInfoListWidget->clear();

    // pull data from the database and display in a list
    Profile *currentProfile = accountController->getUser()->getProfile();
    Scrapbook *myScrapbook = currentProfile->getScrapbook();
    std::vector<Multimedia*> allMulti = myScrapbook->getAllMedia();
    for(int i = 0; i < 5; i++){
        if(i == allMulti.size()){
            return;
        }
        Multimedia *media = allMulti.at(i);
        QString title = media->getTitle();
        QString description = media->getDescription();
        QString content = media->getContent();
        QString newLabel = "PHOTO \n" +
                title + "\n" +
                "@" + media->getAuthorUsername() + "\n" +
                description + "\n";
        QListWidgetItem *newMedia = new QListWidgetItem(QIcon(content), newLabel, ui->latestInfoListWidget);
        ui->latestInfoListWidget->addItem(newMedia);
        ui->latestInfoListWidget->setIconSize(QSize(125,125));
    }

}
RString ClearMachineStats()
{
	Profile* pProfile = PROFILEMAN->GetMachineProfile();
	pProfile->ClearStats();
	PROFILEMAN->SaveMachineProfile();
	return MACHINE_STATS_CLEARED.GetValue();
}
Exemplo n.º 17
0
/*! Upon completion, the flux of the archive will be normalized with
  respect to the flux of the calibrator, such that a FluxCalibrator
  simply scales the archive by the calibrator flux. */
void Pulsar::PolnCalibrator::calibrate (Archive* arch) try
{
  if (verbose > 2)
    cerr << "Pulsar::PolnCalibrator::calibrate" << endl;

  calibration_setup (arch);

  if (arch->get_npol() == 4)
  {
    BackendCorrection correct_backend;
    correct_backend (arch);

    if (verbose > 2)
      cerr << "Pulsar::PolnCalibrator::calibrate Archive::transform" <<endl;

    arch->transform (response);
    arch->set_poln_calibrated (true);

    if (receiver)
    {
      Receiver* rcvr = arch->get<Receiver>();
      if (!rcvr)
	throw Error (InvalidState, "Pulsar::PolnCalibrator::calibrate",
		     "Archive has no Receiver Extension");
      
      rcvr->set_basis_corrected (true);
    }
  }
  else if (arch->get_npol() == 1)
  {
    if (Archive::verbose)
      cerr << "Pulsar::PolnCalibrator::calibrate WARNING"
	" calibrating only absolute gain" << endl;

    unsigned nsub = arch->get_nsubint ();
    unsigned nchan = arch->get_nchan ();

    for (unsigned isub=0; isub < nsub; isub++)
    {
      Integration* subint = arch->get_Integration (isub);
      for (unsigned ichan=0; ichan < nchan; ichan++)
      {
	double gain = abs(det( response[ichan] ));
	Profile* profile = subint->get_Profile (0, ichan);

	profile -> scale (gain);
	profile -> set_weight ( profile->get_weight() / gain );
      }
    }
  }
  else
    throw Error (InvalidParam, "Pulsar::PolnCalibrator::calibrate",
		 "Archive::npol == %d not yet implemented", arch->get_npol());

  arch->set_scale (Signal::ReferenceFluxDensity);
}
catch (Error& error)
{
  throw error += "Pulsar::PolnCalibrator::calibrate";
}
Exemplo n.º 18
0
void MainPage::showTransitionMenu(uint transitionId, QWidget *btn)
{
	// Get transition information
	PrflTransition transition;
	uint durationMsec;
	Profile *profile = App->getProfile();
	profile->getTransition(transitionId, transition, durationMsec);

	// Update menu contents
	m_transitionMenuId = transitionId;
	m_transitionDurAction->setText(tr("Current duration: %L1 msec")
		.arg(durationMsec));
	m_transitionInstantAction->setChecked(
		transition == PrflInstantTransition);
	m_transitionFadeAction->setChecked(
		transition == PrflFadeTransition);
	m_transitionFadeBlackAction->setChecked(
		transition == PrflFadeBlackTransition);
	m_transitionFadeWhiteAction->setChecked(
		transition == PrflFadeWhiteTransition);

	// Popup above the button
	QPoint pos = btn->mapToGlobal(
		QPoint(0, -m_transitionMenu.sizeHint().height()));
	m_transitionMenu.popup(pos);
}
Exemplo n.º 19
0
void TableTicker::Tick(TickSample* sample)
{
  // Marker(s) come before the sample
  int i = 0;
  const char *marker = mStack->getMarker(i++);
  for (int i = 0; marker != NULL; i++) {
    mProfile.addTag(ProfileEntry('m', marker));
    marker = mStack->getMarker(i++);
  }
  mStack->mQueueClearMarker = true;

  // Sample
  // 's' tag denotes the start of a sample block
  // followed by 0 or more 'c' tags.
  for (int i = 0; i < mStack->mStackPointer; i++) {
    if (i == 0) {
      Address pc = 0;
      if (sample) {
        pc = sample->pc;
      }
      mProfile.addTag(ProfileEntry('s', mStack->mStack[i], pc));
    } else {
      mProfile.addTag(ProfileEntry('c', mStack->mStack[i]));
    }
  }

  if (!sLastTracerEvent.IsNull()) {
    TimeDuration delta = TimeStamp::Now() - sLastTracerEvent;
    mProfile.addTag(ProfileEntry('r', delta.ToMilliseconds()));
  }
}
Exemplo n.º 20
0
static void test_SegmentAt()
{
    double pnts[] = {
        0, 0,
        2, 1,
        2, 2,
        3, 3,
        7, 4,
        7, 5,
        8, 6,
       10, 7
    };

    Profile ls;
    fill(ls, pnts);
    JT_ASSERT(isProfile(ls));
    JT_EQUAL(ls.size(), 8);
    JT_EQUAL(firstSegmentAt(ls, -0.1), JEBMath::InvalidIndex);
    JT_EQUAL(lastSegmentAt(ls, -0.1), JEBMath::InvalidIndex);
    JT_EQUAL(firstSegmentAt(ls, 0), 0);
    JT_EQUAL(lastSegmentAt(ls, 0), 0);
    JT_EQUAL(firstSegmentAt(ls, 2), 0);
    JT_EQUAL(lastSegmentAt(ls, 2), 2);
    JT_EQUAL(firstSegmentAt(ls, 10), 6);
    JT_EQUAL(lastSegmentAt(ls, 10), 6);
    JT_EQUAL(firstSegmentAt(ls, 10.1), getSegmentCount(ls));
    JT_EQUAL(lastSegmentAt(ls, 10.1), getSegmentCount(ls));
}
Exemplo n.º 21
0
void ProfileTest::testMerge()
{
    QScopedPointer<Profile> p(loadFromXmlFile("testsync-ovi", Profile::TYPE_SYNC));
    QScopedPointer<Profile> p2(loadFromXmlFile("hcalendar", Profile::TYPE_STORAGE));

    QVERIFY(p != 0);
    QVERIFY(p2 != 0);

    Profile *sub = p->subProfile("hcalendar");
    QVERIFY(sub != 0);
    QVERIFY(sub->key("Local URI").isNull());
    QVERIFY(sub->allFields().isEmpty());
    p->merge(*p2);
    QCOMPARE(sub->key("Local URI"), QString("./Calendar"));
    QCOMPARE(sub->allFields().size(), 3);

    QCOMPARE(sub->d_ptr->iLocalKeys.size(), 4);
    QCOMPARE(sub->d_ptr->iMergedKeys.size(), 1);
    QCOMPARE(sub->d_ptr->iLocalFields.size(), 0);
    QCOMPARE(sub->d_ptr->iMergedFields.size(), 3);

    // Merge service to sync profile.
    QScopedPointer<Profile> p3(loadFromXmlFile("ovi-calendar", Profile::TYPE_SYNC));
    QVERIFY(p3 != 0);
    p3->merge(*p);
    QVERIFY(p3->subProfile("syncml", Profile::TYPE_CLIENT) != 0);
}
Exemplo n.º 22
0
int ConfigurationFile::AutoBind(const string& directory, const string& file)
{
  ConfigurationFile refConfigFile;

  int ret = refConfigFile.ReadConfigFile(directory, file);

  if(ret >= 0)
  {
    for(int i=0; i<MAX_CONTROLLERS; ++i)
    {
      Controller* refController = refConfigFile.GetController(i);
      Controller* modController = GetController(i);
      for(int j=0; j<MAX_PROFILES; ++j)
      {
        Profile* refConfig = refController->GetProfile(j);
        Profile* modConfig = modController->GetProfile(j);

        modConfig->SetTrigger(*refConfig->GetTrigger());
        modConfig->SetIntensityList(*refConfig->GetIntensityList());

        AutoBindMappers<ControlMapper>(refConfig->GetButtonMapperList(), modConfig->GetButtonMapperList());

        AutoBindMappers<ControlMapper>(refConfig->GetAxisMapperList(), modConfig->GetAxisMapperList());
      }
    }
  }

  return ret;
}
Exemplo n.º 23
0
void MainWindow::showPreferences()
{
  Session *sess =  _Sessions.at(tabs->currentIndex());
  Profile *prof = new Profile(sess->profileKey());
  Preferences *pd = new Preferences(prof);
  pd->setModal(true);
#ifdef QTOPIA_PHONE
  if (Qtopia::mousePreferred)
     QtopiaApplication::instance()->hideInputMethod();
#endif
  pd->exec();
  if (pd->result()==QDialog::Accepted) {
    // apply the changes and update the current session settings
    Profile *p = pd->profile();
    TerminalDisplay *display = sess->views()[0];
    display->setVTFont(QFont(p->fontName(), p->fontSize()));
const ColorScheme* colorScheme = ColorSchemeManager::instance()->findColorScheme(p->colorScheme());
    ColorEntry table[TABLE_COLORS];
    colorScheme->getColorTable(table, display->randomSeed());
    display->setColorTable(table);
    display->setOpacity(colorScheme->opacity());
    display->setKeyboardCursorShape((TerminalDisplay::KeyboardCursorShape)p->cursorShape());
    sess->setKeyBindings(p->keyboard());
    sess->setHistoryType(HistoryTypeBuffer(p->historyLines()));
    sess->setProfileKey(p->name());
    p->saveProfile(p->name());    
  }
#ifdef QTOPIA_PHONE
  if (Qtopia::mousePreferred) 
     QtopiaApplication::instance()->showInputMethod();
#endif
  delete pd;
}
Exemplo n.º 24
0
static void test_Bounds()
{
    double pnts[] = {
        0, 0,
        2, 1,
        2, 2,
        3, 3,
        7, 4,
        7, 5,
        8, 6,
       10, 7
    };

    Profile ls;
    fill(ls, pnts);
    JT_ASSERT(isProfile(ls));
    JT_EQUAL(ls.size(), 8);
    JT_EQUAL(lowerBound(ls, -1), 0);
    JT_EQUAL(upperBound(ls, -1), 0);
    JT_EQUAL(lowerBound(ls, 0), 0);
    JT_EQUAL(upperBound(ls, 0), 1);
    JT_EQUAL(lowerBound(ls, 2), 1);
    JT_EQUAL(upperBound(ls, 2), 3);
    JT_EQUAL(lowerBound(ls, 6.5), 4);
    JT_EQUAL(upperBound(ls, 6.5), 4);
    JT_EQUAL(lowerBound(ls, 7), 4);
    JT_EQUAL(upperBound(ls, 7), 6);
    JT_EQUAL(lowerBound(ls, 10), 7);
    JT_EQUAL(upperBound(ls, 10), 8);
}
Exemplo n.º 25
0
void ProfileDB::matchProfile(string profileName,
        vector<Capability> requiredCapabilities,
        vector<Capability> optionalCapabilities, vector<Profile*>& result,
        map<string, Profile*>& profileMappings) {
	Profile* profile = findProfile(profileName, set<string> ());
	vector<Profile*> genealogy;
	while (profile) {
		genealogy.push_back(profile);
		profile = profile->getParent();
	}

	map<string, Profile*> matchTokens;
	for (vector<Profile*>::reverse_iterator genealogyIt = genealogy.rbegin(); genealogyIt
	        != genealogy.rend(); genealogyIt++) {
		Profile* profileToMatch = *genealogyIt;
		string matchToken;
		bool isAbstract = profileToMatch->isAbstract();
		bool doMatch = !isAbstract || fOutputMappings;
		if (doMatch && internalMatchProfile(profileToMatch,
		        requiredCapabilities, optionalCapabilities, matchToken)) {
			Profile* alreadyMatched = matchTokens[matchToken];
			if (!isAbstract && alreadyMatched == NULL) {
				matchTokens[matchToken] = profileToMatch;
				result.push_back(profileToMatch);
			} else if (alreadyMatched) {
				profileMappings[profileToMatch->getProfileName()]
				        = matchTokens[matchToken];
			}
		}
	}
}
Exemplo n.º 26
0
bool ProfileDB::matchProfiles(string profilePattern,
        vector<Capability> requiredCapabilities,
        vector<Capability> optionalCapabilities) {
	File root = File(profilesdir());
	vector<string> profiles;
	innerListAllProfiles(root, string(), profilePattern, false, profiles);
	vector<Profile*> matchingProfiles;
	map<string, Profile*> profileMappings;

	for (vector<string>::iterator profileIt = profiles.begin(); profileIt
	        != profiles.end(); profileIt++) {
		matchProfile(*profileIt, requiredCapabilities, optionalCapabilities,
		        matchingProfiles, profileMappings);
	}

	set<string> profileNames; // TODO: Maybe we want VARIANTS as well!?
	vector<Profile*> prunedProfiles;
	for (vector<Profile*>::iterator matchingProfilesIt =
	        matchingProfiles.begin(); matchingProfilesIt
	        != matchingProfiles.end(); matchingProfilesIt++) {
		Profile* match = *matchingProfilesIt;
		// Make sure we only add a specific profile once.
		if (profileNames.find(match->getProfileName()) == profileNames.end()) {
			profileNames.insert(match->getProfileName());
			prunedProfiles.push_back(match);
		}
	}

	dumpProfiles(prunedProfiles, profileMappings, profilePattern);
	return profileNames.size() > 0;
}
Exemplo n.º 27
0
// Serializes the profiles to disk.
void ProfileManager::SaveCache()
{
    String path = GetProfilePath(true);
 
    Lock::Locker lockScope(&ProfileLock);

    // TODO: Since there is only a single device type now, a full tree overwrite
    // is sufficient but in the future a selective device branch replacement will
    // be necessary

    Ptr<JSON> root = *JSON::CreateObject();
    root->AddNumberItem("Oculus Profile Version", PROFILE_VERSION);
    root->AddStringItem("CurrentProfile", DefaultProfile);
    root->AddNumberItem("ProfileCount", (double) ProfileCache.GetSize());

    // Generate a JSON subtree for each profile
    for (unsigned int i=0; i<ProfileCache.GetSize(); i++)
    {
        Profile* profile = ProfileCache[i];

        JSON* json_profile = JSON::CreateObject();
        json_profile->Name = "Profile";
        json_profile->AddStringItem("Name", profile->Name);
        const char* gender;
        switch (profile->GetGender())
        {
            case Profile::Gender_Male:   gender = "Male"; break;
            case Profile::Gender_Female: gender = "Female"; break;
            default: gender = "Unspecified";
        }
        json_profile->AddStringItem("Gender", gender);
        json_profile->AddNumberItem("PlayerHeight", profile->PlayerHeight);
        json_profile->AddNumberItem("IPD", profile->IPD);

        if (profile->Type == Profile_RiftDK1)
        {
            RiftDK1Profile* riftdk1 = (RiftDK1Profile*)profile;
            JSON* json_riftdk1 = JSON::CreateObject();
            json_profile->AddItem("RiftDK1", json_riftdk1);

            const char* eyecup = "A";
            switch (riftdk1->EyeCups)
            {
                case RiftDK1Profile::EyeCup_A: eyecup = "A"; break;
                case RiftDK1Profile::EyeCup_B: eyecup = "B"; break;
                case RiftDK1Profile::EyeCup_C: eyecup = "C"; break;
            }
            json_riftdk1->AddStringItem("EyeCup", eyecup);
            json_riftdk1->AddNumberItem("LL", riftdk1->LL);
            json_riftdk1->AddNumberItem("LR", riftdk1->LR);
            json_riftdk1->AddNumberItem("RL", riftdk1->RL);
            json_riftdk1->AddNumberItem("RR", riftdk1->RR);
        }

        root->AddItem("Profile", json_profile);
    }

    root->Save(path);
}
Exemplo n.º 28
0
int main () {
	Profile myProfile;

	myProfile.setName("Sogo");
	myProfile.setPhoneNumber("010-123-4567");
	myProfile.printProfile();
	return 0;
}
static JSValueRef getUniqueIdCallback(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
{
    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileClass()))
        return JSValueMakeUndefined(ctx);

    Profile* profile = static_cast<Profile*>(JSObjectGetPrivate(thisObject));
    return JSValueMakeNumber(ctx, profile->uid());
}
static JSValueRef getTitleCallback(JSContextRef ctx, JSObjectRef thisObject, JSStringRef, JSValueRef*)
{
    if (!JSValueIsObjectOfClass(ctx, thisObject, ProfileClass()))
        return JSValueMakeUndefined(ctx);

    Profile* profile = static_cast<Profile*>(JSObjectGetPrivate(thisObject));
    return JSValueMakeString(ctx, OpaqueJSString::create(profile->title()).get());
}