There are typo's in this example, interface is named sasa_interface throughout 
the code, errors introduced during copy/paste then edit for ease of reading :

Error is due to calling an object not in namespace Avogadro from an extension 
class, errors follow code.

in objectextension.h :

#ifndef .....

#include <avogadro/extension, widget and primative>
#include <Q_libs_that_are_relavent>

#include "interface.h"  //this is my class, moving this from the .h to the .cpp 
changes the error
#include "the_ui_bit.h"

//have instantiated interface here (haha, desparation)
//did a forward declaration and reassigned in .cpp as well, no difference 
(obviously I tried all these at different times)

namespace Avogadro{

//have instantiated interface here

class SASACalcFileDialog: public QDialog, private Ui::SASACalcFileDialog
  {
        Q_OBJECT

//have instatiated interface here

  public:
    explicit SASACalcFileDialog( QWidget *parent = 0, Qt::WindowFlags f = 0 ) ;
    ~SASACalcFileDialog();
public slots:
  //there are slots here but not relevant
private:
        interface *my_interface ;  //<--here is where I am currently 
instantiating but moving this around yeilds the same two
                                                    // interface needs to be a 
local variable
  };

//below here is the code to deal with the extension to avogadro, this works.

in objectextension.cpp:

#include "objectextension.h"

//have instantiated interface here

namespace Avogadro
{
//slots and other useful stuff goes here...

//have instantiated interface here

  void SASACalcFileDialog::setup()
  {
    //have instatiated interface here
    //simple math and function calls are here, inconsequential as this works.

    interface->setup_geometry(xyzFile, datFile, ffFile) ; <-- this is line 156, 
and where it is necessary to call this method.
  }
}

in interface.h:

#include <a_bunch_of_stuff>

class interface
{
public:
        interface() ;
        bool setup_geometry(QString, QString, QString) ; //args: xyz_file, 
dat_file, ff_file

private:
        double area ;
        geometry *thisGeometry ;
};

in interface.cpp:

#include "interface.h"

using namespace std ;
using namespace Eigen ;

interface::interface() //look a constructor!
{}

bool interface::setup_geometry(QString xyz_filePath, QString dat_filePath, 
QString ff_FilePath)   //and here is where the functionality lives
{
  //code that is nice and works
}


currently I am getting an undefined reference to 
interface::setup_geometry(QString, QString, Qstring) in objectextension.cpp on 
line 156 error,

substituting:     interface myInterface ;     in the header (not instatiating 
as a pointer) gives an undefined reference to both the constructor in 
objectextension.cpp line 36 and the setup_geometry(...) method. I assume this 
increase in errors is due to the object not really being instantiated when its 
declared as a pointer, and the first time a method is called is the first time 
the object is truly accessed/refered to.

forward declaration and instatiation as an object (not a pointer) yields 
redefinition of class interface errors.

Thanks,

Mark

________________________________________
From: Lewis, Mark [[email protected]]
Sent: 02 March 2011 14:38
To: [email protected]
Subject: [Avogadro-devel] avogadro/standalone interface

Hi all,

Am writing some code to calculate internal surface area of molecules/structures 
as a standalone and making an interface for a plugin to Avogadro, with an eye 
for more development in the future.

Here's the problem I have at the moment:

in objectextension.h :

#ifndef .....

#include <avogadro/extension, widget and primative>
#include <Q_libs_that_are_relavent>

#include "interface.h"  //this is my class, moving this from the .h to the .cpp 
changes the error
#include "the_ui_bit.h"

//have instantiated interface here (haha, desparation)
//did a forward declaration and reassigned in .cpp as well, no difference 
(obviously I tried all these at different times)

namespace Avogadro{

//have instantiated interface here

class SASACalcFileDialog: public QDialog, private Ui::SASACalcFileDialog
  {
        Q_OBJECT

//have instatiated interface here

  public:
    explicit SASACalcFileDialog( QWidget *parent = 0, Qt::WindowFlags f = 0 ) ;
    ~SASACalcFileDialog();
public slots:
  //there are slots here but not relevant
private:
        interface *my_interface ;  //<--here is where I am currently 
instantiating but moving this around yeilds the same two
                                                    // interface needs to be a 
local variable
  };

//below here is the code to deal with the extension to avogadro, this works.

in objectextension.cpp:

#include "objectextension.h"

//have instantiated interface here

namespace Avogadro
{
//slots and other useful stuff goes here...

//have instantiated interface here

  void SASACalcFileDialog::setup()
  {
    //have instatiated interface here
    //simple math and function calls are here, inconsequential as this works.

    interface->setup_geometry(xyzFile, datFile, ffFile) ; <-- this is line 156, 
and where it is necessary to call this method.
  }
}

in interface.h:

#include <a_bunch_of_stuff>

class interface
{
public:
        interface() ;
        bool setup_geometry(QString, QString, QString) ; //args: xyz_file, 
dat_file, ff_file

private:
        double area ;
        sasa_geometry *thisGeometry ;
};

in interface.cpp:

#include "sasa_interface.h"

using namespace std ;
using namespace Eigen ;

sasa_interface::sasa_interface() //look a constructor!
{}

bool sasa_interface::setup_geometry(QString xyz_filePath, QString dat_filePath, 
QString ff_FilePath)   //and here is where the functionality lives
{
  //code that is nice and works
}


currently I am getting an undefined reference to 
interface::setup_geometry(QString, QString, Qstring) in objectextension.cpp on 
line 156 error,

substituting:     interface myInterface ;     in the header (not instatiating 
as a pointer) gives an undefined reference to both the constructor in 
objectextension.cpp line 36 and the setup_geometry(...) method. I assume this 
increase in errors is due to the object not really being instantiated when its 
declared as a pointer, and the first time a method is called is the first time 
the object is truly accessed/refered to.

forward declaration and instatiation as an object (not a pointer) yeilds 
redefinition of class interface errors.

I am quite new to c++ and although I've encountered this before none of the 
prescription ways of dealing with this seem to be working, this is also my 
first project so please be mindful that what I say and what I mean may not 
necessarily coincide, clarification supplied on request and achieved through 
communication.

I am hoping this is a simple problem that most people encounter in their first 
implementation.

Cheers if you look at this,

Mark
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Avogadro-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/avogadro-devel

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Avogadro-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/avogadro-devel

Reply via email to