/*
 * 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";

    StaticModel queryResult = clasp->query(atomGuard);
    if (queryResult.size()){
        for (auto entry: queryResult){
            unsigned int callId;
            Expression exprGuard;
            tie(callId, exprGuard)=ClaspLayer::parse<int, Expression>(entry.second);

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

}} //end of xreate::polymorph
