celix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [celix] pnoltes opened a new pull request #310: Adds initial impl for the C++ headers only wrappers
Date Sun, 03 Jan 2021 20:39:32 GMT

pnoltes opened a new pull request #310:
URL: https://github.com/apache/celix/pull/310


   ### WIP
   This PR is still work in progress.
   
   ### TODO
   
   - [ ] Update documentation for C++ wrapper usage
   - [ ] Update C++ examples (dynamic services & locking)
   - [ ] Add support for service factories
   - [ ] Add a Celix exception and use this.
   
   ### Intro 
   ThisPR introduces a (header only) C++ wrapper for the C Celix framework.
   
   A while back the idea was to introduce a C++ framework of Celix. 
   This idea has been abandoned (a new C++20 framework should be a different project).
   
   To make life easier when using C++ with Celix this PR introduces C++ wrappers around most
of the C Celix concepts:
    - Bundle Context
    - Bundle
    - Framework
    - Properties
    - Filter
    - Service Registration
    - Service Tracker
    - Bundle Tracker
    - Meta Tracker (service tracker tracker)
    - BundleActivator
   
   ### Async
   The C++ wrapper works on top of the async C celix API; this means that creating service
registration and trackers can be done inside a lock. 
   This also means that the C++ object wrapping service registration/trackers have a state
that will change (e.g. REGISTERING->REGISTERED->UNREGISTERING->UNREGISTERED).
   
   Examples:
   ```C++
       celix::Properties props{};
       props["key1"] = "value1";
       auto svc = std::make_shared<CInterface>(CInterface{nullptr, nullptr});
       auto svcReg1 = ctx->registerService<CInterface>(svc)
               .setProperties(props)
               .addProperty("key2", "value2")
               .build();
   ```
   ```C++
       std::atomic<int> count{0};
       auto tracker3 = ctx->trackServices<CInterface>()
               .addAddCallback([&count](const std::shared_ptr<CInterface>&)
{
                   count += 1;
               })
               .addRemCallback([&count](const std::shared_ptr<CInterface>&)
{
                   count += 1;
               })
               .build();
   ```
   
   
   ### Fluent Builder API
   Most call in the C++ BundleContext use a fluent builder API to make configuring complex
service registration, trackers, etc more concise and readable. 
   
   ### BundleActivator Changes
   The CELIX_GEN_CXX_BUNDLE_ACTIVATOR macro has change so that it still support the C++ DepedencyManager
activator, but also support bundle activator which take a `std::shared_ptr<celix::BundleContext>`
as argument.
   
   
   
   
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



Mime
View raw message