1/* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef LATINIME_GESTURE_DECODER_WRAPPER_H 18#define LATINIME_GESTURE_DECODER_WRAPPER_H 19 20#include <stdint.h> 21#include "defines.h" 22#include "incremental_decoder_interface.h" 23 24namespace latinime { 25 26class UnigramDictionary; 27class BigramDictionary; 28class ProximityInfo; 29 30class GestureDecoderWrapper : public IncrementalDecoderInterface { 31 public: 32 GestureDecoderWrapper(const int maxWordLength, const int maxWords) 33 : mIncrementalDecoderInterface(getGestureDecoderInstance(maxWordLength, maxWords)) { 34 } 35 36 virtual ~GestureDecoderWrapper() { 37 delete mIncrementalDecoderInterface; 38 } 39 40 int getSuggestions(ProximityInfo *pInfo, void *traverseSession, int *inputXs, int *inputYs, 41 int *times, int *pointerIds, int *codes, int inputSize, int commitPoint, 42 unsigned short *outWords, int *frequencies, int *outputIndices, 43 int *outputTypes) const { 44 if (!mIncrementalDecoderInterface) { 45 return 0; 46 } 47 return mIncrementalDecoderInterface->getSuggestions( 48 pInfo, traverseSession, inputXs, inputYs, times, pointerIds, codes, 49 inputSize, commitPoint, outWords, frequencies, outputIndices, outputTypes); 50 } 51 52 static void setGestureDecoderFactoryMethod( 53 IncrementalDecoderInterface *(*factoryMethod)(int, int)) { 54 sGestureDecoderFactoryMethod = factoryMethod; 55 } 56 57 private: 58 DISALLOW_IMPLICIT_CONSTRUCTORS(GestureDecoderWrapper); 59 static IncrementalDecoderInterface *getGestureDecoderInstance(int maxWordLength, int maxWords) { 60 if (sGestureDecoderFactoryMethod) { 61 return sGestureDecoderFactoryMethod(maxWordLength, maxWords); 62 } 63 return 0; 64 } 65 66 static IncrementalDecoderInterface *(*sGestureDecoderFactoryMethod)(int, int); 67 IncrementalDecoderInterface *mIncrementalDecoderInterface; 68}; 69} // namespace latinime 70#endif // LATINIME_GESTURE_DECODER_WRAPPER_H 71