Apache Celix  2.3.0
An implementation of the OSGi specification adapted to C and C++
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
celix::AbstractTracker Class Referenceabstract

The AbstractTracker class is the base of all C++ Celix trackers. More...

#include <Trackers.h>

Inheritance diagram for celix::AbstractTracker:
Inheritance graph
[legend]

Public Member Functions

 AbstractTracker (std::shared_ptr< celix_bundle_context_t > _cCtx)
 
virtual ~AbstractTracker () noexcept=default
 
bool isOpen () const
 Check if the tracker is open (state == OPEN) More...
 
TrackerState getState () const
 Get the current state of the tracker. More...
 
void close ()
 Close the tracker (of the state is not CLOSED or CLOSING). More...
 
virtual void open ()=0
 Open the tracker (if the state is not OPEN or OPENING). More...
 
void wait () const
 Wait until a service tracker is completely OPEN or CLOSED. More...
 

Protected Member Functions

void waitIfAble () const
 Wait (if not on the Celix event thread) for the tracker to be OPEN or CLOSED. More...
 

Static Protected Member Functions

template<typename T >
static std::function< void(T *)> delCallback ()
 

Protected Attributes

const std::shared_ptr< celix_bundle_context_t > cCtx
 
std::mutex mutex {}
 
long trkId {-1L}
 
TrackerState state {TrackerState::CLOSED}
 

Detailed Description

The AbstractTracker class is the base of all C++ Celix trackers.

It defines how trackers are closed and manages the tracker state.

This class can be used to create a vector of different (shared ptr) trackers (i.e. ServiceTracker, BundleTracker, MetaTracker).

AbstractTracker <--------------------------------— ^ | | | | | GenericServiceTracker BundleTracker MetaTracker ^ | ServiceTracker

Note
Thread safe.

Constructor & Destructor Documentation

◆ AbstractTracker()

celix::AbstractTracker::AbstractTracker ( std::shared_ptr< celix_bundle_context_t >  _cCtx)
inlineexplicit

◆ ~AbstractTracker()

virtual celix::AbstractTracker::~AbstractTracker ( )
virtualdefaultnoexcept

Member Function Documentation

◆ close()

void celix::AbstractTracker::close ( )
inline

Close the tracker (of the state is not CLOSED or CLOSING).

This will be done sync so then the close() method return the tracker is closed and all the needed callbacks have been called.

◆ delCallback()

template<typename T >
static std::function<void(T*)> celix::AbstractTracker::delCallback ( )
inlinestaticprotected

◆ getState()

TrackerState celix::AbstractTracker::getState ( ) const
inline

Get the current state of the tracker.

◆ isOpen()

bool celix::AbstractTracker::isOpen ( ) const
inline

Check if the tracker is open (state == OPEN)

◆ open()

virtual void celix::AbstractTracker::open ( )
pure virtual

Open the tracker (if the state is not OPEN or OPENING).

This is done async, meaning that the actual opening of the tracker will be done a a Celix event processed on the Celix event thread.

Exceptions
celix::Exception

Implemented in celix::MetaTracker, celix::BundleTracker, and celix::GenericServiceTracker.

◆ wait()

void celix::AbstractTracker::wait ( ) const
inline

Wait until a service tracker is completely OPEN or CLOSED.

This method cannot be called on the Celix event thread.

◆ waitIfAble()

void celix::AbstractTracker::waitIfAble ( ) const
inlineprotected

Wait (if not on the Celix event thread) for the tracker to be OPEN or CLOSED.

Member Data Documentation

◆ cCtx

const std::shared_ptr<celix_bundle_context_t> celix::AbstractTracker::cCtx
protected

◆ mutex

std::mutex celix::AbstractTracker::mutex {}
mutableprotected

◆ state

TrackerState celix::AbstractTracker::state {TrackerState::CLOSED}
protected

◆ trkId

long celix::AbstractTracker::trkId {-1L}
protected

The documentation for this class was generated from the following file: