/////////////////////////////////////////////////////////////////#include \"Operator.hh\"#include \"NDimArray.hh\"#include \"SetOfPoints.hh\"
/////////////////////////////////////////////////////////////////class minima : public Operator {public:
minima(); // default constructor ~minima(); // destructor // required member functions void init( PParam *paramSeq );
PUDT *next( JNIEnv *env, jobject obj );
// other member functionsprivate:
// parameter info
long mSmooth; // fit minima to a spline? 1-Yes; 0-No // state information
int mCount; // frame count
int mNumMin; // External variables used in minutil.cc // other methods . . .};
// handle to minima
typedef minima* Pminima;
/////////////////////////////////////////////////////////////////#endif
// User-defined operator --
// standard to all operators except the operator nameimport edu.ucla.ConquestV2.user.*;import java.io.*;
public class minima implements Operator{
// load shared library of operator in C++ static { System.loadLibrary( \"minima\" ); }
// pointer to C++ class
protected int mPeer = 0;
protected UDTInput mInBufSeq[] = null;
// constructor
public minima() {
// create a C++ operator object mPeer = (int)nativeCreate(); }
// native methods linked to C++
public static native int nativeCreate();
public native void nativeInit( Param[] params ); public native UDT[] nativeNext(); public native void nativeClose();
public native boolean nativeIsSuspendable(); public native byte[] nativeGetContext();
public native void nativeSetContext( byte[] ); // other methods . . .}
(a) minima.hh(b) minima.java
BRIDGETranslatorWellKnownDataTypesinit()next()close(). . .toField()fromField(). . .AbstractionImplementationtwoDimArraytoField()fromField(). . .setOfPointstoField()fromField(). . ....#ifndef SETOFPOINTS_HH#define SETOFPOINTS_HH#include \"UDT.hh\"// user-defined type definitions -- SetOfPointsclass SetOfPoints : public UDT {public: // constructor SetOfPoints( long year, long timeframe, long numpoints ); // two required member functions static SetOfPoints *fromByteArray( char * ); char *toByteArray(); // other member functions long getYear() const; // return the year long getTimeFrame() const; // return the time frame long getNumPoints() const; // return the number of points . . .private: long mNumPoints; // number of data items long mYear; // year long mTimeFrame; // time frame float *mX; // x-axis float *mY; // y-axis float *mValue; // value};// handle for SetOfPointstypedef SetOfPoints* PSetOfPoints;#endif// User-defined type import edu.ucla.ConquestV2.user.*;public class SetOfPoints extends UDT{ static { System.loadLibrary( \"SetOfPoints\" ); } // pointer to C++ class protected int mPeer = 0; // constructor - with C++ object reference specification public SetOfPoints( int peer ) { mPeer = peer; } // A required method for C++ interface public int getCPeer() { return( mPeer ); } // required native methods public static native int nativeFromByteArray( byte[] data ); public native byte[] nativeToByteArray(); // two methods required by the execution environment public static UDT fromByteArray( byte[] data ) { return( new SetOfPoints( nativeFromByteArray( data ) ) ); } public byte[] toByteArray() { return( nativeToByteArray() ); } // methods from C++ definition public static native int createNew( int year, int timeframe, int numpoints ); public native long getYear(); // return the year public native long getTimeFrame(); // return the time frame public native long getNumPoints(); // return the number of points . . .}(a) SetOfPoints.hh(b) SetOfPoints.java
因篇幅问题不能全部显示,请点此查看更多更全内容