![]() |
Changes from 1.9.x to 2 |
![]() |
![]() |
lti::objectIn the LTI-Lib 1.9.x the lti::object only defined the virtual method getTypeName(). The interface for lti::object in the LTI-Lib 2 is much more stronger and specifies the "clonable" interface. Two methods have to be defined in all classes inherited from lti::object: clone() and newInstance(). The former creates an instance with a replicated internal state while the latter creates a new instance with the default constructor. The main reason for this change is that now, all lti::objects can potentially exist in factories, and for this fact the clone() methods are required A relatively new feature of C++ is used for clone() and newInstance(), which is not supported by GCC 2.95.x or VC++ 6.0: the return type of clone() is a pointer to the current class, and not a pointer to the parent class, as previously expected. This saves some unnecessary casting when working at the same level in the class hierarchy. The old method getTypeName() has then be replaced by name(). Since there are many objects for which is does not make sense to clone, then many old lti::objects are now independent from the hierarchy (e.g. lti::mutex, lti::factory, etc.) lti::className, getTypeName() and name()The LTI-Lib 1.9.x produced simple const char* with the method getTypeName(), which was not necessarily unique (especially for template classes). The LTI-Lib 2 has replaced the method getTypeName() with name(), which returns a fully qualified class name (generated with lti::className). This way, the name() method can be directly used with factories.
To simplify the manual generation of class names that are independent of the used C++ compiler or OS platform, all spaces are eliminated from the names. Names of template classesThe names of many template classes in the LTI-Lib 1.9.x began with a 't', so for example there were types lti::tpoint<T>, lti::tpointList<T>, lti::trectangle<T> among others. To be consistent with the lti::vector and lti::matrix types, all those types has been renamed to lti::point<T>, lti::pointList<T>, lti::rectangle<T>. Similarly to the shortcuts of vectors and matrices, there are now several shortcuts like lti::ipoint for lti::point<int>, or lti::fpoint for lti::point<float>. Underscores in protected and private attributesThe use of underscore is now not only allowed, but mandatory in the LTI-Lib
2 for protected or private attributes. This is necessary to simplify the
identification of local variables from class attributes. The attribute name
has to have a trailing underscore (e.g. lti::pointMember Functions
lti::rgbaPixel and lti::rgbPixel<T>In the older LTI-Lib the common pixel type was called rgbPixel; now the equivalent type in the LTI-Lib-2 is lti::rgbaPixel. The older trgbPixel is now called lti::rgbPixel<T>.lti::genericVectorThe generic vectors and matrices and all inherited classes have changed the initialization interface to a more intuitive, efficient one, even though it can be a little bit more dangerous. Construction and InitializationOld LTI-Lib 1.9.xPreviously, if you wrote: vector<T> oldVct(5); a vector with 5 elements initialized with T() was created. There are many cases in which you know you don't want to initialize anything to save some time. Therefore an alternative constructor was created: vector<T> oldVct(false,5); to avoid the initialization. This is however not so intuitive while reading. New LTI-Lib 2In C++ you know that if you write something like: int i; then the content of vector<T> aVct(5); // uninitialized vector with 5 elements, i.e. only // memory allocation vector<T> aVct(5,T()); // vector initialized with default value of T Resize and InitializationThe same applies to the Old LTI-Lib 1.9.xvector<T> vct; vct.resize(10); // 10 new elements initialized with T() vct.resize(15); // 5 new elements initialized with T(), keeping the first 10 vct.resize(18,T(6)); // 3 new elements initialized with "6", keeping the first // 15 elements New LTI-Lib 2vector<T> vct; vct.resize(10); // 10 new uninitialized elements vct.resize(15); // 5 new uninitialized elements, keeping the first 10, // whatsoever they were. vct.resize(18,T(6)); // 3 new elements initialized with "6", keeping the first // 15 elements One very important change is that in the LTI-Lib-2 the use of explicit method names is prefered over overloaded methods or the use of flags. In the particular case of the older "resize", the new prefered way is summarized in the following table:
lti::genericMatrixAccess as vectorIn the LTI-Lib 2 it was possible to access a connected matrix as vector, using an at() method which expected just an integer. Since with this method it is quite dangerous to make a non intended access to a matrix as vector, the method has been renamed to elem(). This way there is no possible misunderstanding that you want to do what you're saying (the problem caused several hours debugging in some functors!). lti::location, lti::rectLocationMember Functions
|