/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * File:   polymorph.cpp
 * Author: pgess <v.melnychenko@xreate.org>
 *
 * Created on November 9, 2017, 12:14 PM
 */

#include "polymorph.h"

using namespace std;
namespace xreate { namespace polymorph {

void
PolymorphQuery::init(ClaspLayer* clasp){
    const std::string& atomGuard = "dfa_callguard";

    ClaspLayer::ModelFragment query = clasp->query(atomGuard);
    if (query){
        for (auto entry = query->first; entry!=query->second; ++entry){
            unsigned int callId;
            Expression exprGuard;

            tie(callId, exprGuard)=ClaspLayer::parse<int, Expression>(entry->second);

            Attachments::put<PolymorphGuard>(callId, exprGuard);
        }
    }
}

}} //end of xreate::polymorph
