Jump to content
  • Advertisement
Sign in to follow this  
Halifax2

Middleware Development Help

This topic is 3636 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

Alright, I just need some quick help with some of my development concerns. Right now I am developing some middleware, and as everyone knows, middleware should be easily integrated into existing engines. Basically, I want the user to be able to "plug" their own implementations for vectors, matrices, file handling, and other things into the middleware, and then the middleware will use their implementation. So my solution: I create an abstract interface for the user implementation to adhere to, and then I create an abstract interface for a factory class, with one function, that the user must implement. The user then registers their factory class, and the engine uses that factory class to create the objects without any idea of the underlying implementation. Does this seem reasonable? Is there a better way to do it?

Share this post


Link to post
Share on other sites
Advertisement
I suspect that an abstract interface for matrix and vector handling will incur too much overhead. You'd want them to write a 3D vector factory, for example? And would those vectors have to derive from your base class?

Share this post


Link to post
Share on other sites
Yes, currently, they have to derive from the base class. And that's exactly what I was afraid of, the overhead.

So any suggestions on how I would gaurantee that the user's implementation has specific functions, such as normalize(), dotproduct(), etc.?

Share this post


Link to post
Share on other sites
provide templates that require them.

provide the classes yourself then all they have to do is write conversion constructors or use them as is.

Share this post


Link to post
Share on other sites
Forcing vector, matrix and file handling class' to derive from your base class is just bad design, take some time to learn what good middleware design involves. For example this blog post by Kyle Wilson and the presentation I link to in the comments.

edit: link fixed

Share this post


Link to post
Share on other sites
Quote:
Original post by stonemetal
provide templates that require them.

provide the classes yourself then all they have to do is write conversion constructors or use them as is.


I don't quite understand your first explanation, can you explain that. And your second example does seem alright, but then the class I provide does not use their implementation, which could be optimized for some special cases or something.

Quote:
Original post by dmail
Forcing vector, matrix and file handling class' to derive from you base class is just bad design, take some time to learn what good middleware design involves. For example this blog post by Kyle Wilson and the presentation I link to in the comments.


That link doesn't work.

Share this post


Link to post
Share on other sites
Quote:
Original post by dmail
Forcing vector, matrix and file handling class' to derive from your base class is just bad design, take some time to learn what good middleware design involves. For example this blog post by Kyle Wilson and the presentation I link to in the comments.
That link is going in bookmarks forthwith.

Share this post


Link to post
Share on other sites
Quote:
Original post by swiftcoder
Quote:
Original post by dmail
Forcing vector, matrix and file handling class' to derive from your base class is just bad design, take some time to learn what good middleware design involves. For example this blog post by Kyle Wilson and the presentation I link to in the comments.
That link is going in bookmarks forthwith.


Odd, it works for me now too. I guess I will have a read then.

EDIT:

Ah, you fixed the link, that's why. But at any rate, I have read that article before when I was searching the internet for answers to my question. This is the exact reason why I wrote, "Basically, I want the user to be able to "plug" their own implementations for...file handling..."

Currently, I have no answers on how to do this efficiently.

Share this post


Link to post
Share on other sites
Did you also listen to the presentation?
If you are going to be doing matrix and vector operations then you need to use you own representation (or a well defined implementation), yet not force the user of your library to have to use it. Instead give them options by supplying more than one method of informing you of a matrix or vector.
Most math libraries have a conversion to a block of data from a class in the form of float* or double* so having this option is really a must. The presentation makes the point of writing user code before library code, ie what will your uses have to do, so ...

enum MATRIX_ORDER{ROW,COLUMN};
void Lib::bar(float*);
void Lib::set_matrix_order(COLUMN);//initialise the lib
...
//user code
D3DXMATRIX foo;
Lib::bar(foo);//D3DXMATRIX has the conversion and the library knows the layout.



You could also support the DirectX math library directly in a windows build or at least give the user the option, possibly also giving the user the _option_ of using your libraries fancy matrix type. Another possibility is to document your matrix type and say to the user here is a abstract class derive from it with an implementation of converting from my type to yours and vice versa and tell the library about it. You could also have an option which accepts 16 floats or ...

Share this post


Link to post
Share on other sites
Quote:
Original post by Halifax2
Basically, I want the user to be able to "plug" their own implementations for vectors, matrices
Don't. I've seen it tried, and it doesn't work, and it sucks. Manually written conversion functions, mildly annoying though they may be, are the way to go. Just make sure to store your matrices in the same order as everyone else, so that conversion functions are no-ops.
Quote:
file handling

This one's a better idea, and it's also a lot easier. The way you proposed will work fine. Consider, though, how streaming will affect things.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!