I am working on moving some processing from a C++ driver to a new method in a class within the environment in which I work. I have started working on the method, but I am facing problems when attempting to call other object dependent methods that exist in the class from the newly written method. Here is some of the code:
bool resample_edf(VVectorDouble& sigin_a, VVectorDouble& sig_out_a,
long out_freq_a) {
// display debugging information
//
if (debug_level_d >= Edf::LEVEL_DETAILED) {
fprintf(stdout, "Edf::resample_edf(): starting resample/n");
}
// get the labels in the file
//
char* labels[Edf::MAX_NCHANS];
long num_channels = Edf::get_labels(labels);
long num_samples = (long) Edf::get_duration() * Edf::get_sample_frequency();
...
The get_labels(labels)
, get_duration()
, and get_sample_frequency()
methods are all methods of the Edf class that I am working in, but I get this error when attempting to compile it.
edf_01.cc:2240:45: error: cannot call member function ‘long int Edf::get_labels(char**)’ without object
long num_channels = Edf::get_labels(labels);
^
edf_01.cc:2242:47: error: cannot call member function ‘double Edf::get_duration()’ without object
long num_samples = (long) Edf::get_duration() * Edf::get_sample_frequency();
All of the methods are public methods, but some of the variables they use are protected in the class.
I am not exactly sure how to resolve this issue, but I will continue looking into it. Thank you the help. Please let me know if more information is needed.
Edit: I guess there are some misunderstandings so I will provide more information.
An Edf object already exists in the utility that is calling this method. The utility looks something like this at the moment:
// local include files
//
#include <Edf.h>
...
int main(int argc, const char** argv) {
...
// create an Edf object
//
Edf edf(Edf::LEVEL_NONE);
// resample the signal
//
if (!edf.resample_edf(sig_in, sig_out, out_freq)) {
fprintf(stdout, " **> nedc_resample_edf: error resampling signal\n");
return((status = -1))
}
...
The resample_edf method is a method within the edf object. Now, inside that method, I want to be able to call other methods from the object, but I am getting errors in doing so. Reinstantiating an edf object within this method will not help me here. I have tried multiple ways of doing it, but nothing has worked.
I did not originally include the way the utility is being run because the compiling of the class has nothing to do with the utility. The problem comes from how the method is calling other methods from the same object. The Edf class is very big, so it would be hard to supply you the whole thing.
Sorry if the original post was not clear.