Giter VIP home page Giter VIP logo

infectorpp's People

Contributors

darelbi avatar

Watchers

 avatar

infectorpp's Issues

duplicate symbol linker issue for Container::~Container (WITH SOLUTION!)

The problem occurs when InfectorContainer.hpp is included in more than one 
compilation unit.

What steps will reproduce the problem?
1. distribute usage of Infector::Container over several compilation units
   (e.g. wanted the creation of the container in main, but the initialization/wiring in another cpp file)
2. compile & link => duplicate symbol error for the Container DTor


What version of the product are you using? On what operating system?
latest release : 1.0.1

Please provide any additional information below.

The issue is easily solved when the destructor is declared and defined "inline".
Add "inline" to the ~Container declaration within InfectorContainer.hpp and 
also to the definition within "Infector_private.hpp". 

The problem occurs because the destructor is the only non-template function 
defined within a header file.


Original issue reported on code.google.com by [email protected] on 8 May 2014 at 3:08

noexcept error in VS 2013

What steps will reproduce the problem?
1. Compile in VS 2013
2.
3.

What is the expected output? What do you see instead?
Many errors, starting with:
error C3646: 'noexcept' : unknown override specifier    

What version of the product are you using? On what operating system?
1.0.1 on windows 8.1

Please provide any additional information below.
Some talk about the issue here but I haven't figured how to to implement a fix: 
http://stackoverflow.com/questions/18387640/how-to-deal-with-noexcept-in-visual-
studio


Original issue reported on code.google.com by [email protected] on 11 Apr 2014 at 3:22

Infectorpp improvements

Hi Oliveri,

first of all I would like to say that I really like your work.
I'm using your IoC container in a Visual C++ project (Visual Studio 2013). To 
get it to compile I've had to make a few adjustments:

1. In the InfectorExceptions.hpp file I had to replace the const char* for the 
message variable with std::string and the return statement with 
message.c_str(). Example:

class ExRecursionLimit: public std::exception{
        std::string message =
        "Reached recursion limit. Probable cause: circular dependency";
    public:
        virtual const char* what() const NOEXCEPT{
            return message.c_str();
        }
    };


2. In the InfectorHelper.hpp file I had to comment out some lines in the 
type_test() method:
template <typename T, typename... Contracts>
    bool type_tests(){

        //prevent service locator
        static_assert( !std::is_same<T,Infector::Container>::value
                      , "Cannot Inject Infector::Container!");

        //prevent service locator
        static_assert( !std::is_base_of<Infector::Container,T>::value
                      , "Cannot Inject Infector::Container or its subclasses!");

        static_assert(  sizeof...(Contracts)>0 //if no contracts don't use "As"
                      , " There must be at least 1 interface ");
        /*
        static_assert(  recursiveTest<std::is_abstract<Contracts>...>()
                      , " Contracts have to be abstract");

        static_assert(  recursiveTest<std::is_base_of<Contracts,T>...>()
                      , " Contracts must be base classes for T");
*/
        static_assert(  std::is_destructible<T>::value
                      , " T must be destructible");

        return true;
    }

After the changes I was able to use your IoC. Maybe you have the time to take a 
look on this changes.

I have also some recommendations for additional features:

For unit testing sometimes it's necessary to mock a class and add additional 
behaviour to it. For example mocking a factory for testing purposes and 
implement an additional method for setting the returned object from the factory.

At the moment I have to build the factory and afterwards manually cast it (by 
dynamic_cast) to my mock class. It would be nice to have a build in method 
called buildAs<Interface, ConcreteClass>. This method automatically does the 
cast to the concrete class and returns an object.

Another issue I came across is, that when using CppUnitTestFramework from 
Microsoft, currently it's not possible to create a static instance of the ioc 
container for each testclass. To fix this I changed following methods in 
InfectorContainer.hpp:

template<typename Dummy>
    void setKnownSizeForType( std::type_index t, bool known, int size);
    template<typename Dummy>
    void processRecursionWeb();

I also changed the calls to this methods and passed your DummyClass as template 
parameters.

kind regards
Michael Bischof

Original issue reported on code.google.com by [email protected] on 8 Sep 2014 at 10:22

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.