Ejemplo n.º 1
0
Component<int> getComponentForInstance(int& n) {
  Component<> comp = createComponent()
    .bindInstance(n);
  return createComponent()
    .install(comp)
    .bindInstance(n);
}
Component<int> getComponentForInstance(int& p) {
  Component<> m = createComponent()
    .bindInstance(p);
  return createComponent()
    .registerConstructor<int()>()
    .install(m);
}
Component<int> getComponentForInstance() {
    // Note: don't do this in real code, leaks memory.
    Component<> comp = createComponent()
                       .bindInstance(*(new int(5)));
    return createComponent()
           .install(comp)
           .bindInstance(*(new int(5)));
}
Ejemplo n.º 4
0
Component<int> getComponent() {
  return createComponent()
    .registerConstructor<int()>()
    .registerConstructor<int()>();
}
Ejemplo n.º 5
0
Component<int> getComponent() {
  return createComponent()
    .registerConstructor<int()>()
    .install(getParentComponent());
}
Ejemplo n.º 6
0
Component<ScalerFactory> getScalerComponent() {
  return createComponent()
    .bind<Scaler, ScalerImpl>()
    .registerFactory<ScalerImpl(Assisted<double>)>([](double factor) { return ScalerImpl(factor); });
}
Component<Required<XAnnot, XAnnot>> getComponent() {
  return createComponent();
}
Component<ScalerFactory> getScalerComponent() {
  return createComponent()
    .bind<Scaler, ScalerImpl>()
    .registerFactory<std::unique_ptr<ScalerImpl>(Assisted<double>)>([](double factor) { return std::unique_ptr<ScalerImpl>(new ScalerImpl(factor)); });
}
Component<Required<std::string>, std::string> getComponent() {
  return createComponent();
}
Component<ScalerFactory> getScalerComponent() {
  return createComponent()
    .bind<Scaler, ScalerImpl>()
    .registerFactory<fruit::Annotated<Annotation, ScalerImpl>(Assisted<double>)>([](double) { return (ScalerImpl*)nullptr; });
}
Component<Required<X, X>> getComponent() {
  return createComponent();
}
Component<ScalerFactoryAnnot> getScalerComponent() {
  return createComponent()
    .bind<ScalerAnnot, fruit::Annotated<Annotation, ScalerImpl>>();
}