本文整理汇总了C++中weak_ptr::expired方法的典型用法代码示例。如果您正苦于以下问题:C++ weak_ptr::expired方法的具体用法?C++ weak_ptr::expired怎么用?C++ weak_ptr::expired使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weak_ptr
的用法示例。
在下文中一共展示了weak_ptr::expired方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeStrongPtr
shared_ptr<Type> MakeStrongPtr(weak_ptr<Type> pWeakPtr)
{
if (!pWeakPtr.expired())
return shared_ptr<Type>(pWeakPtr);
else
return shared_ptr<Type>();
}
示例2: Init
void PropertyList::Init(weak_ptr<Leaf> leaf, wxListCtrl* ctrList)
{
mLeaf.reset();
mCtrList = 0;
if (
(leaf.expired()) ||
(ctrList == 0)
)
{
return;
}
mLeaf = leaf;
mCtrList = ctrList;
shared_ptr<Property> property = wxGetApp().GetProperty();
if (property.get() != 0)
{
property->GetClassList(mLeaf.lock(), mClassList);
}
mCtrList->ClearAll();
mCtrList->InsertColumn(0, _T("name"), wxLIST_FORMAT_LEFT, 120);
mCtrList->InsertColumn(1, _T("value"), wxLIST_FORMAT_LEFT, 600);
}
示例3: registerObjects
Factory::Factory(weak_ptr<RootObject> root)
{
_root = root;
if (!root.expired() && root.lock()->getType() == "scene")
_isScene = true;
registerObjects();
}
示例4: save
virtual void RK_CALL save(ReaK::serialization::oarchive& A, unsigned int) const {
if(Parent.expired())
A & RK_SERIAL_SAVE_WITH_ALIAS("Parent",shared_ptr<serialization::serializable>());
else
A & RK_SERIAL_SAVE_WITH_ALIAS("Parent",Parent.lock());
A & RK_SERIAL_SAVE_WITH_NAME(Position)
& RK_SERIAL_SAVE_WITH_NAME(Rotation);
};
示例5: runtime_error
inline shared_ptr<System> MultiSystemAccess::getSystem2() const {
if (mySystem2.expired()) {
throw std::runtime_error("expired system2");
}
return mySystem2.lock();
}
示例6: getGlobalPose
/**
* Returns this 2D pose relative to the global (null) coordinate system.
*/
self getGlobalPose() const {
if(!Parent.expired()) {
self result = Parent.lock()->getGlobalPose();
result.Position += result.Rotation * Position;
result.Rotation *= Rotation;
return result;
} else
return *this;
};
示例7: SquareSetCheck
//check if it's the right place to set square if so ,set it
void Tetris::SquareSetCheck(const TETRIS_TYPE t_type,weak_ptr<Square> t_wsquare)
{
if(!t_wsquare.expired()){
shared_ptr<Square> t_ssquare = t_wsquare.lock();
if(t_ssquare->ConflictCheck(t_type) == true)
{
t_ssquare->SetSquare(t_type);
}
}else{
LogWriter::me->WriteLog("square expired in SquareSetCheck");
}
}
示例8: getPoseRelativeTo
/**
* Returns this 2D pose relative to pose P.
*/
self getPoseRelativeTo(const shared_ptr< const self >& P) const {
if(!P)
return getGlobalPose();
if(isParentPose(P)) {
if(Parent.lock() == P)
return *this;
else
return Parent.lock()->getPoseRelativeTo(P) * (*this);
} else if(P->isParentPose( rtti::rk_static_ptr_cast< const self >(mThis)))
return ~(P->getPoseRelativeTo( rtti::rk_static_ptr_cast< const self >(mThis)));
else if(Parent.expired())
return (~(P->getGlobalPose())) * (*this);
else
return Parent.lock()->getPoseRelativeTo(P) * (*this);
};
示例9: isParentPose
/**
* Returns true if P is part of the parent chain from this pose.
*/
bool isParentPose(const shared_ptr< const self >& P) const {
if(Parent.expired()) {
if(P)
return true;
else
return false;
} else {
if(P)
return false;
else if(P == Parent.lock())
return true;
else
return Parent.lock()->isParentPose(P);
};
};
示例10: SquareCtrl
//read input key to move square
void Tetris::SquareCtrl(const TETRIS_TYPE t_type,weak_ptr<Square> t_wsquare)
{
if(!t_wsquare.expired()){
shared_ptr<Square> t_ssquare = t_wsquare.lock();
KeyboardUpdate();
//down button is pressed
if(((KeyboardGet(KEY_INPUT_DOWN) > 0)&&(t_type == TETRIS_UP))||
((KeyboardGet(KEY_INPUT_UP) > 0)&&(t_type == TETRIS_DOWN))||
((KeyboardGet(KEY_INPUT_RIGHT) > 0)&&(t_type == TETRIS_RIGHT))||
((KeyboardGet(KEY_INPUT_LEFT) > 0)&&(t_type == TETRIS_LEFT))
){
t_ssquare->Move(kGODOWN,t_type);
}
//left button is pressed
else if(((KeyboardGet(KEY_INPUT_LEFT) > 0)&&(t_type == TETRIS_UP))||
((KeyboardGet(KEY_INPUT_RIGHT) > 0)&&(t_type == TETRIS_DOWN))||
((KeyboardGet(KEY_INPUT_DOWN) > 0)&&(t_type == TETRIS_LEFT))||
((KeyboardGet(KEY_INPUT_UP) > 0)&&(t_type == TETRIS_RIGHT))
){
t_ssquare->Move(kGOLEFT,t_type);
}
//right button is pressed
else if(((KeyboardGet(KEY_INPUT_RIGHT) > 0)&&(t_type == TETRIS_UP))||
((KeyboardGet(KEY_INPUT_LEFT) > 0)&&(t_type == TETRIS_DOWN))||
((KeyboardGet(KEY_INPUT_UP) > 0)&&(t_type == TETRIS_LEFT))||
((KeyboardGet(KEY_INPUT_DOWN) > 0)&&(t_type == TETRIS_RIGHT))
){
t_ssquare->Move(kGORIGHT,t_type);
}
else if(((KeyboardGet(KEY_INPUT_UP) > 0)&&(t_type == TETRIS_UP))||
((KeyboardGet(KEY_INPUT_DOWN) > 0)&&(t_type == TETRIS_DOWN))||
((KeyboardGet(KEY_INPUT_RIGHT) > 0)&&(t_type == TETRIS_LEFT))||
((KeyboardGet(KEY_INPUT_LEFT) > 0)&&(t_type == TETRIS_RIGHT))
){
t_ssquare->Turn(t_type);
}else if(KeyboardGet(KEY_INPUT_SPACE ) > 0){
CtrlBoardChangine(t_type);
}
else if (KeyboardGet(KEY_INPUT_Z) == 1){
SpeedUp();
}
else if (KeyboardGet(KEY_INPUT_X) == 1){
SpeedDown();
}
}
}
示例11: Reflect
void DirectusMaterial::Reflect(weak_ptr<GameObject> gameobject)
{
m_inspectedMaterial = weak_ptr<Material>();
// Catch the evil case
if (gameobject.expired())
{
this->hide();
return;
}
MeshRenderer* meshRenderer = gameobject.lock()->GetComponent<MeshRenderer>().lock().get();
if (!meshRenderer)
{
this->hide();
return;
}
m_inspectedMaterial = meshRenderer->GetMaterial();
if (m_inspectedMaterial.expired())
{
this->hide();
return;
}
// Do the actual reflection
ReflectName();
ReflectShader();
ReflectAlbedo();
ReflectRoughness();
ReflectMetallic();
ReflectNormal();
ReflectHeight();
ReflectOcclusion();
ReflectEmission();
ReflectMask();
ReflectTiling();
ReflectOffset();
SetPropertiesVisible(m_inspectedMaterial.lock()->IsEditable() ? true : false);
// Make this widget visible
this->show();
}
示例12: SetParent
void kinematicFrame::SetParent(weak_ptr<Leaf> parent)
{
shared_ptr<SimSpark> spark = wxGetApp().GetSpark();
if (spark.get() == 0)
{
return;
}
if (parent.expired())
{
mParent = Leaf::CachedPath<zeitgeist::Leaf>();
} else
{
std::string path = parent.lock()->GetFullPath();
mParent.SetKey(Core::CacheKey(spark->GetCore()->GetRoot(), path));
}
UpdateCached();
}
示例13: SetLeaf
void propertyframe::SetLeaf(weak_ptr<Leaf> leaf)
{
shared_ptr<SimSpark> spark = wxGetApp().GetSpark();
if (spark.get() == 0)
{
return;
}
if (leaf.expired())
{
mPath = Leaf::CachedPath<zeitgeist::Leaf>();
} else
{
std::string path = leaf.lock()->GetFullPath();
mPath.SetKey(Core::CacheKey(spark->GetCore()->GetRoot(), path));
}
UpdateCached();
RefreshProperties();
}
示例14: Reflect
void DirectusAudioListener::Reflect(weak_ptr<GameObject> gameobject)
{
m_inspectedAudioListener = nullptr;
// Catch the evil case
if (gameobject.expired())
{
this->hide();
return;
}
// Catch the seed of the evil
m_inspectedAudioListener = gameobject.lock()->GetComponent<AudioListener>().lock().get();
if (!m_inspectedAudioListener)
{
this->hide();
return;
}
// Make this widget visible
this->show();
}
示例15: addAnnotation
bool Object::addAnnotation(weak_ptr<Annotation> annotation) {
if (!isActive()) return false;
if (annotation.expired()) return false;
return addAnnotation(annotation.lock());
}