dbusinstance.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (C) 2004-2017 Savoir-faire Linux Inc.
  3. *
  4. * Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. */
  20. #ifndef __RING_DBUSINSTANCE_H__
  21. #define __RING_DBUSINSTANCE_H__
  22. #include <functional>
  23. #if __GNUC__ >= 5 || (__GNUC__ >=4 && __GNUC_MINOR__ >= 6)
  24. #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
  25. #endif
  26. #include "dbus_cpp.h"
  27. #pragma GCC diagnostic ignored "-Wignored-qualifiers"
  28. #pragma GCC diagnostic ignored "-Wunused-parameter"
  29. #include "dbusinstance.adaptor.h"
  30. #pragma GCC diagnostic warning "-Wignored-qualifiers"
  31. #pragma GCC diagnostic warning "-Wunused-parameter"
  32. #if __GNUC__ >= 5 || (__GNUC__ >=4 && __GNUC_MINOR__ >= 6)
  33. #pragma GCC diagnostic warning "-Wunused-but-set-variable"
  34. #endif
  35. class DBusInstance :
  36. public cx::ring::Ring::Instance_adaptor,
  37. public DBus::IntrospectableAdaptor,
  38. public DBus::ObjectAdaptor
  39. {
  40. public:
  41. typedef std::function<void()> OnNoMoreClientFunc;
  42. DBusInstance(DBus::Connection& connection,
  43. const OnNoMoreClientFunc& onNoMoreClientFunc);
  44. void Register(const int32_t& pid, const std::string& name);
  45. void Unregister(const int32_t& pid);
  46. private:
  47. OnNoMoreClientFunc onNoMoreClientFunc_;
  48. int count_;
  49. };
  50. #endif // __RING_DBUSINSTANCE_H__