April 30, 2024, 11:42:51 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


class interchange system?

Started by kryton9, August 18, 2006, 12:18:44 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

kryton9

This is tough to ask clearly, but I hope this makes sense.

How can you make a class generic enough, but useful without it knowing certain things that it seems can only be hard coded in?

I know I can hard code pointers in my global sub main and write for those pointers in my class, but how can I structure a class to work on stuff without me doing that, because it sort of seems to me to defeat the purpose of classes being reuseable.

For example, I made 2 classes, one for a 3d screen and one for a control window. The control window will manipulate different objects in the 3d screen, but it has no idea what those will be.
It can vary from use of the classes in different applications, but lets say in this case I have 3 mesh objects in the 3d screen: m1, m2, m3    I want a generic set of controls to be able to manipulate those meshes, but not hard coded in. So that it could be in the future, 1 mesh or 20 meshes. Also the meshes could be named something else by someone else, for example sphere1, jet2 etc.

It would seem to me like a class should have a way of broadcasting info about itself and that another class could listen and know what to do, it is hard to explain but that is the best way I can put it.

On another note, I was playing with the dialog editor and controls tonight and I could see where having properties be useful there. For example: setting the window size, control sizes and default settings and values. There are some properties, but it is not complete for the various controls. Is it just that we are in the early stages of Aurora and more properties could be set in the future?

ExMember001

this is something i was thinking to ask in a near future too ...
an How to make a good class tutorial with Aurora could be very usefull!
i'm starting to get an idea on how to use this but i'm still more confortable using my old sub method for reusable code than use classes ;)


J B Wood (Zumwalt)

Example:

Global.INC

// contain getters and settters, along with common global variables and structures
struct obj
     VECTOR3 v1;
     C3DMesh m1;
     C3DObject o1;
end struct

subClass.cls
// this is a base class for example
Class BASE
    void _BASE();
    void BASE();

    obj BaseObj;
End Class


mainClass.cls
// this is our main class
class myMAIN :: BASE
    void _myMain();
    void myMain();
end class



Now, I don't know if I have the syntax correct for this compiler, but the thing is, myMain inherits everything from BASE as its starting point, so myMain also has BaseObj available to use.

If there is something that needs to be global, declare it in your include and include that in every class that needs to share that resource, the include would have to instansiate that object then every class using that instansiated version would have its properties.