1 /* 2 * Copyright 2016, Rene Gollent, rene@gollent.com. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef CONNECTION_CONFIG_HANDLER_ROSTER_H 6 #define CONNECTION_CONFIG_HANDLER_ROSTER_H 7 8 #include <Locker.h> 9 #include <ObjectList.h> 10 #include <String.h> 11 12 #include "ConnectionConfigView.h" 13 14 15 class ConnectionConfigHandler; 16 class TargetHostInterfaceInfo; 17 18 19 class ConnectionConfigHandlerRoster { 20 public: 21 ConnectionConfigHandlerRoster(); 22 virtual ~ConnectionConfigHandlerRoster(); 23 24 static ConnectionConfigHandlerRoster* Default(); 25 static status_t CreateDefault(); 26 static void DeleteDefault(); 27 28 bool Lock() { return fLock.Lock(); } 29 void Unlock() { fLock.Unlock(); } 30 31 status_t Init(); 32 33 bool HasHandlerFor(TargetHostInterfaceInfo* info) 34 const; 35 36 status_t CreateConfigView(TargetHostInterfaceInfo* info, 37 ConnectionConfigView::Listener* listener, 38 ConnectionConfigView*& _view) const; 39 40 private: 41 typedef BObjectList<ConnectionConfigHandler> HandlerList; 42 43 private: 44 bool _GetHandler(const BString& name, 45 ConnectionConfigHandler*& _handler) const; 46 status_t _RegisterHandlers(); 47 48 private: 49 BLocker fLock; 50 static ConnectionConfigHandlerRoster* sDefaultInstance; 51 52 HandlerList fConfigHandlers; 53 }; 54 55 #endif // CONNECTION_CONFIG_HANDLER_ROSTER_H 56