Skip to main content
Wrend.1
Associate III
November 30, 2020
Solved

Can I get Instance of Model? Or How can I call the function of Model in other C code?

  • November 30, 2020
  • 1 reply
  • 1605 views

Often I call the C function from the hardware in Model::tick() function.

But how can I call the function of Model outside.

If I add a member variable to get the Instance(this) of Model, is there any risk? I mean if Model writed by Singleton mode.

This topic has been closed for replies.
Best answer by Martin KJELDSEN

What exactly do you want to accomplish? There might be another way. It could be that you simply want to have a task running and send a message through a queue to the Model which will then handle it in its ::tick() function.

1 reply

Martin KJELDSEN
Principal III
November 30, 2020

What is it exactly you want to do?

You probably either want to 1) Call a C++ function from C code 2) Have the Model react to something

/Martin

Wrend.1
Wrend.1Author
Associate III
November 30, 2020

1) Call a C++ function from C code

And now, I write a static pointer of Model​ and make it = this. To make it work. I am afraid it is not safe.:grinning_face_with_sweat:

Martin KJELDSEN
Martin KJELDSENBest answer
Principal III
November 30, 2020

What exactly do you want to accomplish? There might be another way. It could be that you simply want to have a task running and send a message through a queue to the Model which will then handle it in its ::tick() function.