interpreter.h

Go to the documentation of this file.
00001 
00015 #ifndef SMPINTERPRETER_H
00016 #define SMPINTERPRETER_H
00017 
00018 #include <stdlib.h>
00019 #include <vector>
00020 #include <map>
00021 #include <list>
00022 #include <string>
00023 #include <algorithm>
00024 #include <dlfcn.h>
00025 
00026 #include "elements.h"
00027 #include "parser.h"
00028 #include "kernel.h"
00029 
00030 //for socket
00031 #include<sys/types.h>
00032 #include<sys/socket.h>
00033 #include<netinet/in.h>
00034 #include<arpa/inet.h>
00035 #include<signal.h>
00036 #include<netdb.h>
00037 #include<unistd.h>
00038 
00039 using namespace std;
00040 
00041 class SMPParser;
00042 
00043 namespace SMP{
00044 
00050 class SMPInterpreter
00051 {
00052     friend class SMPParser;
00053 public:
00054 
00055     /*------------------------------------------------------------------------------------------------
00056      * SMP Kernel
00057      */
00058     
00059     void *kernel_lib;
00060     SMPKernel *kernel;
00061 
00062     SMPParser *parser;
00063     /*------------------------------------------------------------------------------------------------
00064      * other data
00065      */
00066 
00068     pthread_t kernel_thread;
00069 
00071     vector<string> cmd_history;
00072 
00074     map<string, int> kernel_config;
00075 
00076     /*-------------------------------------------------------------------------------------------------
00077      * Interpreted data here
00078      */
00079 
00083     vector<_filter*> filter_list;
00084     
00088     vector<_buffer*> buffer_list;
00089   
00092     vector<_filter*> filters;
00093 
00095     char repos_path[100];
00096 
00097     /*-------------------------------------------------------------------------------------------------
00098      * Functions used for user commands
00099      */
00100     
00106     void start_kernel(void);
00107 
00111     void setup(void);
00115     void reset(void);
00116 
00117 
00118 
00122     void clear_project(void);
00123     
00127     void print_project(void);
00128     
00132     void print_help(void);
00133    
00134 
00141     int get_filter_property(vector<_filter*> &target, int id);
00146     void get_filter_property(vector<_filter*> &target);
00147     
00152     void get_buffer_property();
00153 
00159     int get_buffer_property(int id);
00160 
00168     int set_filter_property(int id, string property_name, string value);
00169     
00170 
00175     int reset_filter_property(int id);
00176     
00180     int reset_filter_property(void);
00181 
00182 
00183   
00184  
00185     /*------------------------------------------------------------------------------------------------------
00186      * working as a server
00187      */
00188 
00192     //void server(void);
00196     static void *cmd_handler(void *arg);
00197     
00198 public:
00200     SMPInterpreter(int *pargc, char ***pargv);
00202     ~SMPInterpreter();
00203    
00209     //void start(void);
00210    
00211 
00219     void start(void);
00220   
00224     bool load_project(char *filename);
00225 
00229     void set_repository(char *path);
00230 
00234     char *get_repository();
00235 
00241     static void *run(void *arg);
00242 
00244     int sw_fd;    
00245 
00253     int execute_cmd(char *cmd);
00254     
00255     
00261     void show_current_filters();
00262     
00268     void show_current_buffers();
00269 
00270 public:    // Internal members & functions
00271     string err_string;
00272     bool _load_filters();
00273     bool _print_filters();
00274     bool _add_filter(int fid, bool is_prompt = true);
00275     bool _add_filter_byname(string fname, bool is_prompt = true);
00276     bool _add_filter(_filter *filter, bool is_prompt = true);
00277     bool _add_buffer(int src_fid, int src_pid, int dest_fid, int dest_pid, int type = DATA_BUFFER);
00278     bool _set_buffer_size(int src_fid, int src_pid, int size, int type);//, int type = DATA_BUFFER);
00279     bool _del_filter(int fidx);
00280     bool _del_buffer(int bidx);
00281     bool _del_buffer(int src_fid, int src_pid, int dest_fid, int dest_pid);
00282     
00283     int _get_fidx_by_fuid(uint fuid);
00284     int _get_bidx_by_buid(uint buid);
00285     
00286     void _start();
00287     void _stop();
00288     void _pause();
00289     void _resume();
00290 
00291     bool _isStopped()   { return kernel->stopped; }
00292     bool _isPaused()    { return kernel->paused; }
00293 };
00294 
00295 
00296 } //end namespace
00297 
00298 #endif

Generated on Fri Aug 31 15:41:42 2007 for SCREAMLinuxMiddleware(SLIM) by  doxygen 1.5.1