Alida-C++ 0.5
|
00001 #include <math.h> 00002 #include <stdio.h> 00003 #include <fstream> 00004 #include <string> 00005 #include <iostream> 00006 00007 #include "demo/demoOperator.h" 00008 #include "operator/aldOperatorManager.h" 00009 00010 using namespace std; 00011 00012 REGISTER_OPERATOR(DemoOperator) 00013 00014 DemoOperator::DemoOperator() 00015 { 00016 DEFINE_PARAMETER( float, floatval, ALDOpParameterDescriptor::IN, 00017 true, false, "a float val", "This is a float value", NULL); 00018 00019 DEFINE_PARAMETER( double, doubleval, ALDOpParameterDescriptor::IN, 00020 true, false, "a double val", "This is a double value", NULL); 00021 00022 DEFINE_PARAMETER( int, intval, ALDOpParameterDescriptor::IN, 00023 true, false, "an int val", "This is an int value", NULL); 00024 00025 DEFINE_PARAMETER( std::string, stringval, ALDOpParameterDescriptor::IN, 00026 true, false, "a string val", "This is a string value", NULL); 00027 00028 DEFINE_PARAMETER( double, resultval, ALDOpParameterDescriptor::OUT, 00029 true, false, "a double val", 00030 "This is the result, sum of floatval and doubleval", NULL); 00031 } 00032 00033 void DemoOperator::operate() 00034 { 00035 std::cout << "DemoOperator called..." << endl << endl; 00036 00037 printf("Value of my parameter named floatval is %.8f\n", 00038 *((float*)(this->getParameter("floatval")))); 00039 00040 printf("Value of my parameter named doubleval is %.20f\n", 00041 *((double*)(this->getParameter("doubleval")))); 00042 printf("Value of my parameter named intval is %d\n", 00043 *((int*)(this->getParameter("intval")))); 00044 std::cout << "Value of my parameter named stringval is " << 00045 *((std::string*)(this->getParameter("stringval"))) << std::endl; 00046 00047 double *result = new double(); 00048 (*result) = (double)(*((float*)(this->getParameter("floatval")))) + 00049 *((double*)(this->getParameter("doubleval"))); 00050 this->setParameter("resultval",result); 00051 std::cout << endl << "... operate() finished!" << std::endl; 00052 }