Tao Language for Scripting and Computing

Documentation for Tao C++ Types and Plugin
Home Page
Documents
Downloads
Licensing
MailLists
Forums
FAQ



SourceForge Logo

Support This Project
Tao C++ Types and Plugin: taoPlugin.h Source File

taoPlugin.h

00001 
00003 /*
00004    This file is a part of an interpreter for Tao, a high level 
00005    object-oriented computing and scripting language.
00006    
00007    Copyright (C) 2004-2005, Fu Limin.
00008    Contact: fu.limin.tao@gmail.com, limin.fu@ircc.it
00009 
00010    This program is free software; you can redistribute it and/or modify
00011    it under the terms of the GNU General Public License as published by
00012    the Free Software Foundation; either version 2 of the License, or
00013    (at your option) any later version.
00014 
00015    This program is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018    GNU General Public License for more details.
00019 
00020    You should have received a copy of the GNU General Public License
00021    along with this program; if not, write to the Free Software
00022    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 */
00025 #ifndef TAO_PLUGIN_H
00026 #define TAO_PLUGIN_H
00027 
00028 #include<iostream>
00029 
00031 //
00032 //  Please read the following comments carefully 
00033 //  to see how to define a Tao plugin class.
00034 //
00036 
00037 #ifdef WIN32 
00038 #define TAO_DLL __declspec(dllexport) 
00039 #else
00040 #define TAO_DLL 
00041 #endif
00042 
00045 #define TAO_PLUGIN(x) public:\
00046     x(char*y){ _Tao_Plugin_Proxy.addPlugin(this,y); } private:
00047 
00049 #define TAO_PLUGIN_PROXY TAO_DLL TaoPluginProxy _Tao_Plugin_Proxy;
00050 
00053 #define INIT_TAO_PLUGIN TAO_PLUGIN_PROXY
00054 
00058 
00059 #include"taoCpptype.h"
00060 
00061 using namespace std;
00062 
00063 class TaoPlugin;
00064 
00066 
00069 class TaoPluginProxy
00070 {
00071     TaoPlugin **plugins;
00072     char **names;
00073 
00074     int size;
00075     int nplg;
00076     
00077     public:
00078     TaoPluginProxy(){ size=nplg=0; }
00079 
00080     void addPlugin(TaoPlugin *plg, char *name){
00081         if( nplg+2 > size ){
00082             size += 100;
00083             plugins=(TaoPlugin**)realloc( plugins, size*sizeof(TaoPlugin*) );
00084             names=(char**)realloc( names, size*sizeof(char*) );
00085         }
00086         plugins[ nplg ] = plg;
00087         names[ nplg ] = name;
00088         nplg++;
00089     }
00090     TaoPlugin** getPlugins(){ return plugins; }
00091     char** getNames(){ return names; }
00092     int getPlgNumber(){ return nplg; }
00093 };
00094 
00095 extern TaoPluginProxy _Tao_Plugin_Proxy;
00096 
00098 
00142 class TaoPlugin : public TcBase
00143 {
00144     public:
00145     TaoPlugin(){}
00146     virtual ~TaoPlugin(){}
00147     
00149     short type()const{ return TAO_PLUGIN; }
00152     virtual short rtti()const{ return TAO_PLUGIN; }
00153 
00155     virtual TaoPlugin* newObject( TcArray *param=0 ){
00156         return new TaoPlugin(); 
00157     }
00159     virtual void runMethod( const char *funame, TcArray *in=0,TcArray *out=0)
00160     {
00161         cout<<"TaoPlugin::runMethod() is not reimplemented.\n";
00162         // To reimplement, add:
00163         /*
00164         if( strcmp(funame,"test")==0 ){
00165             test(...);
00166         }else if(...){
00167             ...
00168         }
00169         */
00170     }
00173     virtual void print( ostream *out=0, bool reserved=0 ){
00174         if( out==0 ) out=&cout;
00175         *out<<"TaoPlugin"<<this;
00176     }
00179     virtual void help( ostream *out=0 ){
00180         if( out==0 ) out=&cout;
00181         *out<<"No method is provided through TaoPlugin::runMethod().\n";
00182     }
00183 };
00184 
00185 #endif

Generated on Sun Apr 24 23:42:17 2005 for Tao C++ Types and Plugin by doxygen 1.3.6
This website is maintained by Fu Limin.
Copyright(C) 2004-2005, Fu Limin.
Email: fu [dot] limin [dot] tao [at] gmail [dot] com