Exemplo n.º 1
0
////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  NAME:        ACDCallManager::removeCallFromMap
//
//  SYNOPSIS:    delete the ACDCall reference from the given HashMap
//
//  DESCRIPTION:
//
//  RETURNS:     None.
//
//  ERRORS:      None.
//
//  CAVEATS:     None.
//
////////////////////////////////////////////////////////////////////////////////////////////////////
void ACDCallManager::removeCallFromMap(ACDCall *pCallRef,
   UtlHashMap *pMap, char *mapName)
{
   mLock.acquire();

   UtlHashMapIterator mapIterator(*pMap);
   ACDCall* pACDCall = NULL;
   UtlInt* pTemp = NULL;
   UtlContainable* pKey;

   while ((pTemp = (UtlInt*)mapIterator()) != NULL) {
      pACDCall = (ACDCall*)pMap->findValue(pTemp);
      if(pACDCall == pCallRef ) {
         OsSysLog::add(FAC_ACD, gACD_DEBUG,
            "ACDCallManager::removeCallFromMap(%s) - removed ACDCall(%p) matching hCall=%" PRIdPTR,
               mapName, pACDCall, pTemp->getValue());
         pKey = pMap->removeReference(pTemp);
         if (pKey != NULL) {
            if (pMap != &mDeadCallHandleMap) {
               // Add it to the "dead" list so we know to ignore messages
               // from it Yet can tell it isn't "unknown".
               addDeadCallToMap(pTemp->getValue(), pCallRef) ;
            }
            delete pKey ;
         }
      }
   }
   mLock.release();
}
Exemplo n.º 2
0
////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  NAME:        ACDCallManager::verifyCallInMap
//
//  SYNOPSIS:    check if the ACDCall reference is in the given HashMap
//
//  DESCRIPTION:
//
//  RETURNS:     None.
//
//  ERRORS:      None.
//
//  CAVEATS:     None.
//
////////////////////////////////////////////////////////////////////////////////////////////////////
bool ACDCallManager::verifyCallInMap(ACDCall *pCallRef,
   UtlHashMap *pMap, char *mapName)
{
   mLock.acquire();

   UtlHashMapIterator mapIterator(*pMap);
   ACDCall* pACDCall = NULL;
   UtlInt* pTemp = NULL;
   bool found = false ;

   while ((pTemp = (UtlInt*)mapIterator()) != NULL) {
      pACDCall = (ACDCall*)pMap->findValue(pTemp);
      if(pACDCall == pCallRef ) {
         found = true ;
         break ;
         }
      }

   if (found) {
      OsSysLog::add(FAC_ACD, gACD_DEBUG,
         "ACDCallManager::verifyCallInMap(%s) - found ACDCall(%p)",
            mapName, pCallRef);
   }
   else {
      OsSysLog::add(FAC_ACD, gACD_DEBUG,
         "ACDCallManager::verifyCallInMap(%s) - did not find ACDCall(%p)",
            mapName, pCallRef);
   }
   mLock.release();

   return found ;
}
Exemplo n.º 3
0
void loadTranslator(void)
{
	
        char *lang=NULL;
        bool autoSelect=true;
        if(prefs->get(DEFAULT_LANGUAGE,&lang))
        {
            if(lang && strlen(lang)>0 && strcmp(lang,"auto"))
                autoSelect=false;
        }
        if(autoSelect)
        {
            ADM_info("Using system language\n");
            lang=ADM_strdup(QLocale::system().name().toUtf8().constData());
        }else
        {
            ADM_info("Language forced \n");
        }
        ADM_info("Initializing language %s\n",lang);
#ifdef __APPLE__
	QString appdir = QCoreApplication::applicationDirPath() + "/../share/avidemux6/i18n/";
                
#elif defined(_WIN32)
	QString appdir = QCoreApplication::applicationDirPath() + "/i18n/";
#else
	QString appdir = ADM_getInstallRelativePath("share","avidemux6","i18n");
#endif
        QString languageFile=QString(lang);
    int nbLoaded=0;
	nbLoaded+=loadTranslation(&qtTranslator, appdir + "qt_" + languageFile);
	nbLoaded+=loadTranslation(&avidemuxTranslator, appdir + "avidemux_" + languageFile);
	translatorLoaded = true;
    if(!nbLoaded) // Nothing to translate..
        return;
    ADM_info("Updating translations...\n");
	// Re-translate existing map (to take care of global strings already allocated)
        if(!map)
            map = new QMap<QString, char*>;
	QMapIterator<QString, char*> mapIterator(*map);

	while (mapIterator.hasNext())
	{
		mapIterator.next();

		QByteArray translatedMessage = QApplication::translate("", mapIterator.key().toAscii().constData()).toUtf8();
		char *buffer = mapIterator.value();
		int copyLength = translatedMessage.length() + 1;

		if (copyLength > MAX_UNLOADED_MSG_LENGTH + 1)
		{
			copyLength = MAX_UNLOADED_MSG_LENGTH;
			buffer[MAX_UNLOADED_MSG_LENGTH] = '\0';
		}

		memcpy(buffer, translatedMessage.constData(), copyLength);
	}

	ADM_info("[Locale] Test: &Edit -> %s\n\n", HIDE_STRING_FROM_QT("MainWindow", "&Edit").toUtf8().data());
        
}
Exemplo n.º 4
0
void CalibrateFlossDlg::on_DialogButtonBox_accepted()
{
    commitColor();

    QMapIterator<QString, ChangedColors> mapIterator(m_calibratedColors);

    while (mapIterator.hasNext()) {
        mapIterator.next();

        if (mapIterator.value().count()) {
            FlossScheme *scheme = SchemeManager::scheme(mapIterator.key());
            QListIterator<Floss *> flossIterator(scheme->flosses());

            while (flossIterator.hasNext()) {
                Floss *f = flossIterator.next();

                if (mapIterator.value().contains(f->name())) {
                    f->setColor(mapIterator.value()[f->name()]);
                }
            }

            SchemeManager::writeScheme(mapIterator.key());
        }
    }

    accept();
}
Exemplo n.º 5
0
ACDCall* ACDCallManager::getAcdCallByCallId(UtlString callId) {
   UtlHashMapIterator mapIterator(mCallHandleMap);
   ACDCall* pACDCall = NULL;
   UtlInt* pTemp = NULL;

   while ((pTemp = (UtlInt*)mapIterator()) != NULL) {
      OsSysLog::add(FAC_ACD, gACD_DEBUG, "ACDCallManager::getAcdCallByCallId - looking at call handle=%d",pTemp->getValue());
      pACDCall = (ACDCall*)mCallHandleMap.findValue(pTemp);

      if(pACDCall && pACDCall->getCallId() == callId ) {
         OsSysLog::add(FAC_ACD, gACD_DEBUG, "ACDCallManager::getAcdCallByCallId - found ACDCall matching callid=%s",callId.data());
         return pACDCall;
      }
   }

   OsSysLog::add(FAC_ACD, gACD_DEBUG, "ACDCallManager::getAcdCallByCallId - could not find ACDCall matching callid=%s",callId.data());
   return NULL;
}
Exemplo n.º 6
0
QString Mapper::find(const int n)
{
  QDictIterator<int> mapIterator(m_map);
  for (int *curVal = mapIterator.toFirst();(curVal = mapIterator.current());++mapIterator)
  {
    if (*curVal == n || (*curVal == (n | SIMPLESECT_BIT))) return mapIterator.currentKey();
  }
  return NULL;
}
Exemplo n.º 7
0
void destroyTranslator(void)
{
	if (map)
	{
		QMapIterator<QString, char*> mapIterator(*map);

		while (mapIterator.hasNext())
		{
			mapIterator.next();
			delete [] mapIterator.value();
		}

		delete map;
	}
}
Exemplo n.º 8
0
uint32_t
FrontEnd::calculateSizeOfStackAtlas(
      bool encodeFourByteOffsets,
      uint32_t numberOfSlotsMapped,
      uint32_t bytesPerStackMap,
      TR::Compilation *comp)
   {
   TR::CodeGenerator *cg = comp->cg();
   TR::GCStackAtlas * stackAtlas = cg->getStackAtlas();

   // Calculate the size of each individual map in the atlas.  The fixed
   // portion of the map contains:
   //
   //    Low Code Offset (2 or 4)
   //    Stack map (depends on # of mapped parms/locals)
   //
   uint32_t sizeOfEncodedCodeOffsetInBytes = encodeFourByteOffsets ? 4 : 2;
   uint32_t sizeOfSingleEncodedMapInBytes = sizeOfEncodedCodeOffsetInBytes;
   sizeOfSingleEncodedMapInBytes += bytesPerStackMap;

   // Calculate the atlas size
   //
   uint32_t atlasSize = sizeof(OMR::StackAtlasPOD);

   ListIterator<TR_GCStackMap> mapIterator(&stackAtlas->getStackMapList());
   TR_GCStackMap *mapCursor = mapIterator.getFirst();

   while (mapCursor != NULL)
      {
      TR_GCStackMap *nextMapCursor = mapIterator.getNext();

      if (!mapsAreIdentical(mapCursor, nextMapCursor, stackAtlas, comp))
         {
         atlasSize += sizeOfSingleEncodedMapInBytes;
         }

      mapCursor = nextMapCursor;
      }

   return atlasSize;
   }
Exemplo n.º 9
0
void GridMapRosConverter::toPointCloud(const grid_map::GridMap& gridMap,
                                       const std::vector<std::string>& layers,
                                       const std::string& pointLayer,
                                       sensor_msgs::PointCloud2& pointCloud)
{
  // Header.
  pointCloud.header.frame_id = gridMap.getFrameId();
  pointCloud.header.stamp.fromNSec(gridMap.getTimestamp());
  pointCloud.is_dense = false;

  // Fields.
  std::vector <std::string> fieldNames;

  for (const auto& layer : layers) {
    if (layer == pointLayer) {
      fieldNames.push_back("x");
      fieldNames.push_back("y");
      fieldNames.push_back("z");
    } else if (layer == "color") {
      fieldNames.push_back("rgb");
    } else {
      fieldNames.push_back(layer);
    }
  }

  pointCloud.fields.clear();
  pointCloud.fields.reserve(fieldNames.size());
  int offset = 0;

  for (auto& name : fieldNames) {
    sensor_msgs::PointField point_field;
    point_field.name = name;
    point_field.count = 1;
    point_field.datatype = sensor_msgs::PointField::FLOAT32;
    point_field.offset = offset;
    pointCloud.fields.push_back(point_field);
    offset = offset + point_field.count * 4;  // 4 for sensor_msgs::PointField::FLOAT32
  }

  // Resize.
  size_t nPoints = gridMap.getSize().prod();
  pointCloud.height = 1;
  pointCloud.width = nPoints;
  pointCloud.point_step = offset;
  pointCloud.row_step = pointCloud.width * pointCloud.point_step;
  pointCloud.data.resize(pointCloud.height * pointCloud.row_step);

  // Points.
  std::unordered_map<std::string, sensor_msgs::PointCloud2Iterator<float>> fieldIterators;
  for (auto& name : fieldNames) {
    fieldIterators.insert(
        std::pair<std::string, sensor_msgs::PointCloud2Iterator<float>>(
            name, sensor_msgs::PointCloud2Iterator<float>(pointCloud, name)));
  }

  GridMapIterator mapIterator(gridMap);

  for (size_t i = 0; i < nPoints; ++i) {
    Position3 position;
    position.setConstant(NAN);
    gridMap.getPosition3(pointLayer, *mapIterator, position);

    for (auto& iterator : fieldIterators) {
      if (iterator.first == "x") {
        *iterator.second = (float) position.x();
      } else if (iterator.first == "y") {
        *iterator.second = (float) position.y();
      } else if (iterator.first == "z") {
        *iterator.second = (float) position.z();
      } else if (iterator.first == "rgb") {
        *iterator.second = gridMap.at("color", *mapIterator);
      } else {
        *iterator.second = gridMap.at(iterator.first, *mapIterator);
      }
    }

    ++mapIterator;
    for (auto& iterator : fieldIterators) {
      ++iterator.second;
    }
  }
}
Exemplo n.º 10
0
QoreValue QoreHashMapOperatorNode::evalValueImpl(bool& needs_deref, ExceptionSink* xsink) const {
   ValueEvalRefHolder arg_lst(e[2], xsink);
   if (*xsink || arg_lst->isNothing())
      return QoreValue();
   
   qore_type_t arglst_type = arg_lst->getType();
   assert(arglst_type != NT_NOTHING);
   ReferenceHolder<QoreHashNode> ret_val(ref_rv ? new QoreHashNode : 0, xsink);
   if (NT_LIST != arglst_type) { // Single value
      // check if it's an AbstractIterator object
      if (NT_OBJECT == arglst_type) {
         AbstractIteratorHelper h(xsink, "hmap operator select", 
				  const_cast<QoreObject*>(arg_lst->get<const QoreObject>()));
         if (*xsink)
	    return QoreValue();
         if (h)
            return mapIterator(h, xsink); // TODO!!
	 // passed iterator
      }

      // check if value can be mapped
      ReferenceHolder<> arg_ival(arg_lst.getReferencedValue(), xsink);
      SingleArgvContextHelper argv_helper(*arg_ival, xsink);
      ValueEvalRefHolder arg_key(e[0], xsink);
      if (*xsink)
	 return QoreValue();

      ValueEvalRefHolder arg_val(e[1], xsink);
      if (*xsink)
	 return QoreValue();

      // we have to convert to a string in the default encoding to use a hash key
      QoreStringValueHelper str_util(*arg_key, QCS_DEFAULT, xsink);
      if (*xsink)
	 return QoreValue();
      
      // Insert key-Value pair to the hash
      ret_val->setKeyValue(str_util->getBuffer(), arg_val.getReferencedValue(), xsink);
   }
   else {// List of values
      ConstListIterator li(arg_lst->get<const QoreListNode>());
      while (li.next()) {
         // set offset in thread-local data for "$#"
         ImplicitElementHelper eh(li.index()); 
         SingleArgvContextHelper argv_helper(li.getValue(), xsink);

	 {
	    ValueEvalRefHolder ekey(e[0], xsink);
	    if (*xsink)
	       return QoreValue();

	    // we have to convert to a string in the default encoding to use a hash key
	    QoreStringValueHelper key(*ekey, QCS_DEFAULT, xsink);
	    if (*xsink)
	       return QoreValue();
	    
	    ValueEvalRefHolder val(e[1], xsink);
	    if (*xsink)
	       return QoreValue();

	    if (ref_rv)
	       ret_val->setKeyValue(key->getBuffer(), val.getReferencedValue(), xsink);
	 }
	 // if there is an exception dereferencing one of the evaluted nodes above, then exit the loop
	 if (*xsink)
	    return QoreValue();
      }
   }
   if (*xsink || !ref_rv)
      return QoreValue();

   return ret_val.release();
}
Exemplo n.º 11
0
uint8_t *
FrontEnd::createStackAtlas(
      bool encodeFourByteOffsets,
      uint32_t numberOfSlotsMapped,
      uint32_t bytesPerStackMap,
      uint8_t *encodedAtlasBaseAddress,
      uint32_t atlasSizeInBytes,
      TR::Compilation *comp)
   {
   TR::CodeGenerator *cg = comp->cg();
   TR::GCStackAtlas *stackAtlas = cg->getStackAtlas();

   stackAtlas->setAtlasBits(encodedAtlasBaseAddress);

   // Calculate the size of each individual map in the atlas.  The fixed
   // portion of the map contains:
   //
   //    Low Code Offset (2 or 4)
   //    Stack map (depends on # of mapped parms/locals)
   //
   uint32_t sizeOfEncodedCodeOffsetInBytes = encodeFourByteOffsets ? 4 : 2;

   uint32_t sizeOfSingleEncodedMapInBytes = sizeOfEncodedCodeOffsetInBytes;
   sizeOfSingleEncodedMapInBytes += bytesPerStackMap;

   // Encode the atlas
   //
   OMR::StackAtlasPOD *pyAtlas = (OMR::StackAtlasPOD *)encodedAtlasBaseAddress;
   pyAtlas->numberOfMaps = stackAtlas->getNumberOfMaps();
   pyAtlas->bytesPerStackMap = bytesPerStackMap;

   // Offset to the MAPPED pyFrameObject parameter
   //
   pyAtlas->frameObjectParmOffset = 0;

   // Lowest stack offset where MAPPED locals begin.
   //
   pyAtlas->localBaseOffset = stackAtlas->getLocalBaseOffset();

   // Abort if we have overflowed the fields in pyAtlas.
   //
   if (bytesPerStackMap > USHRT_MAX ||
       stackAtlas->getNumberOfMaps() > USHRT_MAX ||
       stackAtlas->getNumberOfParmSlotsMapped() > USHRT_MAX ||
       stackAtlas->getParmBaseOffset()  < SHRT_MIN || stackAtlas->getParmBaseOffset()  > SHRT_MAX ||
       stackAtlas->getLocalBaseOffset() < SHRT_MIN || stackAtlas->getLocalBaseOffset() > SHRT_MAX)
      {
      comp->failCompilation<TR::CompilationException>("Overflowed the fields in pyAtlas");
      }

   // Maps are in reverse order in list from what we want in the atlas
   // so advance to the address where the last map should go and start
   // building the maps moving back toward the beginning of the atlas.
   //
   uint8_t *cursorInEncodedAtlas = encodedAtlasBaseAddress + atlasSizeInBytes;

   ListIterator<TR_GCStackMap> mapIterator(&stackAtlas->getStackMapList());
   TR_GCStackMap *mapCursor = mapIterator.getFirst();

   while (mapCursor != NULL)
      {
      // Move back from the end of the atlas till the current map can be fit in,
      // then pass the cursor to the routine that actually creates and fills in
      // the stack map
      //
      TR_GCStackMap *nextMapCursor = mapIterator.getNext();

      if (!mapsAreIdentical(mapCursor, nextMapCursor, stackAtlas, comp))
         {
         cursorInEncodedAtlas -= sizeOfSingleEncodedMapInBytes;
         encodeStackMap(mapCursor, cursorInEncodedAtlas, encodeFourByteOffsets, bytesPerStackMap, comp);
         }

      mapCursor = nextMapCursor;
      }

   return encodedAtlasBaseAddress;
   }