Skip to content

Commit

Permalink
Remove Yuni::Bind from src, excluding src/ui (#1977)
Browse files Browse the repository at this point in the history
Remove `Yuni::Bind`, use `std::function`, `std::bind` instead.

Don't do it in src/ui (deprecated component).
  • Loading branch information
flomnes authored Mar 5, 2024
1 parent d028c1d commit 388fa0f
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/libs/antares/paths/include/antares/paths/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class PathList
/*!
** \brief Event triggered from time to time
*/
Yuni::Bind<bool(uint)> onProgress;
std::function<bool(uint)> onProgress;

private:
template<class StringT>
Expand Down
4 changes: 2 additions & 2 deletions src/libs/antares/paths/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class PathListIterator : public IO::Directory::IIterator<true>
using Flow = IO::Flow;

public:
PathListIterator(PathList& l, const PathList& e, Yuni::Bind<bool(uint)>& progress) :
PathListIterator(PathList& l, const PathList& e, std::function<bool(uint)>& progress) :
list(l), exclude(e), onProgress(progress)
{
}
Expand Down Expand Up @@ -160,7 +160,7 @@ class PathListIterator : public IO::Directory::IIterator<true>
PathList& list;
const PathList& exclude;
uint offset;
Yuni::Bind<bool(uint)>& onProgress;
std::function<bool(uint)>& onProgress;
};

void PathList::internalAddFromFolder(const Clob& folder, const PathList& exclude)
Expand Down
23 changes: 14 additions & 9 deletions src/libs/antares/study/binding_constraint/BindingConstraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <yuni/core/math.h>
#include <algorithm>
#include <vector>
#include <functional>

#include "antares/study/binding_constraint/BindingConstraint.h"
#include "antares/study/study.h"
#include "antares/study/binding_constraint/BindingConstraintLoader.h"
Expand All @@ -39,7 +41,8 @@ using namespace Antares;
#define SNPRINTF snprintf
#endif

namespace Antares::Data {
namespace Antares::Data
{

BindingConstraint::Operator BindingConstraint::StringToOperator(const AnyString& text)
{
Expand Down Expand Up @@ -211,10 +214,11 @@ void BindingConstraint::resetToDefaultValues()
markAsModified();
}

void BindingConstraint::copyWeights(const Study &study,
const BindingConstraint &rhs,
bool emptyBefore,
Yuni::Bind<void(AreaName&, const AreaName&)>& translate)
void BindingConstraint::copyWeights(
const Study& study,
const BindingConstraint& rhs,
bool emptyBefore,
const std::function<void(AreaName&, const AreaName&)>& translate)
{
if (emptyBefore)
{
Expand Down Expand Up @@ -276,10 +280,11 @@ void BindingConstraint::copyWeights(const Study &study,
}
}

void BindingConstraint::copyOffsets(const Study &study,
const BindingConstraint &rhs,
bool emptyBefore,
Yuni::Bind<void(AreaName&, const AreaName&)>& translate)
void BindingConstraint::copyOffsets(
const Study& study,
const BindingConstraint& rhs,
bool emptyBefore,
const std::function<void(AreaName&, const AreaName&)>& translate)
{
if (emptyBefore)
pLinkOffsets.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class BindingConstraint final : public Yuni::NonCopyable<BindingConstraint>
void copyWeights(const Study& study,
const BindingConstraint& rhs,
bool emptyBefore,
Yuni::Bind<void(AreaName&, const AreaName&)>& translate);
const std::function<void(AreaName&, const AreaName&)>& translate);

/*!
** \brief Get the offset of a given interconnection
Expand Down Expand Up @@ -269,7 +269,7 @@ class BindingConstraint final : public Yuni::NonCopyable<BindingConstraint>
void copyOffsets(const Study& study,
const BindingConstraint& rhs,
bool emptyBefore,
Yuni::Bind<void(AreaName&, const AreaName&)>& translate);
const std::function<void(AreaName&, const AreaName&)>& translate);

/*!
** \brief Get how many links the binding constraint contains
Expand Down
3 changes: 1 addition & 2 deletions src/libs/antares/study/include/antares/study/cleaner.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ class StudyCleaningInfos final
**
** Return false to stop the process
*/
Yuni::Bind<bool(uint)> onProgress;
std::function<bool(uint)> onProgress;

}; // class StudyCleaningInfos

} // namespace Antares::Data


#endif /* __ANTARES_LIBS_STUDY_CLEANER_H__ */
2 changes: 1 addition & 1 deletion src/libs/fswalker/fswalker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ void Walker::run()
thread->logPrefix = pLogPrefix;
// Extensions
DispatchJobEvent callback;
callback.bind(thread, &WalkerThread::dispatchJob);
callback = std::bind(&WalkerThread::dispatchJob, thread, std::placeholders::_1);
thread->events.initialize(pExtensions, callback);

// Starting the thread !
Expand Down
2 changes: 1 addition & 1 deletion src/libs/fswalker/fswalker.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ using OnFileEvent = void (*)(const YString& filename,
uint64_t size,
void* user);
//! Event for dispatching a new job
using DispatchJobEvent = Yuni::Bind<void(IJob::Ptr job)>;
using DispatchJobEvent = std::function<void(IJob::Ptr job)>;

class IExtension
{
Expand Down
2 changes: 1 addition & 1 deletion src/tools/cleaner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class StudyFinderCleaner final : public Data::StudyFinder

auto* cleaner = new Data::StudyCleaningInfos(folder);
cleaner->setCustomExcludeList(exclude);
cleaner->onProgress.bind(&onProgress);
cleaner->onProgress = &onProgress;
if (cleaner->analyze())
cleaner->performCleanup();
delete cleaner;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/updater/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class MyStudyFinder final : public Data::StudyFinder
if (cleanup)
{
auto* cleaner = new Data::StudyCleaningInfos(folder.c_str());
cleaner->onProgress.bind(&onProgress);
cleaner->onProgress = &onProgress;
if (cleaner->analyze())
cleaner->performCleanup();
delete cleaner;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/vacuum/modified-inode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void* ModifiedINode::userdataCreate(FSWalker::DispatchJobEvent&)

void ModifiedINode::userdataDestroy(void* userdata)
{
pQueue.unbind();
pQueue = []([[maybe_unused]] FSWalker::IJob::Ptr job){};

if (userdata)
{
Expand Down
15 changes: 6 additions & 9 deletions src/ui/action/handler/antares-study/constraint/offsets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,12 @@ bool Offsets::performWL(Context& ctx)
if (source && source != ctx.constraint)
{
pCurrentContext = &ctx;
Bind<void(Data::AreaName&, const Data::AreaName&)> tr;
if (!targetName.empty())
{
tr.bind(this, &Offsets::toLower);
}
else
{
tr.bind(this, &Offsets::translate);
}
const std::function<void(Data::AreaName&, const Data::AreaName&)> tr
= std::bind(targetName.empty() ? &Offsets::translate : &Offsets::toLower,
this,
std::placeholders::_1,
std::placeholders::_2);

ctx.constraint->copyOffsets(*ctx.study, *source, true, tr);
pCurrentContext = nullptr;
return true;
Expand Down
14 changes: 5 additions & 9 deletions src/ui/action/handler/antares-study/constraint/weights.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,11 @@ bool Weights::performWL(Context& ctx)
if (source && source != ctx.constraint)
{
pCurrentContext = &ctx;
Bind<void(Data::AreaName&, const Data::AreaName&)> tr;
if (!targetName.empty())
{
tr.bind(this, &Weights::toLower);
}
else
{
tr.bind(this, &Weights::translate);
}
const std::function<void(Data::AreaName&, const Data::AreaName&)> tr
= std::bind(targetName.empty() ? &Weights::translate : &Weights::toLower,
this,
std::placeholders::_1,
std::placeholders::_2);
ctx.constraint->copyWeights(*ctx.study, *source, true, tr);
pCurrentContext = nullptr;
return true;
Expand Down
1 change: 1 addition & 0 deletions src/ui/simulator/toolbox/components/map/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <wx/bitmap.h>
#include <wx/image.h>
#include <list>
#include <cstdint>

namespace Antares
{
Expand Down
10 changes: 7 additions & 3 deletions src/ui/simulator/windows/cleaner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class CleaningThread final : public Yuni::Thread::IThread
{
std::lock_guard locker(pParent->pMutex);
if (pParent->pInfos)
pParent->pInfos->onProgress.unbind();
pParent->pInfos->onProgress
= []([[maybe_unused]] unsigned int) { return false; };
}
stop();
}
Expand All @@ -69,7 +70,8 @@ class CleaningThread final : public Yuni::Thread::IThread
std::lock_guard locker(pParent->pMutex);
if (pParent->pInfos)
{
pParent->pInfos->onProgress.bind(this, &CleaningThread::onProgress);
pParent->pInfos->onProgress
= std::bind(&CleaningThread::onProgress, this, std::placeholders::_1);
delete pParent->pInfos;
pParent->pInfos = nullptr;
}
Expand All @@ -87,7 +89,9 @@ class CleaningThread final : public Yuni::Thread::IThread
{
logs.callback.clear();
pParent->pInfos = new Data::StudyCleaningInfos(stdFolder.c_str());
pParent->pInfos->onProgress.bind(this, &CleaningThread::onProgress);
pParent->pInfos->onProgress
= std::bind(&CleaningThread::onProgress, this, std::placeholders::_1);

pParent->pMutex.unlock();

pParent->pInfos->analyze();
Expand Down

0 comments on commit 388fa0f

Please sign in to comment.