00001 #ifndef Not_h
00002 #define Not_h
00003 #include "Function.h"
00004
00005 namespace cart
00006 {
00007 template <class T>
00008 class Not : public Function
00009 {
00010 public:
00011 Not();
00012 ~Not();
00013
00014 void evaluate(voidP inputs, void* result);
00015 };
00016
00017 typedef Not<uint> NotUint;
00018
00019 template <class T>
00020 Not<T>::Not()
00021 {
00022 name_ = "NOT";
00023 numOfArgs_ = 1;
00024 }
00025
00026 template <class T>
00027 Not<T>::~Not()
00028 {
00029 }
00030
00031 template <class T>
00032 void Not<T>::evaluate(voidP inputs, void* result)
00033 {
00034 T& neg = *(T*) result;
00035 stringstream ss;
00036 ss << *((string*) inputs.get());
00037 vector<T> readInputs;
00038 T input, maxSize = 0;
00039 uint i = 0;
00040
00041 while (ss >> input)
00042 {
00043 readInputs.push_back(input);
00044 ss >> input;
00045 if (input > maxSize)
00046 {
00047 maxSize = input;
00048 }
00049 i += 2;
00050 if (i == 2 * numOfArgs_)
00051 {
00052 break;
00053 }
00054 }
00055 T mask = (T)pow(2.0, maxSize + 1.0) - 1;
00056
00057 neg = ~((T)readInputs.at(0));
00058
00059
00060 neg &= mask;
00061 }
00062
00063 }
00064
00065 #endif