/*******************************************************************************
 * Copyright (C) 2017-2026 Theodore Chang
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/

#include "AmplitudeRecorder.h"

#include <Domain/DomainBase.h>
#include <Domain/Factory.hpp>
#include <Load/Amplitude/Amplitude.h>

void AmplitudeRecorder::record_impl(const shared_ptr<DomainBase>& D) {
    const sp_d auto current_time = D->get_factory()->get_current_time();

    for(const auto I : object_tag) insert({{D->get<Amplitude>(I)->get_amplitude(current_time)}}, I);

    insert(current_time);
}

void AmplitudeRecorder::initialize(const shared_ptr<DomainBase>& D) {
    for(const auto I : reference_tag)
        if(!D->find<Amplitude>(I)) {
            suanpan_warning("Amplitude {} is not available/active, recorder {} is disabled.\n", I, get_tag());
            D->disable_recorder(get_tag());
            return;
        }

    Recorder::initialize(D);
}

void AmplitudeRecorder::print() { suanpan_info("A recorder to record amplitudes.\n"); }
