00001 /* 00002 * Scale Stack 00003 * 00004 * Copyright 2010 Eric Day 00005 * 00006 * Licensed under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 00024 #ifndef SCALESTACK_EVENT_TEST_HANDLER_H 00025 #define SCALESTACK_EVENT_TEST_HANDLER_H 00026 00027 #include <scalestack/event/handler.h> 00028 00029 namespace scalestack 00030 { 00031 namespace event 00032 { 00033 namespace test 00034 { 00035 00036 class test; 00037 00038 class handler: public event::handler 00039 { 00040 public: 00041 00042 enum state 00043 { 00044 STATE_NONE, 00045 STATE_START, 00046 STATE_RUN, 00047 STATE_TIMER, 00048 STATE_READ, 00049 STATE_WRITE, 00050 STATE_DONE 00051 }; 00052 00053 handler(test& test, handler::state fatal); 00054 00055 ~handler(); 00056 00057 void started(void); 00058 00059 void timer_expired(void); 00060 00061 void close_file_descriptor(int file_descriptor); 00062 00063 void read_ready(int file_descriptor); 00064 00065 void write_ready(int file_descriptor); 00066 00067 void run(void); 00068 00069 private: 00070 00074 handler(const handler&); 00075 00079 handler& operator=(const handler&); 00080 00081 handler::state _state; 00082 handler::state _fatal; 00083 size_t _close_count; 00084 test& _test; 00085 int _pipe[2]; 00086 }; 00087 00088 } /* namespace test */ 00089 } /* namespace event */ 00090 } /* namespace scalestack */ 00091 00092 #endif /* SCALESTACK_EVENT_TEST_HANDLER_H */
1.6.3