VISH  0.2
MultiplyInt.cpp

Create new VObject that has one integer input and output. A slot value of the MultiPlyInt is multiplicated to the input and outputted.

Use The MultiplyInt to mulitply a value by a given value to any int ouptut parameter and connect it to any other int input parameter.

May 5th 2008, mritter

#include <ocean/plankton/VModules.hpp>
#include <ocean/plankton/VCreator.hpp>

#define override

using namespace Wizt;


class MultiplyInt : public Wizt::VObject
{
  // define input and output Parameters of the VObject  
  TypedSlot<int> IntInParam;
  TypedSlot<int> Multiplier;
  VOutput<int> IntOutParam;

public:
  MultiplyInt(const string&name, int p, const RefPtr<VCreationPreferences>&VP)
    : VObject(name, p, VP)
    , IntInParam(this, "intinput", 0)     //set default values
    , IntOutParam(self(), "intoutput", 1)
    , Multiplier( this, "multiplier", 2 )
  {}
  

  // do the calculation
  override bool update(VRequest&R, double precision)
  {
    int x = 0;
    int m = 0;
    
    // Get the Value of the IntInParam and Multiplier in actual context.
    IntInParam << R >> x; 
    Multiplier << R >> m;
    
    // Calculate new Value.
    x *= m;
    
    // Out value into IntOutParam at actual context.
    IntOutParam << R << x;

    return true;
  }
                                                                  
  
};
      

// create one creator object VCreator for MultiplyInt and specify where it should be placed in the creation menu ('examples/..')
static VCreator<MultiplyInt, AcceptList<int> >  VMultiplyIntCreator("Examples/MultiplyInt");

// callback that ensures global constructors are really called
VISH_DEFAULT_INIT