d2_controller.cc 2.31 KB
Newer Older
1
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
2 3 4 5 6 7 8 9 10 11 12 13 14
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.

15 16
#include <config.h>

17 18 19 20
#include <d2/d2_controller.h>
#include <d2/d2_process.h>
#include <d2/spec_config.h>

21 22
#include <stdlib.h>

23 24 25
namespace isc {
namespace d2 {

26
/// @brief Defines the application name, this is passed into base class
27 28
/// it may be used to locate configuration data and appears in log statement.
const char* D2Controller::d2_app_name_ = "DhcpDdns";
29 30

/// @brief Defines the executable name. This is passed into the base class
31
const char* D2Controller::d2_bin_name_ = "kea-dhcp-ddns";
32

33
DControllerBasePtr&
34
D2Controller::instance() {
35
    // If the instance hasn't been created yet, create it.  Note this method
36
    // must use the base class singleton instance methods.
37
    if (!getController()) {
38 39
        DControllerBasePtr controller_ptr(new D2Controller());
        setController(controller_ptr);
40 41 42 43 44 45 46 47
    }

    return (getController());
}

DProcessBase* D2Controller::createProcess() {
    // Instantiate and return an instance of the D2 application process. Note
    // that the process is passed the controller's io_service.
48
    return (new D2Process(getAppName().c_str(), getIOService()));
49 50 51
}

D2Controller::D2Controller()
52
    : DControllerBase(d2_app_name_, d2_bin_name_) {
53
    // set the spec file either from the environment or
54
    // use the production value.
Tomek Mrugalski's avatar
Tomek Mrugalski committed
55 56
    if (getenv("KEA_FROM_BUILD")) {
        setSpecFileName(std::string(getenv("KEA_FROM_BUILD")) +
57
            "/src/bin/d2/dhcp-ddns.spec");
58 59 60 61 62 63 64 65 66 67
    } else {
        setSpecFileName(D2_SPECFILE_LOCATION);
    }
}

D2Controller::~D2Controller() {
}

}; // end namespace isc::d2
}; // end namespace isc