1 2// Licensed under the Apache License, Version 2.0 (the "License"); 3// you may not use this file except in compliance with the License. 4// You may obtain a copy of the License at 5// 6// http://www.apache.org/licenses/LICENSE-2.0 7// 8// Unless required by applicable law or agreed to in writing, software 9// distributed under the License is distributed on an "AS IS" BASIS, 10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11// See the License for the specific language governing permissions and 12// limitations under the License. 13// 14// Copyright 2005-2010 Google, Inc. 15// Author: jpr@google.com (Jake Ratkiewicz) 16 17#include <fst/script/fst-class.h> 18#include <fst/script/script-impl.h> 19#include <fst/script/compose.h> 20 21namespace fst { 22namespace script { 23 24 25void Compose(const FstClass &ifst1, const FstClass &ifst2, 26 MutableFstClass *ofst, ComposeFilter compose_filter) { 27 if (!ArcTypesMatch(ifst1, ifst2, "Compose") || 28 !ArcTypesMatch(*ofst, ifst1, "Compose")) return; 29 30 ComposeArgs1 args(ifst1, ifst2, ofst, compose_filter); 31 Apply<Operation<ComposeArgs1> >("Compose", ifst1.ArcType(), &args); 32} 33 34void Compose(const FstClass &ifst1, const FstClass &ifst2, 35 MutableFstClass *ofst, const ComposeOptions &copts) { 36 if (!ArcTypesMatch(ifst1, ifst2, "Compose") || 37 !ArcTypesMatch(*ofst, ifst1, "Compose")) return; 38 39 ComposeArgs2 args(ifst1, ifst2, ofst, copts); 40 Apply<Operation<ComposeArgs2> >("Compose", ifst1.ArcType(), &args); 41} 42 43REGISTER_FST_OPERATION(Compose, StdArc, ComposeArgs1); 44REGISTER_FST_OPERATION(Compose, LogArc, ComposeArgs1); 45REGISTER_FST_OPERATION(Compose, Log64Arc, ComposeArgs1); 46REGISTER_FST_OPERATION(Compose, StdArc, ComposeArgs2); 47REGISTER_FST_OPERATION(Compose, LogArc, ComposeArgs2); 48REGISTER_FST_OPERATION(Compose, Log64Arc, ComposeArgs2); 49 50} // namespace script 51} // namespace fst 52