00001 //############################################################################################################################################### 00002 // 00003 // Meta and Builder Object Network V2.0 for GME 00004 // BON2Component.h 00005 // 00006 //############################################################################################################################################### 00007 00008 /* 00009 Copyright (c) Vanderbilt University, 2000-2004 00010 ALL RIGHTS RESERVED 00011 00012 Vanderbilt University disclaims all warranties with regard to this 00013 software, including all implied warranties of merchantability 00014 and fitness. In no event shall Vanderbilt University be liable for 00015 any special, indirect or consequential damages or any damages 00016 whatsoever resulting from loss of use, data or profits, whether 00017 in an action of contract, negligence or other tortious action, 00018 arising out of or in connection with the use or performance of 00019 this software. 00020 */ 00021 00022 #ifndef BON2Component_h 00023 #define BON2Component_h 00024 00025 #include "BON.h" 00026 #include "Extensions.h" 00027 #include "BONImpl.h" 00028 #include "PrintDlg.h" 00029 #include <ComponentConfig.h> 00030 00031 namespace BON 00032 { 00033 // This Component is intended only for demonstration purposes. The calls are pretty dumb. ! 00034 00035 // The implementor always has to predeclarete the implementation classes. It is good practice that immediately after the BON::Extensions are declared. 00036 00037 class ProcessingImplBase; 00038 00039 class CompoundImpl; 00040 DECLARE_BONEXTENSION( Model, CompoundImpl, Compound ); 00041 00042 class PrimitiveImpl; 00043 DECLARE_BONEXTENSION( Model, PrimitiveImpl, Primitive ); 00044 00045 class ParameterImpl; 00046 DECLARE_BONEXTENSION( Atom, ParameterImpl, Parameter ); 00047 00048 class IOParameterImpl; 00049 DECLARE_BONEXTENSION( Atom, IOParameterImpl, IOParameter ); 00050 00051 class SignalImpl; 00052 DECLARE_BONEXTENSION( Atom, SignalImpl, Signal ); 00053 00054 //############################################################################################################################################### 00055 // 00056 // C L A S S : BON::Component 00057 // 00058 //############################################################################################################################################### 00059 00060 class Component 00061 { 00062 //============================================================== 00063 // IMPLEMENTOR SPECIFIC PART 00064 // Insert application specific members and method deifinitions here 00065 00066 //============================================================== 00067 // BON2 SPECIFIC PART 00068 // Do not modify anything below 00069 00070 // Member variables 00071 public : 00072 Project m_project; 00073 bool m_bIsInteractive; 00074 00075 public: 00076 Component(); 00077 ~Component(); 00078 00079 public: 00080 void initialize( Project& project ); 00081 void finalize( Project& project ); 00082 void invoke( Project& project, const std::set<FCO>& setModels, long lParam ); 00083 void invokeEx( Project& project, FCO& currentFCO, const std::set<FCO>& setSelectedFCOs, long lParam ); 00084 void objectInvokeEx( Project& project, Object& currentObject, const std::set<Object>& setSelectedObjects, long lParam ); 00085 Util::Variant getParameter( const std::string& strName ); 00086 void setParameter( const std::string& strName, const Util::Variant& varValue ); 00087 00088 #ifdef GME_ADDON 00089 void globalEventPerformed( globalevent_enum event ); 00090 void objectEventPerformed( Object& object, unsigned long event, VARIANT v ); 00091 #endif 00092 }; 00093 00094 //############################################################################################################################################### 00095 // 00096 // C L A S S : BON::ProcessingBaseImpl 00097 // 00098 //############################################################################################################################################### 00099 00100 // This class demonstrate that the implementor is not forced to create BON::EX classes for implementations. They can be used in the inherited classes. 00101 00102 class ProcessingBaseImpl 00103 : public ModelImpl 00104 { 00105 private : 00106 bool m_bParamsAccessed; 00107 std::vector<Parameter> m_vecParams; 00108 00109 public : 00110 void initialize(); 00111 ~ProcessingBaseImpl(); 00112 std::vector<Parameter>& childParameters(); 00113 }; 00114 00115 //############################################################################################################################################### 00116 // 00117 // C L A S S : BON::CompoundImpl 00118 // 00119 //############################################################################################################################################### 00120 00121 class CompoundImpl 00122 : public ProcessingBaseImpl 00123 { 00124 public : 00125 int getHighPrimitivesCount(); 00126 }; 00127 00128 //############################################################################################################################################### 00129 // 00130 // C L A S S : BON::PrimitiveImpl 00131 // 00132 //############################################################################################################################################### 00133 00134 class PrimitiveImpl 00135 : public ProcessingBaseImpl 00136 { 00137 private : 00138 long m_iPriority; 00139 00140 public : 00141 void initialize(); 00142 long priority() const; 00143 }; 00144 00145 //############################################################################################################################################### 00146 // 00147 // C L A S S : BON::ParameterImpl 00148 // 00149 //############################################################################################################################################### 00150 00151 enum DataType { DT_Integer, DT_Real, DT_Character, DT_Pointer }; 00152 00153 class ParameterImpl 00154 : public AtomImpl 00155 { 00156 public : 00157 long m_iSize; 00158 DataType m_eType; 00159 00160 public : 00161 void initialize(); 00162 std::set<IOParameter> inputParameters(); 00163 std::set<IOParameter> outputParameters(); 00164 virtual std::string className() const; 00165 }; 00166 00167 //############################################################################################################################################### 00168 // 00169 // C L A S S : BON::IOParameterImpl 00170 // 00171 //############################################################################################################################################### 00172 00173 class IOParameterImpl 00174 : public ParameterImpl 00175 { 00176 public : 00177 std::string className() const; 00178 }; 00179 00180 //############################################################################################################################################### 00181 // 00182 // C L A S S : BON::SignalImpl 00183 // 00184 //############################################################################################################################################### 00185 00186 class SignalImpl 00187 : public AtomImpl 00188 { 00189 public : 00190 bool isMyParentPrimitive(); 00191 }; 00192 00193 //############################################################################################################################################### 00194 // 00195 // C L A S S : BON::MyVisitor 00196 // 00197 //############################################################################################################################################### 00198 00199 // This is an example for Visitor Extension and usage 00200 00201 class MyVisitor 00202 : public Visitor 00203 { 00204 private : 00205 CPrintDlg* m_pDlg; 00206 00207 public : 00208 MyVisitor( CPrintDlg* pDlg ); 00209 00210 void visitObjectImpl( const Object& object ); 00211 void visitFCOImpl( const FCO& object ); 00212 void visitAtomImpl( const Atom& atom ); 00213 void visitModelImpl( const Model& model ); 00214 00215 private : 00216 void PrintLine( const std::string& str ); 00217 bool visitPrimitive( const Primitive& object ); 00218 bool visitCompound( const Compound& object ); 00219 bool visitParameter( const Parameter& object ); 00220 bool visitIOParameter( const IOParameter& object ); 00221 bool visitSignal( const Signal& object ); 00222 }; 00223 00224 }; // namespace BON 00225 00226 #endif // Bon2Component_H