Jump to content
  • Advertisement
Sign in to follow this  
iraxef

Expanding asIBinaryStream for finished notification

This topic is 1336 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Would you consider expanding asIBinaryStream to include something like the below 2 functions:

class asIBinaryStream
{
public:
	virtual void Read(void *ptr, asUINT size) = 0;
	virtual void Write(const void *ptr, asUINT size) = 0;

        // NEW FUNCTIONS
        virtual void FinishedRead() {}
        virtual void FinishedWrite() {}

public:
	virtual ~asIBinaryStream() {}
};

Thanks for your consideration.

Share this post


Link to post
Share on other sites
Advertisement

I might, but to what purpose would you want me to include this? 

 

When the LoadByteCode or SaveByteCode method returns the engine won't use the stream any further, so the application can easily determine when the engine is done with the stream anyway. What would the benefit be of the engine first explicitly calling FinishedRead or FinishedWrite on the stream just before returning?

Share this post


Link to post
Share on other sites

Separation of concerns, I suppose.. I shouldn't have to manually manage something this low level where if I potentially forget to reset the instance between reads I've either got a buffer overrun or an assert/exception (depending on how I've dealt with the buffer access). If the script engine has an internal way to tell the concrete instance (of the binary stream) that it's finished, then from an external perspective that instance will always be in a consistent state.

 

It's just a better-encapsulated system if it 'takes care of itself'.

Edited by iraxef

Share this post


Link to post
Share on other sites

Normally I would agree, but in this case the engine is not the one to open the stream in the first place, so you're not achieving the encapsulated system anyway. The application is responsible for making sure the stream starts from the right position, so I don't see why it shouldn't be responsible for making sure the stream is also finished properly. :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!