TAO_Interpreter Class Reference

TAO_Interpreter is the superclass for all interpreters. Its build tree method invokes the yacc parser to parse a constraint or preference string. More...

#include <Interpreter.h>

Inheritance diagram for TAO_Interpreter:

Inheritance graph
[legend]
Collaboration diagram for TAO_Interpreter:

Collaboration graph
[legend]
List of all members.

Protected Member Functions

 TAO_Interpreter (void)
 Constructor.

 ~TAO_Interpreter (void)
 Destructor.

int build_tree (const char *preferences)

Static Protected Member Functions

int is_empty_string (const char *str)

Protected Attributes

TAO_Constraintroot_

Static Private Attributes

TAO_SYNCH_MUTEX parserMutex__
 This mutex protects the method from reentrance.


Detailed Description

TAO_Interpreter is the superclass for all interpreters. Its build tree method invokes the yacc parser to parse a constraint or preference string.

Definition at line 33 of file Interpreter.h.


Constructor & Destructor Documentation

TAO_Interpreter::TAO_Interpreter void   )  [protected]
 

Constructor.

Definition at line 10 of file Interpreter.cpp.

00011   : root_ (0)
00012 {
00013 }

TAO_Interpreter::~TAO_Interpreter void   )  [protected]
 

Destructor.

Definition at line 15 of file Interpreter.cpp.

00016 {
00017   delete root_;
00018 }


Member Function Documentation

int TAO_Interpreter::build_tree const char *  preferences  )  [protected]
 

Using the Yacc generated parser, construct an expression tree representing from the tokens returned by it.

Definition at line 21 of file Interpreter.cpp.

References ACE_GUARD_RETURN, YYSTYPE::constraint_, parserMutex__, TAO_Lex_String_Input::reset(), TAO_SYNCH_MUTEX, yylex(), and yyval.

00022 {
00023   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
00024                     guard,
00025                     TAO_Interpreter::parserMutex__,
00026                     -1);
00027 
00028   TAO_Lex_String_Input::reset ((char*)constraints);
00029   int return_value = 0;
00030 
00031   yyval.constraint_ = 0;
00032   return_value = ::yyparse ();
00033 
00034   if (return_value == 0 && yyval.constraint_ != 0)
00035     this->root_ = yyval.constraint_;
00036   else
00037     {
00038       while (yylex () > 0)
00039         continue;
00040       this->root_ = 0;
00041     }
00042 
00043   return return_value;
00044 }

int TAO_Interpreter::is_empty_string const char *  str  )  [static, protected]
 

Definition at line 47 of file Interpreter.cpp.

Referenced by TAO_Constraint_Interpreter::TAO_Constraint_Interpreter(), and TAO_Preference_Interpreter::TAO_Preference_Interpreter().

00048 {
00049   int return_value = 0;
00050 
00051   if (str != 0)
00052     {
00053       int i = 0;
00054       while (str[i] != '\0')
00055         {
00056           if (str[i] != ' ')
00057             break;
00058 
00059           i++;
00060         }
00061 
00062       if (str[i] == '\0')
00063         return_value = 1;
00064     }
00065 
00066   return return_value;
00067 }


Member Data Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_SYNCH_MUTEX TAO_Interpreter::parserMutex__ [static, private]
 

This mutex protects the method from reentrance.

Definition at line 8 of file Interpreter.cpp.

Referenced by build_tree().

TAO_Constraint* TAO_Interpreter::root_ [protected]
 

The root of the expression tree, not equal to null if build_tree successfully builds a tree from the constraints.

Definition at line 51 of file Interpreter.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 14:00:52 2006 for TAO_CosTrader by doxygen 1.3.6