boost::signals2::signalsコンポーネントで使用していますUpdateComponent。このコンポーネントの特定の集計のタイプはUpdateableです。Updateableの に接続できるようにしたいUpdateComponentのですがboost::signals2::signal。Updateableはでslotあることに注意してくださいpure-virtual。
以下は、コードの具体的な例です。
// This is the component that emits a boost::signals2::signal.
class UpdateComponent {
public:
UpdateComponent();
boost::signals2::signal<void (float)> onUpdate; // boost::signals2::signal
}
UpdateComponentのコードのある時点で、私はonUpdate(myFloat);を実行します。boost::signals2::signalこれは、すべての「リスナー」を「解雇」することに似ていると思います。
// The is the aggregate that should listen to UpdateComponent's boost::signals2::signal
class Updateable {
public:
Updateable();
protected:
virtual void onUpdate(float deltaTime) = 0; // This is the pure-virtual slot that listens to UpdateComponent.
UpdateComponent* m_updateComponent;
}
Updateableのコンストラクターでは、次のことを行います。
Updateable::Updateable {
m_updateComponent = new UpdateComponent();
m_updateComponent->onUpdate.connect(&onUpdate);
}
次の 2 つのエラーが表示されます。
...Updateable.cpp:8: error: ISO C++ forbids taking the address of an unqualified or parenthesized non-static member function to form a pointer to member function. Say '&BalaurEngine::Traits::Updateable::onUpdate' [-fpermissive]/usr/include/boost/function/function_template.hpp:225: error: no match for call to '(boost::_mfi::mf1<void, BalaurEngine::Traits::Updateable, float>) (float&)'
Qt をブーストと組み合わせて使用していることに言及する必要があります。ただし、ファイルに追加CONFIG += no_keywordsした.proので、boost Web サイトで概説されているように、2 つがスムーズに連携するはずです。signals私が Qt のand slots(非常にうまく機能する) を使用Updateableしない理由は、次のとおりですQObject。
エラーが発生する理由を誰かが理解するのを手伝ってくれたら、大歓迎です!