Introducing Quartz
- Posted by Roderick Jackson <rjackson at CSIWEB.COM> Feb 19, 1999
- 400 views
------ =_NextPart_000_01BE5BE2.887ECB20 Content-Transfer-Encoding: quoted-printable Hi all, With the help of a few folks from the list, I've been able to complete = my contribution to the Euphoria community... I call it Quartz. Quartz is a library of routines to emulate object-orientation and = classes in Euphoria. I understand that there have been at least two = other such libraries created already; I'm not trying to imitate them = (I'm not sure what features they have), but just to provide something = simple and easy to use, something that fits what I feel is a logical way = to implement the concept. Quartz allows q-objects to be derived from user-defined classes, either = based on a foundational class "qobject", or on a previously-defined = class. Classes inherit data members as well as methods from parent = classes (although methods can be overwritten in subclasses). Constructor = methods are supported as well, but not deconstructors. Classes, members = and methods are labeled and accessed via their names (Euphoria = "strings"). Finally, error checking is performed, and a few global types = and constants are provided to aid use of the library. There are five major Quartz routines: define_qclass (..) - this sets up the structure for each class. Class = name, parent it inherits from, member names, method names, the routine = IDs of method functions, and the routine ID of the constructor function = (else NO_CONSTRUCTOR) are set here. If your classes are all in a = seperate file, simply "include quartz.e" at the top, detail the method = functions, then use a call to "define_qclass" for each. Then in your = main program, just include your class file. new_qobject (class, param) - this returns a new q-object, of the = specified class. The parameter is required, but only used if the class = has a constructor method. send_qmessage (qobject, method, param) - this invokes a method. Each = method, defined by the user, is a global function accepting the q-object = and one other parameter. An method which an q-object inherits will = always be able to properly manipulate that q-object, provided that = "get_qmember" and "set_qmember" are used, and that related methods = haven't been overwritten. get_qmember (qobject, member) - this returns the value of a = q-object's specified member. For example: W =3D get_qmember (MyCat, = "Weight"). set_qmember (qobject, member, value) - this returns the q-object, = modified so that it's specified member is set to the new value. For = example: MyDog =3D set_qmember (MyDog, "LifeStatus", DEAD). To emulate = encapsulation, use only in method code. In addition, two minor functions have been provided that may be of use: get_qobject_class (qobject) - returns the Euphoria "string" naming = the object's class. is_qsubclass (class, class) - returns TRUE if the first class is a = direct or indirect subclass of the second. This is not a full public release yet, although please feel free to try = out and make use of the library. I've done some testing, but I want to = work on more thorough documentation and a better example program before = I submit Quartz for posting on the Euphoria site--optimizing the code = also has yet to be done. The Quartz library (quartz.e), the example = program (example.ex) and the include file created for the example = (animals.e) are attached. Quartz runs under Euphoria 2.0 and 2.1, I = haven't tested it with anything below that. I'd appreciate any comments on Quartz. And again, thanks for the help, = and enjoy! Rod Jackson ------ =_NextPart_000_01BE5BE2.887ECB20