00001 /* 00002 ot_lib - Object Type Library 00003 Copyright (C) 2002 Alessandro Bonfanti 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 Alessandro Bonfanti 00020 xjbon@tin.it 00021 */ 00022 00023 00024 #ifndef OTINTERFACEELEMENT_H 00025 #define OTINTERFACEELEMENT_H 00026 00027 #include "ot_lib.h" 00028 00029 00030 00031 // ------------------------------------------------------ 00033 00034 // ------------------------------------------------------ 00035 class ot_functionImplementation 00036 { 00037 public: 00038 00042 virtual auto_ptr<ot_obj> exec(const ot_obj &input) = 0; 00043 00044 virtual ~ot_functionImplementation(void) {} 00045 }; 00046 00047 00048 // ------------------------------------------------------ 00049 class ot_interfaceElement : public ost::Mutex 00050 { 00051 private: 00052 00053 string m_name; 00054 00055 00056 public: 00057 00058 ot_interfaceElement(const string &name); 00059 virtual ~ot_interfaceElement(void); 00060 00061 const string & getName(void) const; 00062 }; 00063 00064 00065 // ------------------------------------------------------ 00066 class ot_interfaceFunction : public ot_interfaceElement 00067 { 00068 private: 00069 00070 auto_ptr<ot_functionImplementation> m_func; 00071 OT_IE_ACCESS m_accessMode; 00072 00073 00074 public: 00075 00076 ot_interfaceFunction(const string &name,ot_functionImplementation *f,OT_IE_ACCESS a=IE_PRIVATE); 00077 virtual ~ot_interfaceFunction(void); 00078 00079 void setAccess(OT_IE_ACCESS a); 00080 OT_IE_ACCESS getAccess(void); 00081 00082 auto_ptr<ot_obj> exec(const ot_obj &input); 00083 }; 00084 00085 00086 // ------------------------------------------------------ 00087 class ot_interfaceAttribute : public ot_interfaceElement 00088 { 00089 private: 00090 00091 auto_ptr<ot_obj> m_attr; 00092 OT_IE_ACCESS m_access; 00093 OT_IE_STATUS m_status; 00094 00095 00096 public: 00097 00098 ot_interfaceAttribute(const string &name,const ot_obj &o,OT_IE_ACCESS a=IE_PRIVATE,OT_IE_STATUS s=IE_UNLOCKED); 00099 virtual ~ot_interfaceAttribute(void); 00100 00101 auto_ptr<ot_obj> get(void); 00102 void set(const ot_obj &o); 00103 00104 void setAccess(OT_IE_ACCESS a); 00105 OT_IE_ACCESS getAccess(void); 00106 00107 void lock(void); 00108 void unlock(void); 00109 OT_IE_STATUS getStatus(void); 00110 }; 00111 00112 #endif