- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

# mexlog.h

    00001 #include "../bdm/stat/loggers_ui.h"
    00002
    00003 int mxReplaceFieldNM(mxArray *X,const char * fname,mxArray *X1)
    00004 {
    00005         mxArray *Old;
    00006         int i;
    00007
    00008         if((i=mxGetFieldNumber(X,fname))==-1)
    00009         {
    00010                 if((i=mxAddField(X,fname))==-1) return i;
    00011
    00012         }
    00013
    00014         Old=mxGetFieldByNumber(X,0,i);
    00015         if(Old)mxDestroyArray(Old);
    00016         mxSetFieldByNumber(X,0,i,X1);
    00017         return i;
    00018
    00019 };
    00020
    00021 class mexlog : public memlog{
    00022         public:
    00024         mexlog(int maxlen): memlog(maxlen){};
    00026         mxArray* toCell(){
    00027                 mxArray* tmp = mxCreateStructMatrix(1,1,0,NULL);
    00028
    00029                 //copy vectors to mxStruct
    00030                 for (int i=0; i<names.length();i++){
    00031                         mat& M=vectors(i);
    00032                         mxArray* fld=mxCreateDoubleMatrix(M.rows(), M.cols(), mxREAL);
    00033                         mat2mxArray(M,fld);
    00034                         mxReplaceFieldNM(tmp, names(i).c_str(), fld);
    00035                 }
    00036                 return tmp;
    00037         }
    00038 };
    00039
    00040 class UImexlog: public UIbuilder{
    00041         public:
    00042                 UImexlog():UIbuilder("mexlog"){};
    00043                 bdmroot* build(Setting &S) const{
    00044                         return new mexlog(S["maxlen"]);
    00045                 };
    00046 };
    00047 UIREGISTER(UImexlog);