Coder Social home page Coder Social logo

infectorpp's People

Contributors

alexander-irrgang avatar darelbi avatar vitefalcon avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

infectorpp's Issues

Hierarchical containers (HC)

Actually multiple containers are possible, but each container don't
see each other... Then provide a hierachical structure where
children can see dependencies of parents? (or eventually change them?)
Or better some dependencies may be hided by a internal container
so that private stuff can't be accidentally injected (usefull for
bit projects and allows a primitive form of contextual binding)

Would that be usefull for someone?

Reduce compile time?

Not really required for now. But is theorically possible,
most methods works on the type std::type_index rather than a generic type T, so
much of the logic can be moved to a NON-templated class. This will be done
without breaking existing interface of course. but not now. There are most
interesting things to do than refactoring what is currently working very nice:)

Custom allocation

When A dependends on B and B depends on C the smartest way to allocate A is by
reserving a memory chunk of lenght A+B+C (Eventually alignin it) and then
constructing A,B,C using the placement new

raw chunk:

|---------------------------|
after placement new:
|-A-|-------B-------|---C---|

The natural way to do this construction is to use the evaluation order of
constructors that make implemenation easy (and possibly fast).

This require a new smart pointer ( shared_ptr and unique_ptr provides some
mechanism for custom deleters, but that's expensive).

And the name for the new pointer will be ..

infect_ptr ?

then infect_ptr will be a "replacement" for unique_ptr
(maybe inject_ptr is better name XD)

Fix incompatibilities with Visual Studio 2013

  1. constexpr is not supported in Visual Studio 2013
  2. static_assert was not compatible with the current implementation of recursive trait_test (missing constexpr)
  3. There is a bug with std::unique_ptr that prevents usage in VIsual Studio 2013

--> Try to fix all bugs or provide workaround

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

Exceptions are just temporary.

In future exception messages will look like:
"Cannot wire constructor for FooBar, because type 'FooBar' was not bound
(to bind a type use Infector::Container.bind...< ... >() )"

or
"Cannot build FooBar, an exception was thrown by its constructor"

Integrate with GTest for testing

Current test-cases use assert from #include <cassert> for test assertions. AFAIK, asserts are disabled in Release build. We need to be able to test in both Debug and Release configurations.

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

Thanks for moving my repo to Github

Since I don't know how long will take for version 2 to become published I just putted a notice that official repo for version 1 is now the one you moved here :D

I'll keep an eye to give some help or to integrate forward some stuff in v2 :)

Thanks!

Construct arrays of objects?

it's implicit that "Single" types can't be
costructed into arrays, so there will not be "buildSingleArray" in any case.

auto myArray = ioc.buildArray<IFoo>(50); 

for(int i=0; i<50; i++)
 myArray[i]; //would that be usefull? would that be misused?

Moduralize test cases

Currently, all test-cases are in a single file. Tests should ideally be separated out to different files so that the test setup is clear and they are maintainable. To get this done we need to tackle #6 first.

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

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.