Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8693965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:40:08+00:00 2026-06-13T00:40:08+00:00

My issue is : I define class (generator) inside of which I define a

  • 0

My issue is :

I define class (generator) inside of which I define a forward nested structs (topics and it_set).

I make the declaration of this nested class inside the .cpp file.

After this I declare a second class (ImageGenerator) which is an inheritence of generator.

I get an issue when I try inside of the declaration file of ImageGenerator.

Is there anyway to make that possible ?

My codes are these :

<i>
 //base.hpp
</i>

 class generator{

 protected:

    struct topics;
    struct it_set;

    NodeHandle _nh;

    cv::Ptr<topics> _topics;
    cv::Ptr<it_set> _set;

    cv::Mat _data;

public:


   generator(ros::NodeHandle&,const std::string&,const std::string&,const std::string&);

    virtual ~generator(void);

    bool ok(void)const;


protected:

    virtual void grab(void) = 0;

};

<i>
// base.cpp
</i>

static void cam_from_sub(const std::string& _subscriber,std::string& _cam){

    std::stringstream str;

    std::vector<std::string> words;

    std::string tmp;



    for(std::string::const_iterator it = _subscriber.begin();it != _subscriber.end();it++)
        (*it != '/')?(str<<*it):(str<<std::endl);

    while(!str.eof()){
        str>>tmp;
        words.push_back(tmp);
        tmp.clear();
    }

    words.pop_back();


    for(std::vector<std::string>::iterator it = words.begin(); it != words.end();it++){
        _cam+=*it+std::string("/");
        it->clear();
    }

    words.clear();

    _cam+= std::string("camera_info");


}


struct generator::topics{

    std::string _publisher;
    std::string _subscriber;
    std::string _camera_info;

    topics(const std::string& _pub,const std::string& _sub,const std::string& _cam):_publisher(_pub),_subscriber(_sub),_camera_info(_cam){}
    topics(const std::string &_pub, const std::string &_sub):_publisher(_pub),_subscriber(_sub){cam_from_sub(_subscriber,_camera_info);}
    ~topics(void){}
};


struct generator::it_set{

    image_transport::ImageTransport _it;
    image_transport::SubscriberFilter _is;
    image_transport::Publisher _pb;
    message_filters::Subscriber<sensor_msgs::CameraInfo> _cam_info;

    it_set(NodeHandle& _nh,cv::Ptr<generator::topics>& _topics):_it(_nh),_is(_it,_topics->_subscriber,1),_cam_info(_nh,_topics->_camera_info,1){ this->_pb = this->_it.advertise(_topics->_publisher,1);}

};

generator::generator(NodeHandle & nh, const std::string & subscribe, const std::string & publish, const std::string & camera_info):_nh(nh),_topics(new topics(publish,subscribe,camera_info)),_set( new it_set(_nh,_topics)){}

generator::~generator(void){ _set.release(); _topics.release();}

bool generator::ok(void)const{ return this->_nh.ok();}

<i>
// image.hpp
</i>
class ImageGenerator : public generator{

private:

    NodeHandle _nh;

    static bool _sht;

    bool _first_sht;
    bool _is_sub;

public:

    typedef void(*function_type)(const cv::Mat&,cv::Mat&);

private:

    function_type _fun;

    virtual void callback(const sensor_msgs::ImageConstPtr&);

    virtual void grab(void);

public:

    ImageGenerator(const NodeHandle&,const std::string&,const std::string&,const std::string&,function_type);

    ~ImageGenerator(void);

    void operator>>(cv::Mat&);
    void operator<<(const cv::Mat&);


};

<i>
// image.cpp
</i>

bool ImageGenerator::_sht = false;



void ImageGenerator::grab(void){

    if(!this->_is_sub)
        this->_set->_is.registerCallback(boost::bind(&ImageGenerator::callback,this,_1));



    ros::CallbackQueue* mloop = ros::getGlobalCallbackQueue();

    while(!this->_sht)
        mloop->callAvailable(ros::WallDuration(0.1f));

    this->_sht = true;

    mloop = NULL;

    this->_is_sub = true;

}

void ImageGenerator::callback(const sensor_msgs::ImageConstPtr &msg){

    cv_bridge::CvImagePtr cv_ptr;

    cv_ptr = cv_bridge::toCvCopy(msg);

    this->_data = cv_ptr->image;
}

ImageGenerator::ImageGenerator(const NodeHandle & nh, const std::string & subscribe, const std::string & publish, const std::string & camera_info, function_type fun):_nh(nh),base::generator(_nh,subscribe,publish,camera_info),_fun(fun){ this->grab();}

ImageGenerator::~ImageGenerator(void){}

The issue which I want to solve is at

void ImageGenerator::grab(void)

It’s :

this->_set->_is.registerCallback(boost::bind(&ImageGenerator::callback,this,_1));

the compiler answer :

error invalid use of incomplete type generator::it_set

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:40:09+00:00Added an answer on June 13, 2026 at 12:40 am

    The type is incomplete because the compiler hasn’t seen the definition of that struct.

    If you want to use the structs in subclasses of generator, you need to move their definitions inside the definition of generator in “base.hpp”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my issue define varibale MyArray as character extent 40 no-undo. define variable
I have another case for this issue which is, I have a model that
I have an abstract base class which inherits Sharp Arch's Entity class: /// <summary>
I believe that this is an issue of scope. All of my attempts to
I'm trying to make will_paginate's :order to work with this array: @posts = current_user.subscribed_tags.map(&:posts).flatten.paginate(:page
I'm having a templated function that uses a local class which is derived from
I'm currently learning Hibernate, and I've stumbled into this issue: I have defined 3
This question comes from issues raised by this answer . Normally, we define copy
I'm struggling to define a class method that populates and returns a collection of
I'm using method_missing to define a class for namespacing constants in a vocabulary. To

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.