Skip to content
Snippets Groups Projects
Forked from Eclipse Projects / aidge / aidge_core
2817 commits behind the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
GRegex.hpp 1.98 KiB
/********************************************************************************
 * Copyright (c) 2023 CEA-List
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 ********************************************************************************/


#ifndef AIDGE_GREGEX_H_
#define AIDGE_GREGEX_H_

#include <stdexcept>    // for exception, runtime_error, out_of_range
#include <regex>
#include <memory>       // for shared_ptr
#include <algorithm>    // for next_permutation

#include "aidge/graphmatching/Utile.hpp"
#include "aidge/graphmatching/StmFactory.hpp"
#include "aidge/graphmatching/SeqStm.hpp"
#include "aidge/graphmatching/NodeRegex.hpp"
#include "aidge/graphmatching/Match.hpp"


namespace Aidge{

class GRegex {
// __init__(self,nodes_regex:dict,seq_regexps:list)

    StmFactory mStmFab;
    std::vector<SeqStm*> mStmInit;

public:
    GRegex(const std::map<std::string,NodeRegex*>& nodesRegex,std::vector<std::string>& seqRegexps );

    std::set<NodeTmp> matchFromStartNodes(const std::vector<NodeTmp> startNodes,const std::shared_ptr<GraphView> graphToMatch);

    bool walk_validation_all_stm_are_valid(const std::vector<std::vector<SeqStm*>> all_stm);

    bool walk_validation_all_node_read_validate_by_one_stm(const std::vector<std::vector<SeqStm*>> all_stm);

    bool walk_validation_common_nodes_same_tag_for_all_stm(const std::vector<std::vector<SeqStm*>> all_stm);

    std::set<NodeTmp> get_all_validate_nodes(const std::vector<std::vector<SeqStm*>> all_stm);

    std::vector<SeqStm*> getStmInit() const {
        return mStmInit;
    }

    StmFactory getStmFab() const {
        return mStmFab;
    }

    //std::set<std::pair<std::vector<NodeTmp>,std::set<NodeTmp>>> match(const std::shared_ptr<GraphView> graphToMatch);
    Match match(const std::shared_ptr<GraphView> graphToMatch);

};

}
#endif //AIDGE_GREGEX_H_