本文整理匯總了C++中Any函數的典型用法代碼示例。如果您正苦於以下問題:C++ Any函數的具體用法?C++ Any怎麽用?C++ Any使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Any函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: switch
// 獲取屬性值
Any TriggerObject::getProperty(uint id)const
{
if(id > ID_NullObject_Begin && id < ID_NullObject_End)
return NullObject::getProperty(id);
switch(id)
{
case ID_Trigger: // 觸發器設置
{
return Any();
}
break;
case ID_TriggerCondition: // 滿足條件
{
return Any(getCondition());
}
break;
case ID_TriggerOnEnterEvent: // 進入事件
{
return Any(getOnEnterEvent());
}
break;
case ID_TriggerOnLeaveEvent: // 退出事件
{
return Any(getOnLeaveEvent());
}
break;
default:
return Any();
break;
}
}
示例2: PageData
//---------------------------------------------------------------------
WorkQueue::Response* Page::handleRequest(const WorkQueue::Request* req, const WorkQueue* srcQ)
{
// Background thread (maybe)
PageRequest preq = any_cast<PageRequest>(req->getData());
// only deal with own requests; we shouldn't ever get here though
if (preq.srcPage != this)
return 0;
PageResponse res;
res.pageData = OGRE_NEW PageData();
WorkQueue::Response* response = 0;
try
{
prepareImpl(res.pageData);
response = OGRE_NEW WorkQueue::Response(req, true, Any(res));
}
catch (Exception& e)
{
// oops
response = OGRE_NEW WorkQueue::Response(req, false, Any(res),
e.getFullDescription());
}
return response;
}
示例3: Any
//---------------------------------------------------------------------
WorkQueue::Response* TerrainPagedWorldSection::handleRequest(const WorkQueue::Request* req, const WorkQueue* srcQ)
{
if(mPagesInLoading.empty())
{
mHasRunningTasks = false;
req->abortRequest();
return OGRE_NEW WorkQueue::Response(req, true, Any());
}
unsigned long currentTime = Root::getSingletonPtr()->getTimer()->getMilliseconds();
if(currentTime < mNextLoadingTime)
{
// Wait until the next page is to be loaded -> we are in background thread here
OGRE_THREAD_SLEEP(mNextLoadingTime - currentTime);
}
PageID pageID = mPagesInLoading.front();
// call the TerrainDefiner from the background thread
long x, y;
// pageID is the same as a packed index
mTerrainGroup->unpackIndex(pageID, &x, &y);
if(!mTerrainDefiner)
mTerrainDefiner = OGRE_NEW TerrainDefiner();
mTerrainDefiner->define(mTerrainGroup, x, y);
// continue loading in main thread
return OGRE_NEW WorkQueue::Response(req, true, Any());
}
示例4: if
void Preferences::onChangeHedgeSelection(int) {
fl::Engine* engine = Model::Default()->engine();
if (ui->ckx_any->isChecked() and not engine->hasHedge(Any().name()))
engine->addHedge(new Any);
else if (not ui->ckx_any->isChecked() and engine->hasHedge(Any().name()))
delete engine->removeHedge(Any().name());
if (ui->ckx_extremely->isChecked() and not engine->hasHedge(Extremely().name()))
engine->addHedge(new Extremely);
else if (not ui->ckx_extremely->isChecked() and engine->hasHedge(Extremely().name()))
delete engine->removeHedge(Extremely().name());
if (ui->ckx_not->isChecked() and not engine->hasHedge(Not().name()))
engine->addHedge(new Not);
else if (not ui->ckx_not->isChecked() and engine->hasHedge(Not().name()))
delete engine->removeHedge(Not().name());
if (ui->ckx_seldom->isChecked() and not engine->hasHedge(Seldom().name()))
engine->addHedge(new Seldom);
else if (not ui->ckx_seldom->isChecked() and engine->hasHedge(Seldom().name()))
delete engine->removeHedge(Seldom().name());
if (ui->ckx_somewhat->isChecked() and not engine->hasHedge(Somewhat().name()))
engine->addHedge(new Somewhat);
else if (not ui->ckx_somewhat->isChecked() and engine->hasHedge(Somewhat().name()))
delete engine->removeHedge(Somewhat().name());
if (ui->ckx_very->isChecked() and not engine->hasHedge(Very().name()))
engine->addHedge(new Very);
else if (not ui->ckx_very->isChecked() and engine->hasHedge(Very().name()))
delete engine->removeHedge(Very().name());
Window::mainWindow()->fixDependencies();
}
示例5: Any
Any Converter<float>::convert(const Any& a)
{
if (typeid(int) == a.type())
return Any(helper<float, int>::convert(a));
else if (typeid(const char *) == a.type())
return Any(helper<float, const char *>::convert(a));
return any_cast<float>(a);
}
示例6: Any
Any Converter<float>::convert(const Any& a)
{
if (Type::from<int>() == a.type())
return Any(helper<float, int>::convert(a));
else if (Type::from<const char *>() == a.type())
return Any(helper<float, const char *>::convert(a));
return any_cast<float>(a);
}
示例7: switch
// 獲取屬性值
Any CameraObject::getProperty(uint id)const
{
if(id > ID_NullObject_Begin && id < ID_NullObject_End)
return NullObject::getProperty(id);
switch(id)
{
case ID_Camera: // 攝像機設置
{
return Any();
}
break;
case ID_PolygonMode: // 幾何渲染模式
{
return Any((long)m_camera->getPolygonMode());
}
break;
case ID_LodBias: // LOD偏移
{
return Any(m_camera->getLodBias());
}
break;
case ID_NearClipDistance: // 近裁麵
{
return Any(m_camera->getNearClipDistance());
}
break;
case ID_FarClipDistance: // 遠裁麵
{
return Any(m_camera->getFarClipDistance());
}
break;
case ID_FOVy: // FOVy角度
{
return Any(m_camera->getFOVy().valueDegrees());
}
break;
case ID_AspectRatio: // 窗口比率
{
return Any(m_camera->getAspectRatio());
}
break;
case ID_ProjectionType: // 投影方式
{
return Any((long)m_camera->getProjectionType());
}
break;
case ID_OrthoWindow: // 正交投影窗口大小
{
return Any(Vector2(m_camera->getOrthoWindowWidth() , m_camera->getOrthoWindowHeight()));
}
break;
default:
return Any();
break;
}
}
示例8: Any
Any ArticulatedModel::Instruction::Identifier::toAny() const {
if (isAll()) {
return Any(Any::ARRAY, "all");
} else if (isRoot()) {
return Any(Any::ARRAY, "root");
} else if (id.initialized()) {
return Any(int(id));
} else {
return Any(name);
}
}
示例9: convertToAny
Any convertToAny(NPP npp, const NPVariant* variant)
{
switch (variant->type)
{
case NPVariantType_Void:
case NPVariantType_Null:
return Any();
break;
case NPVariantType_Bool:
return NPVARIANT_TO_BOOLEAN(*variant);
break;
case NPVariantType_Int32:
return NPVARIANT_TO_INT32(*variant);
break;
case NPVariantType_Double:
return NPVARIANT_TO_DOUBLE(*variant);
break;
case NPVariantType_String:
return std::string(NPVARIANT_TO_STRING(*variant).utf8characters, NPVARIANT_TO_STRING(*variant).utf8length);
break;
case NPVariantType_Object:
{
NPObject* object = NPVARIANT_TO_OBJECT(*variant);
if (!object)
{
break;
}
if (StubObject::isStub(object))
{
StubObject* stub = static_cast<StubObject*>(object);
return stub->getObject();
}
PluginInstance* instance = static_cast<PluginInstance*>(npp->pdata);
if (instance)
{
ProxyControl* proxyControl = instance->getProxyControl();
if (proxyControl)
{
return proxyControl->createProxy(object);
}
}
break;
}
default:
break;
}
return Any();
}
示例10: Any
void CCPlayer::Open(const std::string& loadParams)
{
CCMessageCenter::GetInstance()->PostMessage(MESSAGE_OBJECT_ENUM_CLIENT,
MESSAGE_OBJECT_ENUM_PLAYER,
COMMAND_TYPE_ENUM_OPEN,
Any(loadParams));
}
示例11: find
//---------------------------------------------------------------------
void TerrainPagedWorldSection::loadPage(PageID pageID, bool forceSynchronous)
{
if (!mParent->getManager()->getPagingOperationsEnabled())
return;
PageMap::iterator i = mPages.find(pageID);
if (i == mPages.end())
{
std::list<PageID>::iterator it = find( mPagesInLoading.begin(), mPagesInLoading.end(), pageID);
if(it==mPagesInLoading.end())
{
mPagesInLoading.push_back(pageID);
mHasRunningTasks = true;
}
// no running tasks, start the new one
if(mPagesInLoading.size()==1)
{
Root::getSingleton().getWorkQueue()->addRequest(
mWorkQueueChannel, WORKQUEUE_LOAD_TERRAIN_PAGE_REQUEST,
Any(), 0, forceSynchronous);
}
}
PagedWorldSection::loadPage(pageID, forceSynchronous);
}
示例12: RTException
void StateRoom::accessRoom()
{
INetworkRelay *network = this->_world->getSharedObject<INetworkRelay>("NetworkRelay");
if (network) {
Remote *remote = NULL;
if (this->_textboxRoom->getString() != "")
this->_textboxRoom->setString("defaulte");
if (!(remote = network->getRemote(0)))
throw RTException("Invalid remote");
IBuffer *buffer = network->getTCPBuffer();
*buffer << static_cast<char>(INetworkRelay::CHANGE_ROOM_QUERY);
*buffer << this->_textboxRoom->getString();
remote->sendTCP(buffer);
Thread<INetworkRelay> *thread = new Thread<INetworkRelay>();
thread->start(network, &INetworkRelay::start, Any());
while (42) {
LockVector<IBuffer *> &recv_buffer = remote->getRecvBufferTCP();
auto guard = create_lock(recv_buffer);
for (auto it = recv_buffer.begin(); it != recv_buffer.end();)
{
if (this->parsePacket(recv_buffer, it))
return ;
}
}
} else {
throw RTException("Invalid network");
}
}
示例13: ss
Signature TextureProxy::MakeSignature(const Proxy<res::Image> &image, vid::opengl::TextureFormat format, vid::opengl::TextureFlags flags, const math::Vector<2, bool> &clamp)
{
std::ostringstream ss(image.GetSignature());
switch (format)
{
case vid::opengl::defaultTextureFormat:
break;
case vid::opengl::alphaTextureFormat:
ss << ":alpha";
break;
case vid::opengl::luminanceTextureFormat:
ss << ":luminance";
break;
default:
assert(!"invalid texture format");
}
if (flags & vid::opengl::filterTextureFlag) ss << ":filter";
if (flags & vid::opengl::mipmapTextureFlag) ss << ":mipmap";
if (Any(clamp))
{
ss << ":clamp";
if (!clamp.x) ss << ".y";
else if (!clamp.y) ss << ".x";
}
return Signature("OpenGL texture", ss.str());
}
示例14: Room
RoomServer::RoomServer(ServerRelay *server, const std::string &nameRoomServer)
: Room(), _serverRelay(server), _nameRoomServer(nameRoomServer)
{
std::cout << "Creating new room: " << this->_nameRoomServer << std::endl;
this->_runWorldServer = new RunWorldServer(server, nameRoomServer);
this->_thread.start(this->_runWorldServer, &RunWorldServer::run, Any());
}
示例15: inputStream
void Instance::LoadModList()
{
if (GetModListFile().FileExists())
{
wxFileInputStream inputStream(GetModListFile().GetFullPath());
wxStringList modListFile = ReadAllLines(inputStream);
for (wxStringList::iterator iter = modListFile.begin(); iter != modListFile.end(); iter++)
{
// Normalize the path to the instMods dir.
wxFileName modFile(*iter);
modFile.Normalize(wxPATH_NORM_ALL, GetInstModsDir().GetFullPath());
modFile.MakeRelativeTo();
if (!Any(modList.begin(), modList.end(), [&modFile] (Mod mod) -> bool
{ return mod.GetFileName().SameAs(wxFileName(modFile)); }))
{
//SetNeedsRebuild();
modList.push_back(Mod(modFile));
}
}
}
for (size_t i = 0; i < modList.size(); i++)
{
if (!modList[i].GetFileName().FileExists())
{
SetNeedsRebuild();
modList.erase(modList.begin() + i);
i--;
}
}
LoadModListFromDir(GetInstModsDir());
}