MCPcopy Create free account
hub / github.com/audeering/opensmile / myFinaliseInstance

Method myFinaliseInstance

src/core/dataProcessor.cpp:548–596  ·  view source on GitHub ↗

finalise reader an writer first finalise the reader, so we can read field/element names from it then set names for the writer then finalise the writer... */

Source from the content-addressed store, hash-verified

546 then finalise the writer...
547 */
548int cDataProcessor::myFinaliseInstance()
549{
550 // an extra hook to allow custom configure of e.g. vectorProcessors, etc. without overwriting myFinaliseInstance!
551 if (!dataProcessorCustomFinalise()) {
552 SMILE_IERR(1,"dataProcessorCustomFinalise returned 0 (failure) !");
553 return 0;
554 }
555
556 /* available hooks for setting data element names in the output level:
557 1. setupNewNames() : you are free to set any names in the output level, independent of the names in the input level
558 (configureField will not be called! you must do everything in setupNewNames!)
559
560 2. setupNamesForField() : this will be called for every input field(!), use this if you only want to append a suffix or change the number of elements in each field!
561 setupNamesFor filed must return the number of elements that were set for the current field
562 + configureField() : custom configuration (e.g. allocation of buffers, etc.) that the component must perform shall be put into this method!
563
564 a hook that actually sets names MUST set the variable "namesAreSet" to 1
565
566 if no hook sets the names, the names will be copied from the input level, and the suffix "nameAppend" will be appended!
567 */
568
569 // hook 1.
570 if (!namesAreSet_) {
571 if (!setupNewNames(reader_->getLevelNf())) {
572 SMILE_IERR(1,"setupNewNames() returned 0 (failure)!");
573 return 0;
574 }
575 }
576
577 // hook 2.
578 if (!namesAreSet_) {
579 int lN = reader_->getLevelNf();
580 int i;
581 for (i=0; i<lN; i++) {
582 int llN=0;
583 int arrNameOffset=0;
584 const char *tmp = reader_->getFieldName(i,&llN,&arrNameOffset);
585 long nOut = setupNamesForField(i,tmp,llN);
586 if (nOut==llN) {
587 writer_->setArrNameOffset(arrNameOffset);
588 }
589 configureField(i,llN,nOut);
590 cloneInputFieldInfo(i, -1, 0); //fallback... no overwrite
591 }
592 namesAreSet_ = 1;
593 }
594
595 return writer_->finaliseInstance();
596}
597
598cDataProcessor::~cDataProcessor()
599{

Callers

nothing calls this directly

Calls 4

finaliseInstanceMethod · 0.80
getLevelNfMethod · 0.45
getFieldNameMethod · 0.45
setArrNameOffsetMethod · 0.45

Tested by

no test coverage detected