Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: references to keep between different objects  (Read 1423 times)

0 Members and 1 Guest are viewing this topic.

blue_prawn

  • Newbie
  • *
  • Posts: 5
    • View Profile
references to keep between different objects
« on: June 10, 2012, 04:51:57 pm »
Hi,

I'm the author of the ocaml-sfml bindings.
OCaml is a garbage collected language, so I need to know the precise relationships between objects that interact together to know which should keep a reference alive around and which don't have to.

For SFML-1.6 Laurent gave me these informations:

- Sound  should keep a reference on its SoundBuffer
- String should keep a reference on its Font
- Sprite should keep a reference on its Image
- PostFx should keep references on all its Images given with SetTexture
- Window should keep a reference on its Input
- RenderWindow should keep a reference on its Input
- RenderWindow should keep a reference on its CurrentView and its DefaultView

So could someone help me to update and complete these informations for SFML-2.0?

When object A uses object B, does B have to stay arround or may it be deleted?

- Sound  should keep a reference on its SoundBuffer
- String should keep a reference on its Font
?? Texture ?(should | don't have to)? keep a reference on its Image ??
?? Sprite ?(should | don't have to)? keep a reference on its Texture ??
- RenderWindow should keep a reference on its CurrentView and its DefaultView
?? Shape <=> Texture ??
?? SocketSelector <=> Socket ??
?? Socket <=> SocketSelector ??
?? Shader ??

... others ???
« Last Edit: June 10, 2012, 04:55:20 pm by blue_prawn »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: references to keep between different objects
« Reply #1 on: June 10, 2012, 05:42:53 pm »
(yes = should keep a reference, no = don't have to)

Quote
?? Texture ?(should | don't have to)? keep a reference on its Image ??
No.

Quote
?? Sprite ?(should | don't have to)? keep a reference on its Texture ??
Yes.

Quote
?? Shape <=> Texture ??
Yes.

Quote
?? SocketSelector <=> Socket ??
No.

Quote
?? Socket <=> SocketSelector ??
No.

Quote
?? Shader ??
Should keep a reference to its textures.

Quote
... others ???
Sorry I don't have the time to review all the classes, I'll try to do it later.
Don't hesitate to look at the .Net binding, it has the same problem to solve.
Laurent Gomila - SFML developer

blue_prawn

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: references to keep between different objects
« Reply #2 on: June 10, 2012, 06:43:09 pm »
Thanks a lot Laurent !
I appreciate in particular how fast you answer to questions.

 

anything