OpcodeBase.hpp

Go to the documentation of this file.
00001 #ifndef OPCODE_BASE_H
00002 #define OPCODE_BASE_H
00003 #ifndef MSVC
00004 #include "csdl.h"
00005 #include <cstdarg>
00006 #else
00007 #include <cmath>
00008 #include "csdl.h"
00009 #endif
00010 
00037 template<typename T>
00038 class OpcodeBase
00039 {
00040 public:
00041   int init(CSOUND *csound)
00042   {
00043     return NOTOK;
00044   }
00045   static int init_(CSOUND *csound, void *opcode_)
00046   {
00047     T *opcode = reinterpret_cast<T *>(opcode_);
00048     if (!csound->reinitflag && !csound->tieflag)
00049       csound->RegisterDeinitCallback(csound,
00050                                      &opcode->h, OpcodeBase<T>::noteoff_);
00051     return opcode->init(csound);
00052   }
00053   int kontrol(CSOUND *csound)
00054   {
00055     return NOTOK;
00056   }
00057   static int kontrol_(CSOUND *csound, void *opcode)
00058   {
00059     return reinterpret_cast<T *>(opcode)->kontrol(csound);
00060   }
00061   int audio(CSOUND *csound)
00062   {
00063     return NOTOK;
00064   }
00065   static int audio_(CSOUND *csound, void *opcode)
00066   {
00067     return reinterpret_cast<T *>(opcode)->audio(csound);
00068   }
00069   int noteoff(CSOUND *csound)
00070   {
00071     return OK;
00072   }
00073   static int noteoff_(CSOUND *csound, void *opcode)
00074   {
00075     return reinterpret_cast< OpcodeBase<T> *>(opcode)->noteoff(csound);
00076   }
00077   void log(CSOUND *csound, const char *format,...)
00078   {
00079     va_list args;
00080     va_start(args, format);
00081     if(csound) {
00082       csound->MessageV(csound, 0, format, args);
00083     }
00084     else {
00085       vfprintf(stdout, format, args);
00086     }
00087     va_end(args);
00088   }
00089   void warn(CSOUND *csound, const char *format,...)
00090   {
00091     va_list args;
00092     va_start(args, format);
00093     if(csound) {
00094       if(csound->GetMessageLevel(csound) & WARNMSG ||
00095          csound->GetDebug(csound)) {
00096         csound->MessageV(csound, CSOUNDMSG_WARNING, format, args);
00097       }
00098     }
00099     else {
00100       vfprintf(stdout, format, args);
00101     }
00102     va_end(args);
00103   }
00104   OPDS h;
00105 };
00106 
00107 #endif
00108 

Generated on Tue Apr 14 11:00:49 2009 for Csound and CsoundAC by  doxygen 1.5.8