Пример #1
0
      // static btw.
      void
      http_server::__di_register_services(ioc::container_shared_ptr_t container)
      {
        logtrace << "HEY! that's module-http-server __di_register_services() ;- Hura!";

        typedef ioc::definition<http_server> server_service_t;

        auto http_server_service = std::make_shared<server_service_t>("http.server");

        logtrace << "http_server_service type name : " << http_server_service->get_type_info().pretty_name();

        // Declare the FACTORY functor :
        http_server_service->set_factory_function(
            [](ioc::base_definition::dependencies_map_ref deps) -> http_server_ptr_t {
              logtrace << "YEAH! that's service `http.server` factory functor bein' invoqued !"
                    " (which is quite remarkable, actually)";

              try {
                http_server_ptr_t server_ = std::make_shared<http_server>();

                /*<< Runs the server. >>*/
                //server_.run();

                return server_;
              }
              catch (std::exception &ex) {
                logfatal << "Caught exception at `http.server` service factory lambda (forwarding it).";
                throw ex;
              }
            }
        );

        // Declare a STARTER functor :
#if 0
        http_server_service->set_starter_function(
            [](server_service_t::reference serv) -> bool {
              logtrace << "YEAH! that's service `http.server` factory FUNCTOR bein' invoqued !"
                          " (which is also remarkable)." ;

              logwarn << " » Not instanciating the cpp-netlib server (impl. stalled)";
              //http_server_ptr_t server_ = serv.get_instance();

              logwarn << " » Not starting the cpp-netlib server (impl. stalled)";
              //server_->run();

              return false;
            }
        );
#endif

         //http_server_service->requires<SomeClassB>("world");

         container->register_service( http_server_service );
      }
Пример #2
0
      // static btw.
      void
      BoostAsioService::__di_register_services(
          di::container_shared_ptr_t container
        )
      {
        logtrace << "HEY! that's module-boost-asio __di_register_services() ;- Hura!";

        auto serv = std::make_shared< BoostAsioService >();

        container->register_service(
            //std::make_shared< BoostAsioService >()
            serv
          );
      }