d2_controller.cc 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #include <config.h>
  15. #include <d2/d2_controller.h>
  16. #include <d2/d2_process.h>
  17. #include <d2/spec_config.h>
  18. #include <stdlib.h>
  19. namespace isc {
  20. namespace d2 {
  21. /// @brief Defines the application name, this is passed into base class
  22. /// it may be used to locate configuration data and appears in log statement.
  23. const char* D2Controller::d2_app_name_ = "DhcpDdns";
  24. /// @brief Defines the executable name. This is passed into the base class
  25. const char* D2Controller::d2_bin_name_ = "kea-dhcp-ddns";
  26. DControllerBasePtr&
  27. D2Controller::instance() {
  28. // If the instance hasn't been created yet, create it. Note this method
  29. // must use the base class singleton instance methods.
  30. if (!getController()) {
  31. DControllerBasePtr controller_ptr(new D2Controller());
  32. setController(controller_ptr);
  33. }
  34. return (getController());
  35. }
  36. DProcessBase* D2Controller::createProcess() {
  37. // Instantiate and return an instance of the D2 application process. Note
  38. // that the process is passed the controller's io_service.
  39. return (new D2Process(getAppName().c_str(), getIOService()));
  40. }
  41. D2Controller::D2Controller()
  42. : DControllerBase(d2_app_name_, d2_bin_name_) {
  43. // set the spec file either from the environment or
  44. // use the production value.
  45. if (getenv("KEA_FROM_BUILD")) {
  46. setSpecFileName(std::string(getenv("KEA_FROM_BUILD")) +
  47. "/src/bin/d2/dhcp-ddns.spec");
  48. } else {
  49. setSpecFileName(D2_SPECFILE_LOCATION);
  50. }
  51. }
  52. D2Controller::~D2Controller() {
  53. }
  54. }; // end namespace isc::d2
  55. }; // end namespace isc