rpn_handler.h

Go to the documentation of this file.
00001 
00002 // Name:        rpn_handler.h
00003 // Purpose:     
00004 // Author:      NDA
00005 // Modified by: 
00006 // Created:     09/01/07 16:54
00007 // RCS-ID:      
00008 // Copyright:   CAEN S.p.A All rights reserved.
00009 // Licence:     
00011 
00012 #ifndef _RPN_HANDLER_H_
00013 #define _RPN_HANDLER_H_
00014 
00015 #if defined(__GNUG__) && !defined(__APPLE__)
00016 #pragma interface "rpn_handler.h"
00017 #endif
00018 
00019 class VirtualBoardChannel;
00023 typedef enum
00024 {
00025         RPN_OPERATOR_ADD= 0,            // Add Operator
00026         RPN_OPERATOR_SUB,                       // Subtract Operator
00027         RPN_OPERATOR_MUL,                       // Multiply Operator
00028         RPN_OPERATOR_DIV,                       // Divide Operator
00029 
00030         RPN_OPERAND_CH0,                        // Channel 0 Operand
00031         RPN_OPERAND_CH1,                        // Channel 1 Operand
00032         RPN_OPERAND_CH2,                        // Channel 2 Operand
00033         RPN_OPERAND_CH3,                        // Channel 3 Operand
00034         RPN_OPERAND_CH4,                        // Channel 4 Operand
00035         RPN_OPERAND_CH5,                        // Channel 5 Operand
00036         RPN_OPERAND_CH6,                        // Channel 6 Operand
00037         RPN_OPERAND_CH7,                        // Channel 7 Operand
00038 
00039         RPN_OPERAND_CONST,                      // Constant value Operand : let as the least
00040 } RpnTypes;
00041 
00042 #ifndef LPCSTR 
00043 typedef const char* LPCSTR;
00044 #endif
00045 //
00046 // Rpn name s for string parsing
00047 const LPCSTR RpnTypesNames[]=
00048 {
00049         "ADD",                  // Add Operator
00050         "SUB",                  // Subtract Operator
00051         "MUL",                  // Multiply Operator
00052         "DIV",                  // Divide Operator
00053         
00054         "CH0",                  // Channel 1 Operand
00055         "CH1",                  // Channel 2 Operand
00056         "CH2",                  // Channel 3 Operand
00057         "CH3",                  // Channel 4 Operand
00058         "CH4",                  // Channel 5 Operand
00059         "CH5",                  // Channel 6 Operand
00060         "CH6",                  // Channel 7 Operand
00061         "CH7",                  // Channel 7 Operand
00062 
00063         // Any other undefined name will be handled as CONST operand value
00064 };
00065 struct RpnItem
00066 {
00067         bool m_processed;
00068         double m_value;
00069         RpnTypes m_type;
00070 };
00071 
00072 class RpnHandler
00073 {
00074 public:
00075         RpnHandler( VirtualBoardChannel* parent, const char *expression_def);
00076         ~RpnHandler( void);
00077 
00078         bool Parse( const char *expression_def);
00079         const char* Format( void);
00080         bool Test( void);
00081         bool Eval( double &result);
00082         unsigned int GetBufferCount( void);
00083 protected:
00084         RpnItem* m_rpn_items_array;
00085         RpnItem* m_tmp_rpn_items_array;
00086         int m_rpn_array_alloc_size;
00087         int m_rpn_array_real_size;
00088         char* m_expression_def;
00089         bool DoEval( double *p_result);
00090         VirtualBoardChannel* m_parent;
00091         int m_ref_channel_index;
00092         
00093 };
00094 
00095 
00096 #endif  // _RPN_HANDLER_H_
00097 

Generated on Mon Mar 19 17:14:08 2007 for CAENScope by  doxygen 1.4.6-NO