Question about programming techniques


sorry, I know this is the wrong list for this kinf of question.  I choosed
this list, because I adopted most of my programming style from GNOME/GTK+
and Objective-C. But I couldnīt find a solution for storing arbitrary data
within container classes like arrays, lists, fifos, ringbuffers, ... 

From what I know is:  
- GTK+ uses pointers. I think, that this results in a lot of typecasts,
dereferences, allocations and deallocations. (E.g. I what if I want to
store 1000 integer values into an array and make a lot of modifications
with new values)

-  C++ uses templates. The functions are written with best performance for
every data type, but that although the point. They are written for every

- OpenStep/Objective-C: Only objects can be stored into an container
class, so arbitrary data has to be packed into objects before. You have
special functions/messages to extract the data from the oject, like
getInt, getFloat, ... 

This would mean, that I provide a function like getSizeOfType to determine
the size of a Type at runtime. Then I would call my class init function
with the type of the data. The init function could gather the size and can
allocate enough memory for the data objects. To extract the data I would
have functions like void* array_getAt(array, position) for the pointer
itself and macros like:
#define array_getIntAt(array,pos)  (*(int*)(array_getAt(array,pos))
Then I have to provide only the defines for new datatypes.

As I said, I learned a lot from GTK+ and I tried to use the programming
style within my projects. (The object oriented approach isnīt implemented,
yet). But glib dosenīt provide all kind of container classes, yet. So I
have to implement them on my own. I donīt know if it is better to go with
the pointer method or with the Objective-C style. 


    _/         _/_/   _/      _/          Dirk Luetjens
   _/        _/      _/_/  _/_/           Lehrstuhl fuer Messtechnik
  _/        _/_/    _/  _/  _/            RWTH Aachen
 _/        _/      _/      _/             D-52056 Aachen
_/_/_/_/  _/      _/      _/              Germany

Institute for Measurement Techniques      phone: +49 241 80 78 65     
University of Technology Aachen           fax:           8888 200
                                          email: dirk@post.LfM.RWTH-Aachen.De

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]