0

I have covered state_machine object with wrapper object to hide asynchronous_state_machine initialization.

    class MyObject : public sc::asynchronous_state_machine< MyObject, MyObjectStateIdle, Scheduler, Allocator >;

    MyObjectShell(constructor data){
        Scheduler scheduler( true );
        mProcessor = scheduler.create_processor< MyObject >(constructor data);
        scheduler.initiate_processor( mProcessor );
        mThread = std::move(Thread(boost::bind(
               &sc::fifo_scheduler<>::operator(), &scheduler1, 0 )));
    }

    const MyObject* GetMyObject() const { /* What to place here to return MyObject, That I created via "scheduler.create_processor< MyObject >" */ }

    const MyObject_state_enum GetState() const { /* What to place here to return MyObject's state*/ }

MyObject is my async_state_machine

But I still need to have an access to MyObject from outside of stateMachine. How can I get it from mProcessor or any other? Or I have to talk with state_machine only through scheduler.queue_event( mProcessor , parameters_); ?

sehe
  • 374,641
  • 47
  • 450
  • 633
  • "MyObject is my async_state_machine" - I'm not convinced this means a lot to most people. I'd guess that if it doesn't tell me what you are doing, chances are no one is going to know, unless you show some code. – sehe Jul 27 '20 at 20:06
  • Edited initial question with more code, Sorry! – newAgeOfHelloWorld Jul 28 '20 at 03:33
  • So now we know that you're using the StateChart library. I blew my time budget (and then some) making your sample code self-contained so we can inspect the code: **[Live On Coliru](http://coliru.stacked-crooked.com/a/14423929f37a14c1)** – sehe Jul 28 '20 at 16:32
  • It does seem like you're trying to do something the wrong way around (you're not supposed to get `MyObject` back out). But I'm not well versed with the library so I can't tell what you're trying to achieve, nor how you'd normally do such. – sehe Jul 28 '20 at 16:32
  • We just had a type of object that is widely used in project, and it has a lot of internal states. So we decided to make it as state_machine. Still we want to have an access to it's interface outside state_machine. Now I will probably send this core object inside state_machine as a parameter and will operate it through closed interface. – newAgeOfHelloWorld Jul 29 '20 at 04:50

0 Answers0