当前位置: 首页>>代码示例>>C++>>正文


C++ Holder类代码示例

本文整理汇总了C++中Holder的典型用法代码示例。如果您正苦于以下问题:C++ Holder类的具体用法?C++ Holder怎么用?C++ Holder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Holder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

JNIEXPORT void JNICALL Java_com_netbirdtech_libcurl_Curl_curlEasyCleanupNative
  (JNIEnv * env, jobject obj, jlong handle) {
    if (handle != 0) {
        Holder* holder = (Holder*) handle;
        curl_easy_cleanup(holder->getCurl());
        delete holder;
        holder = 0;
    }
}
开发者ID:mahongquan,项目名称:java-jni,代码行数:9,代码来源:Main.cpp

示例2: serialize

    void JsonSerializer::serialize(Holder h)
    {
        if (!h.isValid())
            return;

        auto desc = h.descriptor();

        switch (desc->getKind())
        {
        case TypeDescriptor::kPrimitive:
            {
                auto primDesc =
                    static_cast< const PrimitiveTypeDescriptor * >(desc);
                os << '"' << primDesc->getString(h) << '"';
            }
            break;
        case TypeDescriptor::kClass:
            {
                auto classDesc =
                    static_cast< const ClassDescriptor * >(desc);
                ModelClass * obj = classDesc->get(h);
                serialize(obj);
            }
            break;
        case TypeDescriptor::kList:
            {
                ++level;
                os << '[';

                auto vecDesc =
                    static_cast< const ListTypeDescriptor * >(desc);
                const auto values = vecDesc->getValue(h);

                for (size_t i = 0; i < values.size(); i++)
                {
                    os << std::endl << indent();

                    serialize(values[i]);

                    if (i + 1 < values.size())
                        os << ',';
                }

                --level;
                os << std::endl << indent();
                os << ']';

            }
            break;
        default:
            os << "\"Unsupported type\"";
            break;
        }
    }
开发者ID:bruce2008github,项目名称:refcpp,代码行数:54,代码来源:json.hpp

示例3: DeleteSaveGame

int SaveGameIterator::CreateSaveGame(Holder<SaveGame> save, const char *slotname)
{
	if (!slotname) {
		return -1;
	}

	if (int cansave = CanSave())
		return cansave;

	GameControl *gc = core->GetGameControl();
	int index;

	if (save) {
		index = save->GetSaveID();

		DeleteSaveGame(save);
		save.release();
	} else {
		//leave space for autosaves
		//probably the hardcoded slot names should be read by this object
		//in that case 7 == size of hardcoded slot names array (savegame.2da)
		index = 7;
		for (size_t i = 0; i < save_slots.size(); ++i) {
			Holder<SaveGame> save = save_slots[i];
			if (save->GetSaveID() >= index) {
				index = save->GetSaveID() + 1;
			}
		}
	}

	char Path[_MAX_PATH];
	if (!CreateSavePath(Path, index, slotname)) {
		displaymsg->DisplayConstantString(STR_CANTSAVE, DMC_BG2XPGREEN);
		if (gc) {
			gc->SetDisplayText(STR_CANTSAVE, 30);
		}
		return -1;
	}

	if (!DoSaveGame(Path)) {
		displaymsg->DisplayConstantString(STR_CANTSAVE, DMC_BG2XPGREEN);
		if (gc) {
			gc->SetDisplayText(STR_CANTSAVE, 30);
		}
		return -1;
	}

	// Save succesful
	displaymsg->DisplayConstantString(STR_SAVESUCCEED, DMC_BG2XPGREEN);
	if (gc) {
		gc->SetDisplayText(STR_SAVESUCCEED, 30);
	}
	return 0;
}
开发者ID:tomprince,项目名称:gemrb,代码行数:54,代码来源:SaveGameIterator.cpp

示例4: res

Holder StatusManager::status(const QString& name)
{
    Holder res (statusRef(name));

    // Devuelve siempre una copìa
    if (res.is_valid())
    {
        res = Holder(res.clone());
    }

    return res;
}
开发者ID:asenac,项目名称:gsim,代码行数:12,代码来源:StatusManager.cpp

示例5: older

void StatusManager::setStatus(const QString& name, Holder holder)
{
    Holder older(status(name));

    if (holder.is_valid() && older.is_valid())
    {
        using namespace ::gsim::core::utils;

        Holder newer(older.clone());

        // Hace una copia 'reflectiva' ya que holder puede no ser
        // del mismo tipo que el tipo del estado.
        reflective_copy(holder, newer);

        // Region protegida reducida al mínimo
        if (applyStatus(name, older, newer))
        {
            unique_lock lock(m_data->messageMutex);

            m_data->status[name] = newer;

            // Ha de estar dentro de la región protegida para la
            // notificación en orden
            emit statusChanged(name, newer); 
            emit statusChanged(name, older, newer); 
        }
    }
}
开发者ID:asenac,项目名称:gsim,代码行数:28,代码来源:StatusManager.cpp

示例6: tab

int SaveGameIterator::CreateSaveGame(int index, bool mqs)
{
	AutoTable tab("savegame");
	const char *slotname = NULL;
	if (tab) {
		slotname = tab->QueryField(index);
	}

	if (mqs) {
		assert(index==1);
		PruneQuickSave(slotname);
	}

	//if index is not an existing savegame, we create a unique slotname
	for (size_t i = 0; i < save_slots.size(); ++i) {
		Holder<SaveGame> save = save_slots[i];
		if (save->GetSaveID() == index) {
			DeleteSaveGame(save);
			break;
		}
	}
	char Path[_MAX_PATH];
	CreateSavePath(Path, index, slotname);

	if (!DoSaveGame(Path)) {
		return -1;
	}

	// Save succesful / Quick-save succesful
	if (index == 1) {
		displaymsg->DisplayConstantString(STR_QSAVESUCCEED, 0xbcefbc);
		if (core->GetGameControl()) {
			core->GetGameControl()->SetDisplayText(STR_QSAVESUCCEED, 30);
		}
	} else {
		displaymsg->DisplayConstantString(STR_SAVESUCCEED, 0xbcefbc);
		if (core->GetGameControl()) {
			core->GetGameControl()->SetDisplayText(STR_SAVESUCCEED, 30);
		}
	}
	return 0;
}
开发者ID:NickDaly,项目名称:GemRB-MultipleConfigs,代码行数:42,代码来源:SaveGameIterator.cpp

示例7: main

int main() {
  Holder h;
  Holder::Pointer hp, hp2;
  int i;

  h.initialize();
  hp.initialize(&h);
  hp2.initialize(&h);
  for(i = 0; i < sz; i++) {
    hp.set(i);
    hp.next();
  }
  hp.top();
  hp2.end();
  for(i = 0; i < sz; i++) {
    cout << "hp = " << hp.read()
         << ", hp2 = " << hp2.read() << endl;
    hp.next();
    hp2.previous();
  }
} ///:~
开发者ID:forzenheart,项目名称:Thinking-In-C-resource,代码行数:21,代码来源:NestFriend.cpp

示例8: trainInner

// virtual
void GWag::trainInner(GMatrix& features, GMatrix& labels)
{
	GNeuralNet* pTemp = NULL;
	Holder<GNeuralNet> hTemp;
	size_t weights = 0;
	double* pWeightBuf = NULL;
	double* pWeightBuf2 = NULL;
	ArrayHolder<double> hWeightBuf;
	for(size_t i = 0; i < m_models; i++)
	{
		m_pNN->train(features, labels);
		if(pTemp)
		{
			// Average m_pNN with pTemp
			if(!m_noAlign)
				m_pNN->align(*pTemp);
			pTemp->weights(pWeightBuf);
			m_pNN->weights(pWeightBuf2);
			GVec::multiply(pWeightBuf, double(i) / (i + 1), weights);
			GVec::addScaled(pWeightBuf, 1.0 / (i + 1), pWeightBuf2, weights);
			pTemp->setWeights(pWeightBuf);
		}
		else
		{
			// Copy the m_pNN
			GDom doc;
			GDomNode* pNode = m_pNN->serialize(&doc);
			GLearnerLoader ll(m_rand);
			pTemp = new GNeuralNet(pNode, ll);
			hTemp.reset(pTemp);
			weights = pTemp->countWeights();
			pWeightBuf = new double[2 * weights];
			hWeightBuf.reset(pWeightBuf);
			pWeightBuf2 = pWeightBuf + weights;
		}
	}
	pTemp->weights(pWeightBuf);
	m_pNN->setWeights(pWeightBuf);
}
开发者ID:kslazarev,项目名称:waffles,代码行数:40,代码来源:GEnsemble.cpp

示例9: curl_easy_setopt

JNIEXPORT jint JNICALL Java_com_netbirdtech_libcurl_Curl_curlEasySetoptObjectPointArrayNative
  (JNIEnv *env, jobject obj, jlong handle, jint opt, jobjectArray values) {
    Holder* holder = (Holder*) handle;
    CURL * curl = holder->getCurl();

    const char *str;
    struct curl_slist *slist = 0;
    int nargs = env->GetArrayLength(values);
    for (int i = 0; i < nargs; i++) {
        jstring value = (jstring) env->GetObjectArrayElement(values, i);
        str = env->GetStringUTFChars(value, 0);
        if (str == 0) {
            return 0;
        }
        //LOGV("append slist");
        slist = curl_slist_append(slist, str);
        env->ReleaseStringUTFChars(value, str);
    }
    holder->addCurlSlist(slist);
    //LOGD("set slist option=%d, size=%d", opt, nargs);
    return curl_easy_setopt(curl, (CURLoption) opt, slist);
}
开发者ID:mahongquan,项目名称:java-jni,代码行数:22,代码来源:Main.cpp

示例10: addExactPoints

    void GeoSearch::addExactPoints(const GeoPoint& pt, Holder& points, int& before, int& after,
            bool force){
        before = 0;
        after = 0;

        if(pt.isExact()){
            if(force) points.insert(pt);
            return;
        }

        vector<BSONObj> locs;
        getPointsFor(pt.key(), pt.obj(), locs, _uniqueDocs);

        GeoPoint nearestPt(pt, -1, true);

        for(vector<BSONObj>::iterator i = locs.begin(); i != locs.end(); i++){
            Point loc(*i);
            double d;
            if(! exactDocCheck(loc, d)) continue;

            if(_uniqueDocs && (nearestPt.distance() < 0 || d < nearestPt.distance())){
                nearestPt._distance = d;
                nearestPt._pt = *i;
                continue;
            } else if(! _uniqueDocs){
                GeoPoint exactPt(pt, d, true);
                exactPt._pt = *i;
                points.insert(exactPt);
                exactPt < pt ? before++ : after++;
            }
        }

        if(_uniqueDocs && nearestPt.distance() >= 0){
            points.insert(nearestPt);
            if(nearestPt < pt) before++;
            else after++;
        }
    }
开发者ID:ChrisBg,项目名称:mongo,代码行数:38,代码来源:2dnear.cpp

示例11: processMessage

void MessageProcessorManager::processMessage(
        Connection_ptr con,
        Message_ptr msg)
{
    // Obtiene el contenido y el descriptor del mensaje
    Holder holder = msg->holder();
    TypeDescriptor_ptr messageDescriptor = 
        holder.get_type_descriptor();

    // creates the key
    map_t::iterator it = m_processors.find(
            std::make_pair(con.get(), messageDescriptor));

    if (it != m_processors.end() && 
            !it->second.empty())
    {
        // Iterates over its associated processors
        processors_t::const_iterator pit = it->second.begin(); 

        for (; pit != it->second.end(); ++pit) 
        {
            const MessageProcessor_ptr processor = *pit;
            const ReflectivePath_t& path = processor->path();

            // Results
            TypeDescriptor_ptr descriptor = NULL;
            Holder value;

            bool res = followPath(messageDescriptor, holder, path, 
                    // Results
                    descriptor, value);

            if (res)
                processor->process(msg, value);
        }
    }
}
开发者ID:asenac,项目名称:gsim,代码行数:37,代码来源:MessageProcessorManager.cpp

示例12: CreateRenderer

 Renderer::Ptr CreateRenderer(const Holder& holder, Parameters::Accessor::Ptr params, Sound::Receiver::Ptr target)
 {
   if (const Sound::FadeGainer::Ptr fade = CreateFadeGainer(params, target))
   {
     if (FadeoutFilter::Ptr fadeout = CreateFadeOutFilter(params, holder.GetModuleInformation(), fade))
     {
       const Devices::AYM::Chip::Ptr chip = CreateChip(params, fadeout);
       const Renderer::Ptr result = holder.CreateRenderer(params, chip);
       fadeout->SetTrackState(result->GetTrackState());
       return result;
     }
     else
     {
       //only fade in
       const Devices::AYM::Chip::Ptr chip = CreateChip(params, fade);
       return holder.CreateRenderer(params, chip);
     }
   }
   else
   {
     const Devices::AYM::Chip::Ptr chip = CreateChip(params, target);
     return holder.CreateRenderer(params, chip);
   }
 }
开发者ID:fgroen,项目名称:zxtune,代码行数:24,代码来源:aym_base.cpp

示例13: aggregateRows

void aggregateRows(GArgReader& args)
{
	size_t r = args.pop_uint();
	vector<string> files;
	GFile::fileList(files);
	GMatrix* pResults = NULL;
	Holder<GMatrix> hResults;
	for(vector<string>::iterator it = files.begin(); it != files.end(); it++)
	{
		PathData pd;
		GFile::parsePath(it->c_str(), &pd);
		if(strcmp(it->c_str() + pd.extStart, ".arff") != 0)
			continue;
		GMatrix* pData = loadData(it->c_str());
		Holder<GMatrix> hData(pData);
		if(!pResults)
		{
			pResults = new GMatrix(pData->relation());
			hResults.reset(pResults);
		}
		pResults->takeRow(pData->releaseRow(r));
	}
	pResults->print(cout);
}
开发者ID:litaoshao,项目名称:waffles,代码行数:24,代码来源:main.cpp

示例14: GetIniFile

void IniSpawn::InitSpawn(const ieResRef DefaultArea)
{
	const char *s;

	Holder<DataFileMgr> inifile = GetIniFile(DefaultArea);
	if (!inifile) {
		strnuprcpy(NamelessSpawnArea, DefaultArea, 8);
		return;
	}

	s = inifile->GetKeyAsString("nameless","destare",DefaultArea);
	strnuprcpy(NamelessSpawnArea, s, 8);
	s = inifile->GetKeyAsString("nameless","point","[0.0]");
	int x,y;
	if (sscanf(s,"[%d.%d]", &x, &y)!=2) {
		x=0;
		y=0;
	}
	NamelessSpawnPoint.x=x;
	NamelessSpawnPoint.y=y;

	s = inifile->GetKeyAsString("nameless", "partyarea", DefaultArea);
	strnuprcpy(PartySpawnArea, s, 8);
	s = inifile->GetKeyAsString("nameless", "partypoint", "[0.0]");
	if (sscanf(s,"[%d.%d]", &x, &y) != 2) {
		x = NamelessSpawnPoint.x;
		y = NamelessSpawnPoint.y;
	}
	PartySpawnPoint.x = x;
	PartySpawnPoint.y = y;

	//35 - already standing
	//36 - getting up
	NamelessState = inifile->GetKeyAsInt("nameless","state",36);

	namelessvarcount = inifile->GetKeysCount("namelessvar");
	if (namelessvarcount) {
		NamelessVar = new VariableSpec[namelessvarcount];
		for (y=0;y<namelessvarcount;y++) {
			const char* Key = inifile->GetKeyNameByIndex("namelessvar",y);
			strnlwrcpy(NamelessVar[y].Name, Key, 32);
			NamelessVar[y].Value = inifile->GetKeyAsInt("namelessvar",Key,0);
		}
	}

	localscount = inifile->GetKeysCount("locals");
	if (localscount) {
		Locals = new VariableSpec[localscount];
		for (y=0;y<localscount;y++) {
			const char* Key = inifile->GetKeyNameByIndex("locals",y);
			strnlwrcpy(Locals[y].Name, Key, 32);
			Locals[y].Value = inifile->GetKeyAsInt("locals",Key,0);
		}
	}

	s = inifile->GetKeyAsString("spawn_main","enter",NULL);
	if (s) {
		ReadSpawnEntry(inifile.get(), s, enterspawn);
	}

	s = inifile->GetKeyAsString("spawn_main","exit",NULL);
	if (s) {
		ReadSpawnEntry(inifile.get(), s, exitspawn);
	}

	s = inifile->GetKeyAsString("spawn_main","events",NULL);
	if (s) {
		eventcount = CountElements(s,',');
		eventspawns = new SpawnEntry[eventcount];
		ieVariable *events = new ieVariable[eventcount];
		GetElements(s, events, eventcount);
		int ec = eventcount;
		while(ec--) {
			ReadSpawnEntry(inifile.get(), events[ec], eventspawns[ec]);
		}
		delete[] events;
	}
	//maybe not correct
	InitialSpawn();
}
开发者ID:ChunHungLiu,项目名称:gemrb,代码行数:80,代码来源:IniSpawn.cpp

示例15:

 T& operator*() { Object* o = v[i]; Holder* h = static_cast<Holder*>(o); return h->value(); }
开发者ID:Nobody-7,项目名称:tcpppl_answers,代码行数:1,代码来源:ex13.cpp


注:本文中的Holder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。