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 7004279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:10:42+00:00 2026-05-27T21:10:42+00:00

I cant understand why in the class constructor I can call this function but

  • 0

I cant understand why in the class constructor I can call this function but when called in the test function, it errors out with

E:\Projects\NasuTek-Plugin-Engine\tests\CheckAddonEngine.cpp:64: error: conversion from 'std::auto_ptr<FakeSettableFeaturePlugin>' to 'std::auto_ptr<FakeFeature>' is ambiguous

C++ File

#include <ObjectEngine.h>
#include <memory>

#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>

class FakeFeature : public PObject {
    public:
        inline virtual const char *returnSomthingCool() { return "Somthing Cool"; }
};

class FakeFeaturePlugin : public FakeFeature {
    public:
        inline const char *returnSomthingCool() { return "Somthing Cool From a Plugin Object"; }
        inline std::string getName() { return "Fake Feature Plugin Object"; }
};

class FakeSettableFeaturePlugin : public FakeFeature {
    public:
        inline const char *returnSomthingCool() { return _value; }
        inline char *setSomthingCool(const char *value) { _value = const_cast<char *>(value); }
        inline std::string getName() { return "Fake Feature Settable Plugin Object"; }
    private:
        char *_value;
};

typedef ObjectEngine<FakeFeature> FakeFeatureEngine;

class FakeApplication {
    public:
        inline FakeApplication(){
            _engine = new FakeFeatureEngine();

            std::auto_ptr<FakeFeature> pluginToAdd (new FakeFeaturePlugin);

            _engine->addObject(pluginToAdd); // Essencially what im doing where it errors, both classes inherit FakeFeature
        }

        inline ~FakeApplication() {
            delete _engine;
        }

        FakeFeatureEngine *_engine;
};

BOOST_AUTO_TEST_CASE(getengineobject) {
    FakeApplication *application = new FakeApplication();
    FakeFeature &feature = application->_engine->getObject("Fake Feature Plugin Object");

    BOOST_CHECK_EQUAL(feature.getName(), "Fake Feature Plugin Object");
    BOOST_CHECK_EQUAL(feature.returnSomthingCool(), "Somthing Cool From a Plugin Object");

    delete application;
}

BOOST_AUTO_TEST_CASE(addobjecttoengine) {
    FakeApplication *application = new FakeApplication();

    std::auto_ptr<FakeSettableFeaturePlugin> plugin (new FakeSettableFeaturePlugin);
    plugin.get()->setSomthingCool("Bro I Set this to this value ^_^");

    application->_engine->addObject(plugin); // This is the line that fails

    FakeFeature &feature = application->_engine->getObject("Fake Feature Settable Plugin Object");

    BOOST_CHECK_EQUAL(feature.getName(), "Fake Feature Settable Plugin Object");
    BOOST_CHECK_EQUAL(feature.returnSomthingCool(), "Bro I Set this to this value ^_^");

    delete application;
}

.h File

/**
  @file ObjectEngine.h
  @brief Header File with Plugin Engine Templates to make adding a plugin interface to your app easier
  */

#ifndef NASUTEKPLUGINENGINE_H
#define NASUTEKPLUGINENGINE_H

#include <boost/ptr_container/ptr_list.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include <stdio.h>
#include <string>

class PObject {
    public:
        inline PObject() {}
        virtual std::string getName() = 0;
};

template<typename TObjectType>
class ObjectEngine {
    public:
        ObjectEngine() {}
        ~ObjectEngine() {
            _objects.clear();
        }
        void addObject(std::auto_ptr<TObjectType> obj) {
            if(boost::is_base_of<PObject, TObjectType>::value) {
                _objects.push_back(obj.release());
            }
        }
        TObjectType &getObject(std::string objectName) {
            typename boost::ptr_list<TObjectType>::iterator i;
            for(i = _objects.begin(); i != _objects.end(); i++) {
                if((*i).getName() == objectName) {
                    return *i;
                }
            }
            throw "Object does not exist.";
        }
        bool objectExist(std::string objectName) {
            typename boost::ptr_list<TObjectType *>::iterator i;
            for(i = _objects.begin(); i != _objects.end(); i++) {
                if((*i).getName() == objectName) {
                    return true;
                }
            }
            return false;
        }
    private:
        boost::ptr_list<TObjectType> _objects;
};

#endif // NASUTEKPLUGINENGINE_H

What I’m trying to do is create a plugin engine for my projects while making it reusable, and the C++ file is making sure its working right.

  • 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-05-27T21:10:43+00:00Added an answer on May 27, 2026 at 9:10 pm

    This doesn’t look like a problem with Boost Test, per se, but it looks like the line in addobjecttoengine…

    std::auto_ptr<FakeSettableFeaturePlugin> plugin (new FakeSettableFeaturePlugin);
    

    …should be…

    std::auto_ptr<FakeFeature> plugin(new FakeSettableFeaturePlugin);
    

    …the same as in FakeApplication‘s constructor. Then there’s no conversion to perform at CheckAddonEngine.cpp:64.

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

Sidebar

Related Questions

I have some class( Window ) without copy constructor (it's private). I can't understand
I cant understand what this warning I get on Xcode is about. Searching for
I found the code from the net in which i cant understand this line:-
I can't seem to understand why I cant pass any values with the following
Trying to understand how CoffeeScript instance and class variable works I came with this
I want extend class which have final constructor (in my case it's SimpleXMLElement), but
This is almost a duplicate question, but I really didn't understand the answer given
I cant seem to find much info on haskells layout features, as I understand
Can't understand why the following takes place: String date = 06-04-2007 07:05; SimpleDateFormat fmt
I can't understand the concept and, first of all, where it belongs. Is it

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.