ircproxy  The Ultimate Cyborg

BinaryExpression< inverted, EXPR1, OP, EXPR2 > Class Template Reference

#include <Expression.h>

Inheritance diagram for BinaryExpression< inverted, EXPR1, OP, EXPR2 >:

ExpressionInterface BinaryExpressionDerived< inverted, EXPR1, OP, EXPR2 >

List of all members.


Detailed Description

template<bool inverted, class EXPR1, beop_type OP, class EXPR2>
class BinaryExpression< inverted, EXPR1, OP, EXPR2 >

An binary boolean expression.

Definition at line 200 of file Expression.h.


Public Types

typedef BinaryExpression
<!inverted, EXPR1, OP, EXPR2 > 
inverted_type
 The type of this expression inverted.

Public Member Functions

 BinaryExpression (EXPR1 e1, EXPR2 e2)
 Constructor.
BinaryExpression<!inverted,
EXPR1, OP, EXPR2 > 
operator! (void) const
 Return inverted expression.
ExpressionEventServercreate_event_server (void)
 Create and return an event server that is watching this expression.
void sub_event_server_impl (ExpressionEventServer *event_server)
 Actual implementation of sub_event_server().
virtual void add_event_server (boost::shared_ptr< ExpressionEventServer > const &event_server)
 Implementation of pure virtual funtion ExpressionInterface::add_event_server.
virtual bool evaluate (void)
 Evaluate the expression.
virtual void sub_event_server (ExpressionEventServer *event_server)
 Implementation of pure virtual funtion ExpressionInterface::sub_event_server.
virtual void print_on (std::ostream &os) const
 Print the expression on ostream os.

Protected Attributes

EXPR1 M_e1
 First expression.
EXPR2 M_e2
 Second expression.

Member Typedef Documentation

template<bool inverted, class EXPR1, beop_type OP, class EXPR2>
typedef BinaryExpression<!inverted, EXPR1, OP, EXPR2> BinaryExpression< inverted, EXPR1, OP, EXPR2 >::inverted_type

The type of this expression inverted.

Definition at line 203 of file Expression.h.


Constructor & Destructor Documentation

template<bool inverted, class EXPR1, beop_type OP, class EXPR2>
BinaryExpression< inverted, EXPR1, OP, EXPR2 >::BinaryExpression ( EXPR1  e1,
EXPR2  e2 
) [inline]

Constructor.

Definition at line 211 of file Expression.h.

00211 : M_e1(e1), M_e2(e2) { }


Member Function Documentation

template<bool inverted, class EXPR1, beop_type OP, class EXPR2>
BinaryExpression<!inverted, EXPR1, OP, EXPR2 > BinaryExpression< inverted, EXPR1, OP, EXPR2 >::operator! ( void   )  const [inline]

template<bool inverted, class EXPR1, beop_type OP, class EXPR2>
ExpressionEventServer& BinaryExpression< inverted, EXPR1, OP, EXPR2 >::create_event_server ( void   )  [inline]

Create and return an event server that is watching this expression.

Definition at line 217 of file Expression.h.

References debug::channels::dc::expression.

00218     {
00219       boost::shared_ptr<ExpressionInterface> expression(new BinaryExpression(*this));
00220       boost::shared_ptr<ExpressionEventServer> event_server(new ExpressionEventServer(expression));
00221       expression->add_event_server(event_server);
00222       return *event_server;
00223     }

template<bool inverted, class EXPR1, beop_type OP, class EXPR2>
void BinaryExpression< inverted, EXPR1, OP, EXPR2 >::sub_event_server_impl ( ExpressionEventServer event_server  )  [inline]

Actual implementation of sub_event_server().

Definition at line 226 of file Expression.h.

00226 { M_e1.sub_event_server_impl(event_server); M_e2.sub_event_server_impl(event_server); }

template<bool inverted, class EXPR1, beop_type OP, class EXPR2>
virtual void BinaryExpression< inverted, EXPR1, OP, EXPR2 >::add_event_server ( boost::shared_ptr< ExpressionEventServer > const &  event_server  )  [inline, virtual]

Implementation of pure virtual funtion ExpressionInterface::add_event_server.

Implements ExpressionInterface.

Definition at line 229 of file Expression.h.

00230         { M_e1.add_event_server(event_server); M_e2.add_event_server(event_server); }

template<bool inverted, class EXPR1, beop_type OP, class EXPR2>
bool BinaryExpression< inverted, EXPR1, OP, EXPR2 >::evaluate ( void   )  [inline, virtual]

Evaluate the expression.

Implements ExpressionInterface.

Definition at line 258 of file Expression.h.

00259 {
00260   typename binary_operator<inverted, EXPR1, OP, EXPR2>::return_type result =
00261     static_cast<BinaryExpressionDerived<inverted, EXPR1, OP, EXPR2>*>(this)->evaluate_impl();
00262   return only_pass_if_bool(result);
00263 }

template<bool inverted, class EXPR1, beop_type OP, class EXPR2>
virtual void BinaryExpression< inverted, EXPR1, OP, EXPR2 >::sub_event_server ( ExpressionEventServer event_server  )  [inline, virtual]

Implementation of pure virtual funtion ExpressionInterface::sub_event_server.

Implements ExpressionInterface.

Definition at line 234 of file Expression.h.

00234 { sub_event_server_impl(event_server); }

template<bool inverted, class EXPR1, beop_type OP, class EXPR2>
void BinaryExpression< inverted, EXPR1, OP, EXPR2 >::print_on ( std::ostream &  os  )  const [inline, virtual]

Print the expression on ostream os.

Implements ExpressionInterface.

Definition at line 272 of file Expression.h.

References BinaryExpression< inverted, EXPR1, OP, EXPR2 >::M_e1, and BinaryExpression< inverted, EXPR1, OP, EXPR2 >::M_e2.

00273 {
00274   if (inverted)
00275     os << '!';
00276   os << '(';
00277   M_e1.print_on(os);
00278   switch (OP)
00279   {
00280     case beop_AND:
00281       os << " && ";
00282       break;
00283     case beop_OR:
00284       os << " || ";
00285       break;
00286     case beop_NEQ:
00287       os << " != ";
00288       break;
00289     case beop_EQ:
00290       os << " == ";
00291       break;
00292     case beop_BITWISE_AND:
00293       os << " & ";
00294       break;
00295     case beop_BITWISE_OR:
00296       os << " | ";
00297       break;
00298     case beop_BITWISE_XOR:
00299       os << " ^ ";
00300       break;
00301   }
00302   M_e2.print_on(os);
00303   os << ')';
00304 }


Member Data Documentation

template<bool inverted, class EXPR1, beop_type OP, class EXPR2>
EXPR1 BinaryExpression< inverted, EXPR1, OP, EXPR2 >::M_e1 [protected]

template<bool inverted, class EXPR1, beop_type OP, class EXPR2>
EXPR2 BinaryExpression< inverted, EXPR1, OP, EXPR2 >::M_e2 [protected]


The documentation for this class was generated from the following file:

Copyright © 2005-2007 Carlo Wood.  All rights reserved.