communicator.hpp
Go to the documentation of this file.00001 #ifndef MUSCLE_COMMUNICATOR_HPP 00002 #define MUSCLE_COMMUNICATOR_HPP 00003 00004 #include <string> 00005 #include <unistd.h> 00006 #include "logger.hpp" 00007 #include "muscle_types.h" 00008 00009 // Keep in sync with Java protocol! 00010 typedef enum { 00011 // env 00012 PROTO_SEND = 4, 00013 PROTO_RECEIVE = 5, 00014 PROTO_FINALIZE = 0, 00015 PROTO_WILL_STOP = 3, 00016 PROTO_HAS_NEXT = 8, 00017 // CxA 00018 PROTO_KERNEL_NAME = 1, 00019 PROTO_PROPERTY = 2, 00020 PROTO_PROPERTIES = 6, 00021 PROTO_TMP_PATH = 7 00022 } muscle_protocol_t; 00023 00024 extern "C" int communicator_write_to_socket(void *socket_handle, void *buf, int buf_len); 00025 extern "C" int communicator_read_from_socket(void *socket_handle, void *buf, int buf_len); 00026 00027 namespace muscle { 00028 00029 class Communicator 00030 { 00031 public: 00032 Communicator() : sockfd(-1) { } 00033 virtual ~Communicator() { 00034 if (sockfd >= 0) close(sockfd); 00035 } 00037 virtual int execute_protocol(muscle_protocol_t opcode, std::string *identifier, muscle_datatype_t type, const void *msg, size_t msg_len, void *result, size_t *result_len) { return 0; } 00039 std::string retrieve_string(muscle_protocol_t opcode, std::string *name); 00041 virtual void free_data(void *ptr, muscle_datatype_t type) {}; 00042 protected: 00043 void connect_socket(const char *hostname, int port); 00044 int sockfd; 00045 }; 00046 00047 } // EO namespace muscle 00048 #endif
Generated on Thu Oct 18 14:28:28 2012 for Muscle C/C++ API by
![doxygen](doxygen.png)