00001 // -*- C++ -*- 00002 // 00003 /* \file 00004 * Represents a Connector that reads and writes from a UNIX file descriptor. 00005 */ 00006 00007 // ***** BEGIN LICENSE BLOCK ***** 00008 // Version: MPL 1.1/GPL 2.0/LGPL 2.1 00009 // 00010 // The contents of this file are subject to the Mozilla Public License 00011 // Version 1.1 (the "License"); you may not use this file except in 00012 // compliance with the License. You may obtain a copy of the License at 00013 // http://www.mozilla.org/MPL/ 00014 // 00015 // Software distributed under the License is distributed on an "AS IS" 00016 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 // the License for the specific language governing rights and limitations 00018 // under the License. 00019 // 00020 // The Original Code is the consmgr network/serial-line monitoring package. 00021 // 00022 // The Initial Developer of the Original Code is Chris P. Ross. 00023 // Portions created by the Initial Developer are Copyright (C) 2000-2008 00024 // the Initial Developer. All Rights Reserved. 00025 // 00026 // Contributor(s): 00027 // Geoff Adams 00028 // 00029 // Alternatively, the contents of this file may be used under the terms of 00030 // either the GNU General Public License Version 2 or later (the "GPL"), or 00031 // the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 00032 // in which case the provisions of the GPL or the LGPL are applicable instead 00033 // of those above. If you wish to allow use of your version of this file only 00034 // under the terms of either the GPL or the LGPL, and not to allow others to 00035 // use your version of this file under the terms of the MPL, indicate your 00036 // decision by deleting the provisions above and replace them with the notice 00037 // and other provisions required by the GPL or the LGPL. If you do not delete 00038 // the provisions above, a recipient may use your version of this file under 00039 // the terms of any one of the MPL, the GPL or the LGPL. 00040 // 00041 // ***** END LICENSE BLOCK ***** 00042 00043 #ifndef __FDCONN_H 00044 #define __FDCONN_H 00045 00046 // Get the base class 00047 #include "connector.h" 00048 00082 class FDConnector : public Connector { 00083 protected: 00084 // Only our subclasses should be allowed to use this 00085 // parameter-less constructor. 00086 FDConnector(); 00087 00088 public: 00091 FDConnector(int); 00092 00093 virtual ~FDConnector(); 00094 00095 #if 0 00097 virtual void notify_on_disconnect(const Messageable *owner); 00098 #endif 00099 00102 virtual void disconnect(); 00103 00105 virtual Data *read(); 00106 00108 virtual ssize_t write(const Data &b); 00109 00110 virtual std::string get_id() const; 00111 00114 virtual bool connected(void) const; 00115 00116 protected: 00118 virtual void connect(int fd); 00119 00120 private: 00124 int fd; 00125 00127 pthread_mutex_t mutex; 00128 }; 00129 00130 #endif /* __FDCONN_H */