------------------------------------------------------------- Description: Registers a new variable. If the variable with that name is already registered in this store then if its type is the same the variable is reused otherwise the error is logged and the function returns NULL. Arguments: name - Name of the new variable type - Type of the new variable Return Value: New variable (or old with the
| 399 | // fails). |
| 400 | // ------------------------------------------------------------- |
| 401 | TriVariable* Tr2VariableStore::RegisterVariableType( const char* name, TriVariableContentType type ) |
| 402 | { |
| 403 | TriVariable* var = FindLocalVariable( name ); |
| 404 | |
| 405 | if( var ) |
| 406 | { |
| 407 | // Variable already exists, ensure type matches |
| 408 | TriVariableContentType existingType = var->GetType(); |
| 409 | if( existingType == TRIVARIABLE_INVALID ) |
| 410 | { |
| 411 | // Variable was just reserved, switch it to this type, |
| 412 | // it has enough allocated space |
| 413 | var->m_type = type; |
| 414 | } |
| 415 | else if( type == TRIVARIABLE_INVALID ) |
| 416 | { |
| 417 | return var; |
| 418 | } |
| 419 | else if( type != existingType ) |
| 420 | { |
| 421 | // Variable exists under a different type |
| 422 | CCP_LOGERR( "Attempting to register variable '%s' as '%s', already registered as '%s'", name, TriVariable::GetTypeName( type ), TriVariable::GetTypeName( existingType ) ); |
| 423 | CCP_ASSERT( false ); |
| 424 | var = NULL; |
| 425 | } |
| 426 | } |
| 427 | else |
| 428 | { |
| 429 | TriVariablePtr variable; |
| 430 | variable.CreateInstance(); |
| 431 | var = variable; |
| 432 | var->m_type = type; |
| 433 | var->m_name = name; |
| 434 | m_variableMap[name] = var; |
| 435 | } |
| 436 | |
| 437 | return var; |
| 438 | } |
| 439 | |
| 440 | std::vector<std::string> Tr2VariableStore::GetLocalNames() const |
| 441 | { |
nothing calls this directly
no test coverage detected