[Clam-devel] Segmentation LoadFrom
David García Garzón
dgarcia at iua.upf.edu
Thu Jun 12 03:59:59 PDT 2008
TODO: Test for UnsizedSegmentation StoreOn
Then the LoadFrom. Generate and send a patch at any point you have all working
after a new test in green and after any successfull refactoring.
The code in Annotator that does the conversion from Array is in
SegmentationPane::refreshSegmentation. Such code uses the constructor with
three parameters. Note that parameters are the same for the three kinds. Note
also that one cannot be deduced from the XML we have now, that will make us
in trouble later, but by now let's skip that.
Take just ContiguousSgmentation:
We would like to have a virtual function that receives the array. But current
implementation does not receive a CLAM::Array but it is templated as
iterators which is very convenient for other uses (tests). But template and
virtual are incompatible, the first refactoring would be to turn the template
constructor into a constructor receiving just TData* which i think is
compatible with any current use. Just in case, compile, both the annotator
and the tests and pass the tests.
Once we turned the constructor into a templateless one, lets do an 'Extract
method' refactoring from the constructor for the data filling part. So, for
each Segmentation add the following method:
void takeArray(TData * begin, TData * iterator end)
// copy here the filling code from the constructor
Then substitute the copied code at the constructor by a call to such method.
All the test should be working.
No proceed the same with the rest of the Segmentations sending patches at the
Create a virtual method takeArray on base Segmentation. Should still compile.
On SegmentationPane, intead of using the three parameters constructor use the
one parameter one and let's call the takeArray method after the switch. All
the segmentations should still work so try them at Annotator as we did some
Now, those refactoring have prepared the way for our desired red, the LoadFrom
test. Some hints: you can define an std::istreamstream("With some xml content
to be read") and see how previous tests use the boundsAsString method to get
the actual segmentation content as string.
Now you'll try to use the load but now we have a problem: We are missing the
audioDuration parameter. By now, just set it on the constructor. Here we
would need to change the XML format to add such a bound as part of the XML,
this can break a lot of things so this is the perfect point to have a
David García Garzón
(Work) dgarcia at iua dot upf anotherdot es
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: This is a digitally signed message part.
More information about the clam-devel