Example #1
0
// Src and dst can be any size.  Src and dst have same number of components.
void LLImageRaw::copyScaled( LLImageRaw* src )
{
	LLImageRaw* dst = this;  // Just for clarity.

	llassert_always( (1 == src->getComponents()) || (3 == src->getComponents()) || (4 == src->getComponents()) );
	llassert_always( src->getComponents() == dst->getComponents() );

	if( (src->getWidth() == dst->getWidth()) && (src->getHeight() == dst->getHeight()) )
	{
		memcpy( dst->getData(), src->getData(), getWidth() * getHeight() * getComponents() );	/* Flawfinder: ignore */
		return;
	}

	S32 temp_data_size = src->getWidth() * dst->getHeight() * getComponents();
	llassert_always(temp_data_size > 0);
	std::vector<U8> temp_buffer(temp_data_size);

	// Vertical
	for( S32 col = 0; col < src->getWidth(); col++ )
	{
		copyLineScaled( src->getData() + (getComponents() * col), &temp_buffer[0] + (getComponents() * col), src->getHeight(), dst->getHeight(), src->getWidth(), src->getWidth() );
	}

	// Horizontal
	for( S32 row = 0; row < dst->getHeight(); row++ )
	{
		copyLineScaled( &temp_buffer[0] + (getComponents() * src->getWidth() * row), dst->getData() + (getComponents() * dst->getWidth() * row), src->getWidth(), dst->getWidth(), 1, 1 );
	}
}
Example #2
0
// Src and dst can be any size.  Src and dst have same number of components.
void LLImageRaw::copyScaled( LLImageRaw* src )
{
	LLMemType mt1((LLMemType::EMemType)mMemType);
	LLImageRaw* dst = this;  // Just for clarity.

	llassert_always( (1 == src->getComponents()) || (3 == src->getComponents()) || (4 == src->getComponents()) );
	llassert_always( src->getComponents() == dst->getComponents() );

	if( (src->getWidth() == dst->getWidth()) && (src->getHeight() == dst->getHeight()) )
	{
		memcpy( dst->getData(), src->getData(), getWidth() * getHeight() * getComponents() );	/* Flawfinder: ignore */
		return;
	}

	// Vertical
	S32 temp_data_size = src->getWidth() * dst->getHeight() * getComponents();
	llassert_always(temp_data_size > 0);
	U8* temp_buffer = new U8[ temp_data_size ];
	for( S32 col = 0; col < src->getWidth(); col++ )
	{
		copyLineScaled( src->getData() + (getComponents() * col), temp_buffer + (getComponents() * col), src->getHeight(), dst->getHeight(), src->getWidth(), src->getWidth() );
	}

	// Horizontal
	for( S32 row = 0; row < dst->getHeight(); row++ )
	{
		copyLineScaled( temp_buffer + (getComponents() * src->getWidth() * row), dst->getData() + (getComponents() * dst->getWidth() * row), src->getWidth(), dst->getWidth(), 1, 1 );
	}

	// Clean up
	delete[] temp_buffer;
}
Example #3
0
void LLImageRaw::clear(U8 r, U8 g, U8 b, U8 a)
{
	llassert( getComponents() <= 4 );
	// This is fairly bogus, but it'll do for now.
	U8 *pos = getData();
	U32 x, y;
	for (x = 0; x < getWidth(); x++)
	{
		for (y = 0; y < getHeight(); y++)
		{
			*pos = r;
			pos++;
			if (getComponents() == 1)
			{
				continue;
			}
			*pos = g;
			pos++;
			if (getComponents() == 2)
			{
				continue;
			}
			*pos = b;
			pos++;
			if (getComponents() == 3)
			{
				continue;
			}
			*pos = a;
			pos++;
		}
	}
}
void ComponentContainer::render() const
{
	for (unsigned int i = 0; i < getComponents().size(); i++)
	{
		getComponents()[i]->render();
	}
}
Example #5
0
void Panel::calcSize()
{
	int width = 0;
	int height = 0;

	// sucht die width/height indem alle Komponenten durchlaufen werden und die am weitesten rechts und unten gespeichert werden
	for (unsigned int i = 0; i < getComponents().size(); i++)
	{
		width = std::max(width, getComponents()[i]->getRelativeRect().getRight() + getPadding().x);
		height = std::max(height, getComponents()[i]->getRelativeRect().getBot() + getPadding().y);
	}

	if (width != getRelativeRect().getSize().x)
	{
		setRelativeRect(PixelRect(
			getRelativeRect().getPosition().x,
			getRelativeRect().getPosition().y,
			width,
			getRelativeRect().getSize().y));
	}

	if (height != getRelativeRect().getSize().y)
	{
		setRelativeRect(PixelRect(
			getRelativeRect().getPosition().x,
			getRelativeRect().getPosition().y,
			getRelativeRect().getSize().x,
			height));
	}
}
Example #6
0
BOOL LLImageRaw::setSubImage(U32 x_pos, U32 y_pos, U32 width, U32 height,
							 const U8 *data, U32 stride, BOOL reverse_y)
{
	if (!getData())
	{
		return FALSE;
	}
	if (!data)
	{
		return FALSE;
	}

	// Should do some simple bounds checking

	U32 i;
	for (i = 0; i < height; i++)
	{
		const U32 row = reverse_y ? height - 1 - i : i;
		const U32 from_offset = row * ((stride == 0) ? width*getComponents() : stride);
		const U32 to_offset = (y_pos + i)*getWidth() + x_pos;
		memcpy(getData() + to_offset*getComponents(),		/* Flawfinder: ignore */
				data + from_offset, getComponents()*width);
	}

	return TRUE;
}
BOOL LLImageTGA::decodeTruecolorRle24( LLImageRaw* raw_image )
{
	llassert( getComponents() == 3 );

	U8* dst = raw_image->getData();
	U8* src = getData() + mDataOffset;

	U8* last_src = src + getDataSize();
	U8* last_dst = dst + getComponents() * (getHeight() * getWidth() - 1);

	while( dst <= last_dst )
	{
		// Read RLE block header

		if (src >= last_src)
			return FALSE;
	
		U8 block_header_byte = *src;
		src++;

		U8 block_pixel_count = (block_header_byte & 0x7F) + 1;
		if( block_header_byte & 0x80 )
		{
			// Encoded (duplicate-pixel) block
			do
			{
				if (src + 2 >= last_src)
					return FALSE;
				dst[0] = src[2];
				dst[1] = src[1];
				dst[2] = src[0];
				dst += 3;
				block_pixel_count--;
			}
			while( block_pixel_count > 0 );
			src += 3;
		}
		else 
		{
			// Unencoded block
			do
			{
				if (src + 2 >= last_src)
					return FALSE;
				
				dst[0] = src[2];
				dst[1] = src[1];
				dst[2] = src[0];
				dst += 3;
				src += 3;
				block_pixel_count--;
			}
			while( block_pixel_count > 0 );
		}
	}

	return TRUE;
}
BOOL LLImageTGA::decodeTruecolorNonRle( LLImageRaw* raw_image, BOOL &alpha_opaque )
{
	alpha_opaque = TRUE;

	// Origin is the bottom left
	U8* dst = raw_image->getData();
	U8* src = getData() + mDataOffset;
	S32 pixels = getWidth() * getHeight();

	if (getComponents() == 4)
	{
		while( pixels-- )
		{
			// Our data is stored in RGBA.  TGA stores them as BGRA (little-endian ARGB)
			dst[0] = src[2]; // Red
			dst[1] = src[1]; // Green
			dst[2] = src[0]; // Blue
			dst[3] = src[3]; // Alpha
			if (dst[3] != 255)
			{
				alpha_opaque = FALSE;
			}
			dst += 4;
			src += 4;
		}
	}
	else if (getComponents() == 3)
	{
		if( mIs15Bit )
		{
			while( pixels-- )
			{
				decodeTruecolorPixel15( dst, src );
				dst += 3;
				src += 2;
			}
		}
		else
		{
			while( pixels-- )
			{
				dst[0] = src[2]; // Red
				dst[1] = src[1]; // Green
				dst[2] = src[0]; // Blue
				dst += 3;
				src += 3;
			}
		}
	}
	else if (getComponents() == 1)
	{
		memcpy(dst, src, pixels);	/* Flawfinder: ignore */
	}

	return TRUE;
}
MenuComponent* ComponentContainer::getHoveredComponent() const
{
	PixelVector cursor = getRelativeCursorPosition();

	for (int i = getComponents().size()-1; i >= 0; i--) // für alle Components (als letzes gerendert liegt ganz oben -> von hinten nach vorne)
	{
		if (cursor.inRect(getComponents()[i]->getRelativeRect())) // wenn die maus auf die Component zeigt
		{
			// returne ihn (falls er ein ComponentContainer ist, seine hovered-component)
			return getComponents()[i]->getHoveredComponentRecursively();
		}
	} // wenn keine Component gefunden wurde
	return nullptr;
}
Example #10
0
Object::Object(const SaveFile& file)
:   Entity(file.readString(), *Game::objectConfig),
    sprite(::getSprite(*Game::objectSpriteSheet, *Game::objectConfig, getId()))
{
    for (auto& component : getComponents())
        component->load(file);
}
Example #11
0
//-------------------------------------------------------------------------------------		
void Components::delComponent(int32 uid, COMPONENT_TYPE componentType, 
							  COMPONENT_ID componentID, bool ignoreComponentID, bool shouldShowLog)
{
	COMPONENTS& components = getComponents(componentType);
	COMPONENTS::iterator iter = components.begin();
	for(; iter != components.end();)
	{
		if((uid < 0 || (*iter).uid == uid) && (ignoreComponentID == true || (*iter).cid == componentID))
		{
			INFO_MSG(fmt::format("Components::delComponent[{}] componentID={}, component:totalcount={}.\n", 
				COMPONENT_NAME_EX(componentType), componentID, components.size()));

			ComponentInfos* componentInfos = &(*iter);

			//SAFE_RELEASE((*iter).pIntAddr);
			//SAFE_RELEASE((*iter).pExtAddr);
			//(*iter).pChannel->decRef();

			if(_pHandler)
				_pHandler->onRemoveComponent(componentInfos);

			iter = components.erase(iter);
			if(!ignoreComponentID)
				return;
		}
		else
			iter++;
	}

	if(shouldShowLog)
	{
		ERROR_MSG(fmt::format("Components::delComponent::not found [{}] component:totalcount:{}\n", 
			COMPONENT_NAME_EX(componentType), components.size()));
	}
}
Example #12
0
//------------------------------------------------------------------------------
// findNameOfComponent() --
//   1) Returns a pointer to an Identifier that contains the name of components 'p'
//      (our children first then grandchildren).  For grandchildren, a full name is
//      created to a component (i.e., "xxx.yyy.zzz", see findByName()).
//   2) Unref() the Identifier when finished.
//   3) Zero(0) is returned if 'p' is not found.
//------------------------------------------------------------------------------
const Identifier* Component::findNameOfComponent(const Component* const p) const
{
    const Identifier* name {};
    const PairStream* subcomponents = getComponents();
    if (subcomponents != nullptr) {

        // First check our component list ..
        name = subcomponents->findName(p);

        if (name == nullptr) {

            // Not found, so check our children's components ...

            const List::Item* item = subcomponents->getFirstItem();
            while (item != nullptr && name == nullptr) {
                const auto pair = static_cast<const Pair*>(item->getValue());
                const auto child = static_cast<const Component*>(pair->object());
                const Identifier* name0 = child->findNameOfComponent(p);
                if (name0 != nullptr) {
                    // Found it, so prefix it with our child's name and
                    // return the full name.
                    const auto fullname = static_cast<Identifier*>(pair->slot()->clone());
                    *fullname += ".";
                    *fullname += name0->getString();
                    name = fullname;
                    name0->unref();
                }
                item = item->getNext();
            }
        }
        subcomponents->unref();
        subcomponents = nullptr;
    }
    return name;
}
//------------------------------------------------------------------------------
// Pass the data record to all of our subcomponents for processing; they all
// should be of type OutputHandler (see processComponents() above)
//------------------------------------------------------------------------------
void OutputHandler::processRecord(const DataRecordHandle* const dataRecord)
{
   // Check the data filters to see if we should process this type record
   if ( isDataTypeEnabled(dataRecord) ) {

      // First, call our own implementation
      processRecordImp(dataRecord);

      // Next, pass the data record to our subcomponent OutputHandlers
      // for further processing
      base::PairStream* subcomponents = getComponents();
      if (subcomponents != nullptr) {
         for (base::List::Item* item = subcomponents->getFirstItem(); item != nullptr; item = item->getNext()) {

            base::Pair* pair = static_cast<base::Pair*>(item->getValue());
            OutputHandler* sc = static_cast<OutputHandler*>(pair->object());

            sc->processRecord(dataRecord);
         }
         subcomponents->unref();
         subcomponents = nullptr;
      }

   }
}
//------------------------------------------------------------------------------
// getSteerpoints() -- Get the route we're flying to (starting at 'to')
//------------------------------------------------------------------------------
unsigned int Route::getSteerpoints(Basic::safe_ptr<Steerpoint>* const stptList, const unsigned int max)
{
    unsigned int i = 0;
    Basic::PairStream* steerpoints = getComponents();
    if (stptList != nullptr && max > 0 && steerpoints != nullptr) {

        // Find our 'to' steerpoint
        bool found = false;
        Basic::List::Item* item = steerpoints->getFirstItem();
        while (item != nullptr && !found) {
            Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
            found = (pair == to);
            if (!found) {
                item = item->getNext();
            }
        }

        // Get the route we're flying 'to'
        while (item != nullptr && i < max) {
            Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
            Steerpoint* p = dynamic_cast<Steerpoint*>(pair->object());
            if (p != nullptr) {
                stptList[i++] = p;
            }
            item = item->getNext();
        }
    }

    if (steerpoints != nullptr) {
       steerpoints->unref();
       steerpoints = nullptr;
    }

    return i;
}
Example #15
0
//------------------------------------------------------------------------------
// Removes a symbol from the master symbol table
//------------------------------------------------------------------------------
bool SymbolLoader::removeSymbol(const int idx)
{
    bool ok = false;

    // Find the symbol
    if (idx >= 1 && idx <= MAX_SYMBOLS) {
        const int i = (idx - 1);
        if (symbols[i] != 0) {

            // ---
            // remove the symbol's graphical component from our subcomponent list
            // ---
            {
                // Get the symbol's graphical component
                Basic::Pair* pair = symbols[i]->getSymbolPair();
                BasicGL::Graphic* g = (BasicGL::Graphic*) pair->object();

                Basic::PairStream* x = getComponents();
                Basic::Component::processComponents(x, typeid(BasicGL::Graphic), 0, g);
                x->unref();
            }

            // ---
            // and remove it from our master symbol table
            // ---
            symbols[i]->setSymbolPair(0);
            symbols[i]->unref();
            symbols[i] = 0;

            ok = true;
        }

    }
    return ok;
}
//##############################################################################
//# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
//##############################################################################
void xContainerInternal::setLayout(MYOWNERSHIP xLayoutManager* mgr)
{
	assert(mgr != NULL);
	mgr->addComponents(getComponents());
	delete m_layout;
	m_layout = mgr;
}
Example #17
0
// Virtual
// Encode the in memory RGB image into PNG format.
BOOL LLImagePNG::encode(const LLImageRaw* raw_image, F32 encode_time)
{
	llassert_always(raw_image);

    resetLastError();

	// Image logical size
	setSize(raw_image->getWidth(), raw_image->getHeight(), raw_image->getComponents());

	// Temporary buffer to hold the encoded image. Note: the final image
	// size should be much smaller due to compression.
	U32 bufferSize = getWidth() * getHeight() * getComponents() + 1024;
    U8* tmpWriteBuffer = new U8[ bufferSize ];

	// Delegate actual encoding work to wrapper
	LLPngWrapper pngWrapper;
	if (! pngWrapper.writePng(raw_image, tmpWriteBuffer))
	{
		setLastError(pngWrapper.getErrorMessage());
		delete[] tmpWriteBuffer;
		return FALSE;
	}

	// Resize internal buffer and copy from temp
	U32 encodedSize = pngWrapper.getFinalSize();
	allocateData(encodedSize);
	memcpy(getData(), tmpWriteBuffer, encodedSize);

	delete[] tmpWriteBuffer;

	return TRUE;
}
Example #18
0
void Object::save(SaveFile& file) const
{
    file.write(getId());

    for (auto& component : getComponents())
        component->save(file);
}
//------------------------------------------------------------------------------
// reset() -- Reset parameters
//------------------------------------------------------------------------------
void Route::reset()
{
   BaseClass::reset();

   // ---
   // reset the initial 'to' steerpoint
   // ---
   directTo(static_cast<unsigned int>(0));
   Basic::PairStream* steerpoints = getComponents();
   if (steerpoints != nullptr) {

      // First try to find by name
      if (initToStptName != nullptr) {
         directTo(*initToStptName);
      }

      // Next try to find by index
      else if (initToStptIdx != 0) {
         directTo(initToStptIdx);
      }

      // We still don't have a 'to' steerpoint, then just use the first one
      if (to == nullptr) {
         directTo(1);
      }

      steerpoints->unref();
      steerpoints = nullptr;
   }
}
//------------------------------------------------------------------------------
// directTo() -- Change to this steerpoint
//------------------------------------------------------------------------------
bool Route::directTo(const Steerpoint* const stpt)
{
    bool ok = false;
    Basic::PairStream* steerpoints = getComponents();
    if (steerpoints != nullptr && stpt != nullptr) {
        // When we have steerpoints (components) and a steerpoint to switch to ...
        Basic::Pair* sp = findSteerpoint(stpt);
        if (sp != nullptr) {
            to = sp;
            stptIdx = steerpoints->getIndex(sp);
            ok = true;
        }
    }

    else if (stpt == nullptr) {
      to = nullptr;
      stptIdx = 0;
      ok = true;
    }

    if (steerpoints != nullptr) {
       steerpoints->unref();
       steerpoints = nullptr;
    }

    return ok;
}
Example #21
0
//-------------------------------------------------------------------------------------		
void Components::removeComponentFromChannel(Mercury::Channel * pChannel)
{
	int ifind = 0;
	while(ALL_COMPONENT_TYPES[ifind] != UNKNOWN_COMPONENT_TYPE)
	{
		COMPONENT_TYPE componentType = ALL_COMPONENT_TYPES[ifind++];
		COMPONENTS& components = getComponents(componentType);
		COMPONENTS::iterator iter = components.begin();

		for(; iter != components.end();)
		{
			if((*iter).pChannel == pChannel)
			{
				//SAFE_RELEASE((*iter).pIntAddr);
				//SAFE_RELEASE((*iter).pExtAddr);
				// (*iter).pChannel->decRef();

				WARNING_MSG("Components::removeComponentFromChannel: %s : %"PRAppID".\n", COMPONENT_NAME_EX(componentType), (*iter).cid);
				iter = components.erase(iter);
				return;
			}
			else
				iter++;
		}
	}

	// KBE_ASSERT(false && "channel is not found!\n");
}
Example #22
0
//------------------------------------------------------------------------------
// addComponent() -- Add a new component to our list of components
//------------------------------------------------------------------------------
bool Component::addComponent(Pair* const p)
{
   PairStream* subcomponents = getComponents();
   processComponents(subcomponents, typeid(Component), p);
   if (subcomponents != nullptr) subcomponents->unref();
   return true;
}
//------------------------------------------------------------------------------
// Compute nav steering data for each steerpoint.
//------------------------------------------------------------------------------
void Route::computeSteerpointData(const LCreal, const Navigation* const nav)
{
   if (nav != nullptr) {
      Basic::PairStream* steerpoints = getComponents();
      if (steerpoints != nullptr) {

         // Until we pass the 'to' steerpoint, the 'from' pointer will be
         // null(0) and the steerpoint's compute() function will compute
         // direct-to the steerpoint.  After the 'to' steerpoint, the 'from'
         // pointer will help compute each from-to leg of the route.
         Steerpoint* from = nullptr;

         Basic::List::Item* item = steerpoints->getFirstItem();
         while (item != nullptr) {
            Basic::Pair* pair = static_cast<Basic::Pair*>(item->getValue());
            Steerpoint* stpt = static_cast<Steerpoint*>(pair->object());
            stpt->compute(nav,from);
            if (pair == to || from != nullptr) from = stpt;
            item = item->getNext();
         }

         steerpoints->unref();
         steerpoints = nullptr;
      }
   }
}
Example #24
0
//------------------------------------------------------------------------------
// setSlotHighlight() -- 
//------------------------------------------------------------------------------                          
bool Field::setSlotHighlight(const Basic::Number* const shobj)
{
    if (shobj != 0) {
        // Set our mode
        if (shobj->getBoolean()) {
            setDisplayMode(highlight);
            setDisplayMode(highlight1);
        }
        else {
            setDisplayMode(highlight);
            setDisplayMode(highlight1);
        }

        Basic::PairStream* subcomponents = getComponents();
        if (subcomponents != 0) {

            const Basic::List::Item* item = subcomponents->getFirstItem();
            while (item != 0) {
                Basic::Pair* p = (Basic::Pair*) item->getValue();
                Field* child = dynamic_cast<Field*>(p->object());
                if (child != 0) child->setSlotHighlight(shobj); //changed from obj
                item = item->getNext();
            }

            subcomponents->unref();
            subcomponents = 0;
        }
    }
    return true;
}   
bool Route::directTo(const char* const name)
{
    bool ok = false;
    Basic::PairStream* steerpoints = getComponents();
    if (steerpoints != nullptr && name != nullptr) {
        // When we have steerpoints (components) and a name of a steerpoint
        Basic::Pair* sp = findSteerpoint(name);
        if (sp != nullptr) {
            to = sp;
            stptIdx = steerpoints->getIndex(sp);
            ok = true;
        }
    }

    else if (name == nullptr) {
      to = nullptr;
      stptIdx = 0;
      ok = true;
    }

    if (steerpoints != nullptr) {
       steerpoints->unref();
       steerpoints = nullptr;
    }

    return ok;
}
Example #26
0
//------------------------------------------------------------------------------
// setSlotReversed() -- 
//------------------------------------------------------------------------------                          
bool Field::setSlotReversed(const Basic::Number* const srobj)
{
   
    if (srobj != 0) {

        // Set our mode
        if (srobj->getBoolean()) {
            setDisplayMode(reversed);
            setDisplayMode(reversed1);
        }
        else {
            clearDisplayMode(reversed);
            clearDisplayMode(reversed1);
        }

        // Set our children's mode
        Basic::PairStream* subcomponents = getComponents();
        if (subcomponents != 0) {

            const Basic::List::Item* item = subcomponents->getFirstItem();
            while (item != 0) {
                Basic::Pair* p = (Basic::Pair*) item->getValue();
                Field* child = dynamic_cast<Field*>(p->object());
                if (child != 0) child->setSlotReversed(srobj);
                item = item->getNext();
            }

            subcomponents->unref();
            subcomponents = 0;
        }
    }
    return true;
}
//------------------------------------------------------------------------------
// deleteSteerpoint() - goes through and deletes the steerpoint if there is a match
//------------------------------------------------------------------------------
bool Route::deleteSteerpoint(Steerpoint* const sp)
{
   // get a pointer to our current 'to' steerpoint
   const Steerpoint* p = getSteerpoint();

   // remove the steerpoint
   Basic::PairStream* steerpoints = getComponents();
   Basic::Component::processComponents(steerpoints,typeid(Steerpoint),nullptr,sp);
   if (steerpoints != nullptr) {
      steerpoints->unref();
      steerpoints = nullptr;
   }

   // When we just deleted our current 'to' steerpoint,
   // force a new 'direct to' using stptIdx
   if (p == sp) {
      unsigned int idx = stptIdx;
      directTo(static_cast<unsigned int>(0));
      while ( !directTo(idx) && idx > 0 ) idx--;
   }

   // Otherwise just force a new 'direct to' using our current
   // 'to' steerpoint to make sure our stptIdx is correct.
   else {
      directTo(p);
   }

   return true;
}
Example #28
0
//------------------------------------------------------------------------------
// updateData()
//------------------------------------------------------------------------------
void Instrument::updateData(const LCreal dt)
{
   // update our base class
   BaseClass::updateData(dt);

   // check for a color rotary, just in case we need one
   BasicGL::ColorRotary* cr = dynamic_cast<BasicGL::ColorRotary*>(getColor());
   if (cr != 0) cr->determineColor(preScaleInstVal);

   // only tell the rest of our instruments our value if we want them to know it
   if (allowPassing) {
      // sort out the instruments from our components
      Basic::PairStream* ps = getComponents();
      if (ps != 0) {
         Basic::List::Item* item = ps->getFirstItem();
         while(item != 0) {
            Basic::Pair* pair = (Basic::Pair*) item->getValue();
            if (pair != 0) {
               // send the value down to all of our instrument components
               Instrument* myInst = dynamic_cast<Instrument*>(pair->object());
               Basic::Number n = preScaleInstVal;
               if (myInst != 0) myInst->event(UPDATE_INSTRUMENTS, &n);
            }
            item = item->getNext();
         }
         ps->unref();
         ps = 0;
      }
   }
}
static void checkIsValidReference(CuTest *testCase, stList *reference,
        double totalScore) {
    stList *chosenEdges = convertReferenceToAdjacencyEdges(reference);
    //Check that everyone has a partner.
    CuAssertIntEquals(testCase, nodeNumber, stList_length(chosenEdges) * 2);
    stSortedSet *nodes = stSortedSet_construct3((int(*)(const void *, const void *)) stIntTuple_cmpFn,
            (void(*)(void *)) stIntTuple_destruct);
    for (int64_t i = 0; i < nodeNumber; i++) {
        stSortedSet_insert(nodes, stIntTuple_construct1( i));
    }
    checkEdges(chosenEdges, nodes, 1, 0);
    //Check that the score is correct
    double totalScore2 = calculateZScoreOfReference(reference, nodeNumber, zMatrix);
    CuAssertDblEquals(testCase, totalScore2, totalScore, 0.000001);
    //Check that the stubs are properly connected.
    stList *allEdges = stList_copy(chosenEdges, NULL);
    stList_appendAll(allEdges, stubs);
    stList_appendAll(allEdges, chains);
    stList *components = getComponents(allEdges);
    CuAssertIntEquals(testCase, stList_length(stubs), stList_length(reference));
    CuAssertIntEquals(testCase, stList_length(stubs), stList_length(components));
    //Cleanup
    stList_destruct(components);
    stSortedSet_destruct(nodes);
    stList_destruct(allEdges);
    stList_destruct(chosenEdges);
}
Example #30
0
//-------------------------------------------------------------------------------------		
void Components::removeComponentFromChannel(Mercury::Channel * pChannel)
{
	int ifind = 0;
	while(ALL_COMPONENT_TYPES[ifind] != UNKNOWN_COMPONENT_TYPE)
	{
		COMPONENT_TYPE componentType = ALL_COMPONENT_TYPES[ifind++];
		COMPONENTS& components = getComponents(componentType);
		COMPONENTS::iterator iter = components.begin();

		for(; iter != components.end();)
		{
			if((*iter).pChannel == pChannel)
			{
				//SAFE_RELEASE((*iter).pIntAddr);
				//SAFE_RELEASE((*iter).pExtAddr);
				// (*iter).pChannel->decRef();

				WARNING_MSG(boost::format("Components::removeComponentFromChannel: %1% : %2%.\n") %
					COMPONENT_NAME_EX(componentType) % (*iter).cid);

#if KBE_PLATFORM == PLATFORM_WIN32
				printf("[WARNING]: %s.\n", (boost::format("Components::removeComponentFromChannel: %1% : %2%.\n") %
					COMPONENT_NAME_EX(componentType) % (*iter).cid).str().c_str());
#endif
				iter = components.erase(iter);
				return;
			}
			else
				iter++;
		}
	}

	// KBE_ASSERT(false && "channel is not found!\n");
}