Skip to content
Snippets Groups Projects
Commit bccd0283 authored by Joan Vallvé Navarro's avatar Joan Vallvé Navarro
Browse files

lock() != nullptr instead of expired()

parent 3e31b91c
No related branches found
No related tags found
1 merge request!394Resolve "Safe and more complete print()"
Pipeline #5913 passed
...@@ -316,27 +316,27 @@ void FactorBase::printHeader(int _depth, bool _constr_by, bool _metric, bool _st ...@@ -316,27 +316,27 @@ void FactorBase::printHeader(int _depth, bool _constr_by, bool _metric, bool _st
for (const auto& Fow : getFrameOtherList()) for (const auto& Fow : getFrameOtherList())
{ {
auto Fow_sh = Fow.lock(); auto Fo = Fow.lock();
if (Fow_sh) if (Fo)
_stream << " Frm" << Fow_sh->id(); _stream << " Frm" << Fo->id();
} }
for (const auto& Cow : getCaptureOtherList()) for (const auto& Cow : getCaptureOtherList())
{ {
auto Cow_sh = Cow.lock(); auto Co = Cow.lock();
if (Cow_sh) if (Co)
_stream << " Cap" << Cow_sh->id(); _stream << " Cap" << Co->id();
} }
for (const auto& fow : getFeatureOtherList()) for (const auto& fow : getFeatureOtherList())
{ {
auto fow_sh = fow.lock(); auto fo = fow.lock();
if (fow_sh) if (fo)
_stream << " Ftr" << fow_sh->id(); _stream << " Ftr" << fo->id();
} }
for (const auto& Low : getLandmarkOtherList()) for (const auto& Low : getLandmarkOtherList())
{ {
auto Low_sh = Low.lock(); auto Lo = Low.lock();
if (Low_sh) if (Lo)
_stream << " Lmk" << Low_sh->id(); _stream << " Lmk" << Lo->id();
} }
_stream << std::endl; _stream << std::endl;
} }
...@@ -366,9 +366,9 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBasePtr _fac_ptr, std::ostr ...@@ -366,9 +366,9 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBasePtr _fac_ptr, std::ostr
// find constrained_by pointer in constrained frame // find constrained_by pointer in constrained frame
for (const auto& Fow : getFrameOtherList()) for (const auto& Fow : getFrameOtherList())
{ {
if (!Fow.expired()) const auto& Fo = Fow.lock();
if (Fo)
{ {
const auto& Fo = Fow.lock();
if (_verbose) if (_verbose)
{ {
_stream << " ( --> Frm" << Fo->id() << " <- "; _stream << " ( --> Frm" << Fo->id() << " <- ";
...@@ -389,10 +389,9 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBasePtr _fac_ptr, std::ostr ...@@ -389,10 +389,9 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBasePtr _fac_ptr, std::ostr
// find constrained_by pointer in constrained capture // find constrained_by pointer in constrained capture
for (const auto& Cow : getCaptureOtherList()) for (const auto& Cow : getCaptureOtherList())
{ {
if (!Cow.expired()) const auto& Co = Cow.lock();
if (Co)
{ {
const auto& Co = Cow.lock();
if (_verbose) if (_verbose)
{ {
_stream << " ( --> Cap" << Co->id() << " <- "; _stream << " ( --> Cap" << Co->id() << " <- ";
...@@ -413,9 +412,9 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBasePtr _fac_ptr, std::ostr ...@@ -413,9 +412,9 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBasePtr _fac_ptr, std::ostr
// find constrained_by pointer in constrained feature // find constrained_by pointer in constrained feature
for (const auto& fow : getFeatureOtherList()) for (const auto& fow : getFeatureOtherList())
{ {
if (!fow.expired()) const auto& fo = fow.lock();
if (fo)
{ {
const auto& fo = fow.lock();
if (_verbose) if (_verbose)
{ {
_stream << " ( --> Ftr" << fo->id() << " <- "; _stream << " ( --> Ftr" << fo->id() << " <- ";
...@@ -436,10 +435,9 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBasePtr _fac_ptr, std::ostr ...@@ -436,10 +435,9 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBasePtr _fac_ptr, std::ostr
// find constrained_by pointer in constrained landmark // find constrained_by pointer in constrained landmark
for (const auto& Low : getLandmarkOtherList()) for (const auto& Low : getLandmarkOtherList())
{ {
if (Low.expired()) const auto& Lo = Low.lock();
if (Lo)
{ {
const auto& Lo = Low.lock();
if (_verbose) if (_verbose)
{ {
_stream << " ( --> Lmk" << Lo->id() << " <- "; _stream << " ( --> Lmk" << Lo->id() << " <- ";
...@@ -530,9 +528,9 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBasePtr _fac_ptr, std::ostr ...@@ -530,9 +528,9 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBasePtr _fac_ptr, std::ostr
// find in constrained Frame // find in constrained Frame
for (const auto& Fow : getFrameOtherList()) for (const auto& Fow : getFrameOtherList())
{ {
if (!Fow.expired()) const auto& Fo = Fow.lock();
if (Fo)
{ {
const auto& Fo = Fow.lock();
found_here = Fo->hasStateBlock(sb); found_here = Fo->hasStateBlock(sb);
if (found_here && _verbose) _stream << " FrmO" << Fo->id(); if (found_here && _verbose) _stream << " FrmO" << Fo->id();
found = found || found_here; found = found || found_here;
...@@ -551,9 +549,9 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBasePtr _fac_ptr, std::ostr ...@@ -551,9 +549,9 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBasePtr _fac_ptr, std::ostr
// find in constrained Capture // find in constrained Capture
for (const auto& Cow : getCaptureOtherList()) for (const auto& Cow : getCaptureOtherList())
{ {
if (!Cow.expired()) const auto& Co = Cow.lock();
if (Co)
{ {
const auto& Co = Cow.lock();
found_here = Co->hasStateBlock(sb); found_here = Co->hasStateBlock(sb);
if (found_here && _verbose) _stream << " CapO" << Co->id(); if (found_here && _verbose) _stream << " CapO" << Co->id();
found = found || found_here; found = found || found_here;
...@@ -563,9 +561,9 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBasePtr _fac_ptr, std::ostr ...@@ -563,9 +561,9 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBasePtr _fac_ptr, std::ostr
// find in constrained Feature // find in constrained Feature
for (const auto& fow : getFeatureOtherList()) for (const auto& fow : getFeatureOtherList())
{ {
if (!fow.expired()) const auto& fo = fow.lock();
if (fo)
{ {
const auto& fo = fow.lock();
// find in constrained feature's Frame // find in constrained feature's Frame
auto foF = fo->getFrame(); auto foF = fo->getFrame();
found_here = foF->hasStateBlock(sb); found_here = foF->hasStateBlock(sb);
...@@ -589,9 +587,9 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBasePtr _fac_ptr, std::ostr ...@@ -589,9 +587,9 @@ CheckLog FactorBase::localCheck(bool _verbose, FactorBasePtr _fac_ptr, std::ostr
// find in constrained landmark // find in constrained landmark
for (const auto& Low : getLandmarkOtherList()) for (const auto& Low : getLandmarkOtherList())
{ {
if (!Low.expired()) const auto& Lo = Low.lock();
if (Lo)
{ {
const auto& Lo = Low.lock();
found_here = Lo->hasStateBlock(sb); found_here = Lo->hasStateBlock(sb);
if (found_here && _verbose) _stream << " LmkO" << Lo->id(); if (found_here && _verbose) _stream << " LmkO" << Lo->id();
found = found || found_here; found = found || found_here;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment