Start e.g.: make exec
00001 #include <tutorial/basics/alphabeta/DataSource.hpp> 00002 #include <tutorial/basics/alphabeta/DataFilter.hpp> 00003 #include <tutorial/basics/alphabeta/DataSink.hpp> 00004 00005 #include <ocean/plankton/VCreator.hpp> 00006 00007 using namespace Wizt; 00008 using namespace MemCore; 00009 00010 using namespace AlphaBeta; 00011 00012 00013 static Ref<VCreator<DataSource> > VDataSourceCreator("Tutorial/DataSource"); 00014 static Ref<VCreator<DataFilter, AcceptList<Alpha> > > VDataFilterCreator("Tutorial/DataFilter"); 00015 static Ref<VCreator<DataSink , AcceptList<Beta > > > VDataSinkCreator ("Tutorial/DataSink"); 00016 00032 int main() 00033 { 00034 // 00035 // Here, we create the VObjects through the VCreatorBase::find() interface. 00036 // Note that we could also create them using a simple C++ new. 00037 // Also, we could have found and created these objects through querying 00038 // VISH for a certain input type, e.g. asking for an input of Beta or 00039 // Alpha. This code here is just for simplification of this setup part. 00040 // 00041 // 00042 RefPtr<DataSource> DS; 00043 if (1) 00044 { 00045 RefPtr<VCreatorBase> VC = VCreatorBase::find("Tutorial/DataSource"); 00046 if (!VC) { puts("DataSource creator not found"); return 1; } 00047 DS = VC->create("MySource"); 00048 if (!DS) { puts("Could not create DataSource"); return 1; } 00049 } 00050 00051 00052 RefPtr<DataFilter> DF; 00053 if (1) 00054 { 00055 RefPtr<VCreatorBase> VC = VCreatorBase::find("Tutorial/DataFilter"); 00056 if (!VC) { puts("DataFilter creator not found"); return 1; } 00057 DF = VC->create("MyFilter"); 00058 if (!DF) { puts("Could not create DataFilter"); return 1; } 00059 } 00060 00061 RefPtr<DataSink> DT; 00062 if (1) 00063 { 00064 RefPtr<VCreatorBase> VC = VCreatorBase::find("Tutorial/DataSink"); 00065 if (!VC) { puts("DataSink creator not found"); return 1; } 00066 DT = VC->create("MySink"); 00067 if (!DT) { puts("Could not create DataSink"); return 1; } 00068 } 00069 00070 // 00071 // Setting up link from DataSource to DataFilter via communication object type Alpha 00072 // 00073 { 00074 RefPtr<VParameter> SourceOutput = DS->getImplementation( typeid(Alpha), "", "" ); 00075 RefPtr<VSlot> S = DF->Connect( SourceOutput ); 00076 printf("Filter connected to source output parameter '%s'\n", S->name.c_str() ); 00077 } 00078 00079 00080 // 00081 // Setting up link from DataFilter to DataSink via object type Beta 00082 // 00083 { 00084 RefPtr<VParameter> FilterOutput = DF->getImplementation( typeid(Beta), "", "" ); 00085 RefPtr<VSlot> what = DT->Connect( FilterOutput ); 00086 printf("Data Sink to filter output parameter '%s'\n", what->name.c_str() ); 00087 } 00088 00089 // 00090 // Done, now we are ready to issue an (asynchroneous) request chain 00091 // 00092 00093 VRequest myRequest(false); 00094 puts("Now modify some input parameter and update:"); 00095 00096 puts("Initial Chain Status:"); 00097 printf("DS: %d\n", int(DS->age(myRequest).time_value()) ); 00098 printf("DF: %d\n", int(DF->age(myRequest).time_value()) ); 00099 printf("DT: %d\n", int(DT->age(myRequest).time_value()) ); 00100 00101 // Change some input parameter of the data source 00102 DS->SomeInput << myRequest << 23; 00103 00104 // Request some result of the data sink 00105 DT->request(myRequest, 1.0); 00106 00107 puts("Resulting chain status:"); 00108 printf("DS: %d\n", int(DS->age(myRequest).time_value()) ); 00109 printf("DF: %d\n", int(DF->age(myRequest).time_value()) ); 00110 printf("DT: %d\n", int(DT->age(myRequest).time_value()) ); 00111 00112 // Do it again. Nothing will happen this time. 00113 DT->request(myRequest, 1.0); 00114 00115 puts("demo done, exiting."); 00116 return 0; 00117 } 00118 00119