Пример #1
0
const char * ParameterGroup::getStringValue(const char *paramName) 
{
  StringParameter *dp = dynamic_cast<StringParameter*> (this->getParameter(paramName));
  if(dp == NULL) {
  	cout << "Parameter \"" << paramName << "\" is not of type string.\n";
  	return "";
  }
  
  return dp->getValue();
}
TEST(ParameterTest, StringParameterValidation) {
	StringParameter p;
	std::vector<std::string> possibilities;
	possibilities.push_back("test");
	possibilities.push_back("moretest");
	possibilities.push_back("evenmoretest");

	ASSERT_NO_THROW(p = StringParameter("test", possibilities, "asd", "asd"));

	EXPECT_THROW(p.set("abc"), SIPL::SIPLException);
}
void StringParameterHandler::setParameterValue( IECore::Parameter *parameter, ValueSource valueSource )
{
	StringParameter *stringParameter = static_cast<StringParameter *>( parameter );
	if( valueSource==Storage )
	{
		stringParameter->setTypedValue( m_storage );
	}
	else
	{
		std::ostringstream s;
		m_knob->to_script( s, 0, false );
		stringParameter->setTypedValue( s.str() );
	}
}
Пример #4
0
 virtual void initComponentInstance(ComponentInstance *c){
     try {
         const char *s = pTopic->get(c->component);
         diamondapparatus::subscribe(s);
     } catch(diamondapparatus::DiamondException e){
         printf("Diamond problem : %s\n",e.what());
     }
 }
Пример #5
0
 virtual void onParamChanged(ComponentInstance *ci,UNUSED Parameter *p){
     try {
         if(p == pTopic){
             const char *s = pTopic->get(ci->component);
             diamondapparatus::subscribe(s);
         }
     } catch(diamondapparatus::DiamondException e){
         printf("Diamond problem : %s\n",e.what());
     }
 }
Пример #6
0
bool ColorAttribute::compute() {

   //std::cerr << "ColorAttribute: compute: execcount=" << m_executionCount << std::endl;

   auto color = p_color->getValue();
   Object::const_ptr obj = expect<Object>("data_in");
   if (!obj)
      return false;

   Object::ptr out = obj->clone();
   out->addAttribute("_color", color);
   addObject("data_out", out);

   return true;
}
Пример #7
0
 virtual void run(ComponentInstance *ci,int out){
     Component *c = ci->component;
     const char *s = pTopic->get(c);
     float o;
     
     try {
         diamondapparatus::Topic t = diamondapparatus::get(s);
         
         if(out<t.size()){
             o = t[out].f();
             o *= pMul[out]->get(c);
             o += pAdd[out]->get(c);
         } else
             o = 0;
     } catch(diamondapparatus::DiamondException e){
         printf("Diamond problem : %s\n",e.what());
         o=0;
     }
     tFloat->setOutput(ci,out,o);
 }
Пример #8
0
 virtual void run(ComponentInstance *ci,int out){
     Component *c = ci->component;
     OSCData *d = (OSCData *)ci->privateData;
     
     bool changed=false;
     float data[NUMOSCINS];
     int outct=0;
     for(int i=0;i<NUMOSCINS;i++){
         if(c->isInputConnected(i)){
             float in = tFloat->getInput(ci,i);
             data[outct++]=in;
             if(in!=d->prev[i]){
                 d->prev[i]=in;
                 changed=true;
             }
         }
     }
     if(changed){
         sendOsc(pTopic->get(c),data,outct);
     }
 }
Пример #9
0
void InstructionBuilder::visit(StringParameter& param) {
  printf("analyze param<str>: %s\n", param.to_s().c_str());
}
Пример #10
0
 virtual const char *getExtraText(Component *c,char *buf){
     sprintf(buf,"topic:%s",pTopic->get(c));
     return buf;
 }
Пример #11
0
StringParameter::StringParameter(const StringParameter& theStringParam)
    : nameM(theStringParam._getName())
    , valueM(theStringParam._getValue())
{
}