コード例 #1
0
ファイル: ThreatManager.cpp プロジェクト: MobileDev/P-Core
void HostileReference::addThreat(float fModThreat)
{
    iThreat += fModThreat;
    // the threat is changed. Source and target unit have to be available
    // if the link was cut before relink it again
    if (!isOnline())
        updateOnlineStatus();
    if (fModThreat != 0.0f)
    {
        ThreatRefStatusChangeEvent event(UEV_THREAT_REF_THREAT_CHANGE, this, fModThreat);
        fireStatusChanged(event);
    }

    if (isValid() && fModThreat >= 0.0f)
    {
        Unit* victim_owner = getTarget()->GetCharmerOrOwner();
        if (victim_owner && victim_owner->isAlive())
            getSource()->addThreat(victim_owner, 0.0f);     // create a threat to the owner of a pet, if the pet attacks
    }
}
コード例 #2
0
 void OpenALRenderableSource::attachALBuffers()
     throw(Exception)
 {
     if (!alBuffersAttached) {
         SharedPtr<Sound> sound = getSource()->getSound();
         
         if (!sound->isLoaded())
             sound->load();
         
         assert(!sound->isStreaming() && "OpenALRenderableSource can only handle streaming sounds");
         
         // Attachment to a simple sound, just assign the AL buffer to this AL source
         ALBufferHandle alBuffer = dynamic_cast<OpenALSimpleSound*>(sound.get())->getAlBuffer();
         ALSourceHandle alSource = getALSource();
         alSourcei(alSource, AL_BUFFER, alBuffer);
         alBuffersAttached = true;
         
         checkAlError();
     }
 }
コード例 #3
0
ファイル: Graph.c プロジェクト: hellolgq/Graph-ADT
/*  getPath */
void getPath(ListRef L, GraphRef G, int u){
   int w;

   makeEmpty(L);
   if(getSource(G) == 0){
      printf("Graph Error: calling getPath() on graph without running BFS \n");
      exit(1);
   }
   if(G->color[u] == 1){
      return;
   }
   else{
      insertFront(L, u);
      w = u;
      while(G->distance[w] > 0){
         insertFront(L, G->parent[w]);
         w = G->parent[w];
      }
   }     
}
コード例 #4
0
ファイル: SourceHDF5.cpp プロジェクト: G-Node/nix
bool SourceHDF5::deleteSource(const string &name_or_id) {
    boost::optional<H5Group> g = source_group();
    bool deleted = false;
    
    if(g) {
        // call deleteSource on sources to trigger recursive call to all sub-sources
        if (hasSource(name_or_id)) {
            // get instance of source about to get deleted
            Source source = getSource(name_or_id);
            // loop through all child sources and call deleteSource on them
            for(auto &child : source.sources()) {
                source.deleteSource(child.id());
            }
            // if hasSource is true then source_group always exists
            deleted = g->removeAllLinks(source.name());
        }
    }

    return deleted;
}
コード例 #5
0
  OutputVlcStream::OutputVlcStream(Encre<libvlc_instance_t>* encre) : VlcStream(encre), m_videoSource(""), m_soundSource("")
  {
    std::string media;
    bool sound = false;

    if (!getSource() || (m_videoSource == "" && m_soundSource == ""))
      throw "exception to catch in the instance of encre"; //TODO : a better exception
    if (m_videoSource != "" && m_soundSource == "")
      media = m_videoSource;
    else if (m_videoSource == "" && m_soundSource != "")
      media = m_soundSource;
    else
      {
	media = m_videoSource;
	sound = true;
      }
    m_media = libvlc_media_new_location(m_encre->getData(), media.c_str());
    if (sound)
      setOptions(m_soundSource);
  }
コード例 #6
0
int ODataObjectModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 18)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 18;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = getSource(); break;
        case 1: *reinterpret_cast< QVariant*>(_v) = getModel(); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setSource(*reinterpret_cast< QString*>(_v)); break;
        case 1: setModel(*reinterpret_cast< QVariant*>(_v)); break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 2;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
コード例 #7
0
void CommonTransitions::paintAlpha( shared_ptr<Graphics> graphics )
{
	// this will always be invoked on the EDT so there is no race condition risk
	if(rgbBuffer.get() != NULL || secondaryBuffer.get() != NULL) {
		shared_ptr<Component> src = getSource();
		int w = src->getWidth();
		int h = src->getHeight();
		int position = this->position;
		if (position > 255) {
			position = 255;
		} else {
			if (position < 0) {
				position = 0;
			}
		}
		if(secondaryBuffer.get() != NULL) {
			shared_ptr<Component> dest = getDestination();                
			int x = dest->getAbsoluteX();
			int y = dest->getAbsoluteY();

			graphics->drawImage(buffer, x, y);
			graphics->setAlpha(position);
			graphics->drawImage(secondaryBuffer, x, y);
			graphics->setAlpha(0xff);
		} else {
			int alpha = position << 24;
			int size = w * h;
			shared_ptr<VectorArray<int>> bufferArray = rgbBuffer->getRGB();
			for (int iter = 0 ; iter < size ; iter++) {
				(*bufferArray)[iter] = (((*bufferArray)[iter] & 0xFFFFFF) | alpha);
			}
			shared_ptr<Component>  dest = getDestination();                
			int x = dest->getAbsoluteX();
			int y = dest->getAbsoluteY();
			graphics->drawImage(buffer, x, y);
			graphics->drawImage(rgbBuffer, x, y);
		}
	} 

}
コード例 #8
0
ファイル: GraphTest.c プロジェクト: FernandoC/BFS
int main(int argc, char* argv[]){
    if( argc != 2 ){
        printf("Usage: %s output\n", argv[0]);
        exit(1);
    }

    FILE *out;
    out = fopen(argv[1], "w");

    GraphRef G = newGraph(10);
    ListRef path = newList();
    int i;
    for( i = 1; i<= 9; i++){
        addEdge(G, i, i+1);
    }
    printGraph(out, G);

    BFS(G, 1); 

    fprintf(out, "Source of G is %d\n", getSource(G));

    fprintf(out, "Order of G is %d\n", getOrder(G));
    fprintf(out, "BFS called on Graph G with 1 as the source\n");

    getPath(path, G,  10);
    fprintf(out, "The path from 1 to 10 is:");
    printList(out, path);

    fprintf(out, "Parent of 10: %d\n", getParent(G, 10));
    fprintf(out, "Parent of 2: %d\n", getParent(G, 2));

    int dist = getDist(G, 1);
    fprintf(out, "Distance from 1 to 1 is %d\n", dist);
    fprintf(out, "Distance from 1 to 7 is %d\n", getDist(G, 7));

    freeList(&path);
    fclose(out);
    return(0);
}
コード例 #9
0
ファイル: skill.cpp プロジェクト: dhl/frePPLe
DECLARE_EXPORT void Skill::writeElement(XMLOutput *o, const Keyword& tag, mode m) const
{
  // Write a reference
  if (m == REFERENCE)
  {
    o->writeElement(tag, Tags::tag_name, getName());
    return;
  }

  // Write the head
  if (m != NOHEAD && m != NOHEADTAIL)
    o->BeginObject(tag, Tags::tag_name, XMLEscape(getName()));

  // Write source field
  o->writeElement(Tags::tag_source, getSource());

  // Write the custom fields
  PythonDictionary::write(o, getDict());

  // Write the tail
  if (m != NOHEADTAIL && m != NOTAIL) o->EndObject(tag);
}
コード例 #10
0
void Style::recalculate(float z) {
    for (const auto& source : sources) {
        source->enabled = false;
    }

    zoomHistory.update(z, data.getAnimationTime());

    StyleCalculationParameters parameters(z,
                                          data.getAnimationTime(),
                                          zoomHistory,
                                          data.getDefaultFadeDuration());

    for (const auto& layer : layers) {
        hasPendingTransitions |= layer->recalculate(parameters);

        Source* source = getSource(layer->source);
        if (source && layer->needsRendering()) {
            source->enabled = true;
            if (!source->loaded && !source->isLoading()) source->load();
        }
    }
}
コード例 #11
0
ファイル: TransferRequest.cpp プロジェクト: Votsh/waves
*/
void TransferRequest::print( ATP_TransferRequest_t * frame ){
	Log.Debug("TransferRequest object:"CR);

	if ( getFrameType(frame) == ATP_TRANSFER_REQUEST ) Log.Debug("type:        ATP_TRANSFER_REQUEST"CR );
	if ( getFrameType(frame) == ATP_CHUNK_REQUEST ) Log.Debug(   "type:        ATP_CHUNK_REQUEST"CR );
	if ( getFrameType(frame) == ATP_CHUNK_RESPONSE ) Log.Debug("type:        ATP_CHUNK_RESPONSE"CR );

	Log.Debug("frameID:       %s"CR, getFrameID(frame));
	Log.Debug("frameType:     %d"CR, getFrameType(frame));	
	Log.Debug("meshAddress:   %l"CR, getMeshAddress(frame));	
	Log.Debug("datetime:      %l"CR, getDatetime(frame));	
	Log.Debug("atpID:         %l"CR, getAtpID(frame)); 	
	Log.Debug("version:       %d"CR, getVersion(frame));
	Log.Debug("topchunk:      %d"CR, getTopChunk(frame));
	Log.Debug("chunkcount:    %d"CR, getChunkCount(frame));

	if ( getStatus(frame) == ATP_IDLE ) Log.Debug(                 "status:        ATP_IDLE"CR );
	if ( getStatus(frame) == ATP_SUCCESS ) Log.Debug(              "status:        ATP_SUCCESS"CR );
	if ( getStatus(frame) == ATP_FAILED_DURING_TRANSIT ) Log.Debug("status:        ATP_FAILED_DURING_TRANSIT"CR );
	if ( getStatus(frame) == ATP_FAILED_CHECKSUM ) Log.Debug(   "status:        ATP_FAILED_CHECKSUM"CR );
	if ( getStatus(frame) == ATP_FAILED_ENCRYPTION ) Log.Debug( "status:        ATP_FAILED_ENCRYPTION"CR );
	if ( getStatus(frame) == ATP_FAILED_COMPRESSION ) Log.Debug("status:        ATP_FAILED_COMPRESSION"CR );
	if ( getStatus(frame) == ATP_UNSENT ) Log.Debug(            "status:        ATP_UNSENT"CR );
	if ( getStatus(frame) == ATP_SENT ) Log.Debug(              "status:        ATP_SENT"CR );
	if ( getStatus(frame) == ATP_RECEIVED ) Log.Debug(          "status:        ATP_RECEIVED"CR );
	if ( getStatus(frame) == ATP_WORKING ) Log.Debug(          "status:        ATP_WORKING"CR );
	
	Log.Debug("size:          %l"CR, getSize(frame));
	Log.Debug("expires:       %l"CR, getExpires(frame));	
	Log.Debug("descriptor:    %s"CR, getDescriptor(frame));	
	Log.Debug("source:        %l"CR, getSource(frame));	
	Log.Debug("destination:   %l"CR, getDestination(frame));	
	Log.Debug("fileName:      %s"CR, getFileName(frame));
	
	if ( getBuffer(frame) != 0 ){
		Log.Debug("buffer:      %s"CR, getBuffer(frame));
	}
コード例 #12
0
ファイル: style.cpp プロジェクト: whztt07/mapbox-gl-native
void Style::recalculate(float z, TimePoint now) {
    uv::writelock lock(mtx);

    for (const auto& source : sources) {
        source->enabled = false;
    }

    zoomHistory.update(z, now);

    for (const auto& layer : layers) {
        layer->updateProperties(z, now, zoomHistory);
        if (!layer->bucket) {
            continue;
        }

        util::ptr<Source> source = getSource(layer->bucket->source);
        if (!source) {
            continue;
        }

        source->enabled = true;
    }
}
コード例 #13
0
ファイル: Message.cpp プロジェクト: Aero348/dune
    bool
    Message::operator==(const Message& other) const
    {
      if (getId() != other.getId())
        return false;

      if (getTimeStamp() != other.getTimeStamp())
        return false;

      if (getSource() != other.getSource())
        return false;

      if (getSourceEntity() != other.getSourceEntity())
        return false;

      if (getDestination() != other.getDestination())
        return false;

      if (getDestinationEntity() != other.getDestinationEntity())
        return false;

      return fieldsEqual(other);
    }
コード例 #14
0
// is any literal in this expr safely coercible to its target type?
NABoolean Assign::isSafelyCoercible(CacheWA &cwa) const
{
  if (cwa.getPhase() >= CmpMain::BIND) {
    // we have to disallow caching of the following types of updates:
    //   update t set col = overlylongliteral
    ItemExpr *src = getSource().getItemExpr();
    if (src->getOperatorType() == ITM_CONSTANT) {
      // source is a literal; make sure this update is cacheable only if
      // literal can be safely coerced into its target type.
      return ((ConstValue*)src)->canBeSafelyCoercedTo(getTarget().getType());
    }      
    else { // source is not a literal
      // we need to descend into this expr to verify that no 
      // errors can occur during backpatching. For example, 
      //   update t set i = i + 123456789012345678901234567890
      // should not be cacheable if i is a smallint.
      // reject "update t set c=(subquery)" as noncacheable
      // as part of a fix to CR 10-020108-8401.
      return src->isSafelyCoercible(cwa) && src->isCacheableExpr(cwa);
    }
  }
  return FALSE;
}
コード例 #15
0
ファイル: style.cpp プロジェクト: jcrocker/mapbox-gl-native
void Style::recalculate(float z) {
    uv::writelock lock(mtx);

    for (const auto& source : sources) {
        source->enabled = false;
    }

    zoomHistory.update(z, data.getAnimationTime());

    for (const auto& layer : layers) {
        layer->updateProperties(z, data.getAnimationTime(), zoomHistory);
        if (!layer->bucket) {
            continue;
        }

        Source* source = getSource(layer->bucket->source);
        if (!source) {
            continue;
        }

        source->enabled = true;
    }
}
コード例 #16
0
ファイル: ThreatManager.cpp プロジェクト: 43094361/server
void HostileReference::updateOnlineStatus()
{
    bool online = false;
    bool accessible = false;

    if (!isValid())
    {
        if (Unit* target = ObjectAccessor::GetUnit(*getSourceUnit(), getUnitGuid()))
        {
            link(target, getSource());
        }
    }
    // only check for online status if
    // ref is valid
    // target is no player or not gamemaster
    // target is not in flight
    if (isValid() &&
            ((getTarget()->GetTypeId() != TYPEID_PLAYER || !((Player*)getTarget())->isGameMaster()) ||
             !getTarget()->IsTaxiFlying()))
    {
        Creature* creature = (Creature*) getSourceUnit();
        online = getTarget()->isInAccessablePlaceFor(creature);
        if (!online)
        {
            if (creature->AI()->canReachByRangeAttack(getTarget()))
            {
                online = true;    // not accessable but stays online
            }
        }
        else
        {
            accessible = true;
        }
    }
    setAccessibleState(accessible);
    setOnlineOfflineState(online);
}
コード例 #17
0
        void SoundEmitter::changeParentSource()
        {
          InformationMessage("Sound", "SoundEmitter::changeParent : enter") ;

          Model::SoundEnvironnement* env = getObject()->getParent<Model::SoundEnvironnement>() ;
          if (env)
          {
            SoundEnvironnement* envView = env->getView<SoundEnvironnement>(m_viewpoint) ;
            if (envView)
            {
              ALuint auxEffectSlot = envView->getAuxEffectSlot() ;
              //SoundEnvironnement has changed
              if (auxEffectSlot != m_auxEffectSlot)
              {
                m_auxEffectSlot = auxEffectSlot;
                // @todo see filter parameter for occlusion , exclusion case
                EFX::applyEffectToSource(getSource(), m_auxEffectSlot) ;
                InformationMessage("Sound", "update add reverb") ;
              }
              else
              {
                InformationMessage("Sound", "same reverb") ;
              }
            }
            else
            {
              InformationMessage("Sound", "no envView") ;
            }
          }
          else
          {
            InformationMessage("Sound", "no environment") ;
          }

          InformationMessage("Sound", "SoundEmitter::changeParent : leaving") ;
        }
コード例 #18
0
ファイル: Graph.c プロジェクト: UVERkill/CMPS101
// getPath(): appends to the List L the vertices of a shortest path in G from source to u,
// or appends to L the value NIL if no such path exists
// Preconditions: getSource(G)!=NIL, 1<=u<=getOrder(G)
void getPath(List L, Graph G, int u) {
    if(L == NULL) {
        printf("Graph Error: calling getPath() on NULL List reference\n");
        exit(1);
    }
    if(G == NULL) {
        printf("Graph Error: calling getPath() on NULL Graph reference\n");
        exit(1);
    }
    if(getSource(G)==NIL) {
        printf("Graph Error: calling getPath() with NIL source\n");
        exit(1);
    }
    if(u<1 || u>getOrder(G)) {
        printf("Graph Error: calling getPath() with out of bounds value\n");
        exit(1);
    }
    if(G->source == u) {
        append(L, u);
    } else if(G->parent[u] != NIL) {
        getPath(L, G, G->parent[u]);
        append(L, u);
    }
}
コード例 #19
0
ファイル: publishertest.cpp プロジェクト: antmd/OpenMAMA
/*  Description: Create a mamaPublisher with event callbacks and mamaMsg, send the msg using 
 *               mamaPublisher then destroy both.
 *
 *  Expected Result: MAMA_STATUS_OK
 */
TEST_F (MamaPublisherTestC, EventSendWithCallbacks)
{
    mamaPublisher    publisher     = NULL;
    mamaTransport    tport         = NULL;
    const char*      symbol        = getSymbol();
    const char*      source        = getSource();
    mamaMsg          msg           = NULL;
    mamaQueue        queue         = NULL;
    mamaPublisherCallbacks* cb     = NULL;
    int              i             = 0;
    int              numPublishers = 10;

    pubOnCreateCount = 0;
    pubOnErrorCount = 0;
    pubOnDestroyCount = 0;

    mamaPublisherCallbacks_allocate(&cb);
    cb->onError = (mama_publisherOnErrorCb) pubOnError;
    cb->onCreate = (mama_publisherOnCreateCb) pubOnCreate;
    cb->onDestroy = (mama_publisherOnDestroyCb) pubOnDestroy;

    ASSERT_EQ (MAMA_STATUS_OK, mama_open());

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaMsg_create (&msg));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaMsg_addString (msg, symbol, 101, source));

    ASSERT_EQ (MAMA_STATUS_OK,
               mama_getDefaultEventQueue (mBridge, &queue));
 
    ASSERT_EQ (MAMA_STATUS_OK,
               mamaTransport_allocate (&tport));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaTransport_create (tport, getTransport(), mBridge));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaTransport_setTransportTopicCallback (tport, (mamaTransportTopicCB) transportTopicCb, NULL));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaPublisher_createWithCallbacks (&publisher, tport, queue, symbol, source, NULL, cb, NULL));

    for (i = 0; i < numPublishers; ++i)
    {
        ASSERT_EQ (MAMA_STATUS_OK,
                   mamaPublisher_send (publisher, msg));
    }

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaPublisher_destroy (publisher));

    ASSERT_EQ (MAMA_STATUS_OK,
               mamaTransport_destroy (tport));

    ASSERT_EQ (MAMA_STATUS_OK, mama_close());

    ASSERT_EQ (1, pubOnCreateCount);
    ASSERT_EQ (0, pubOnErrorCount);
    ASSERT_EQ (1, pubOnDestroyCount);

    mamaPublisherCallbacks_deallocate(cb);
}
コード例 #20
0
ファイル: style.cpp プロジェクト: CapeSepias/mapbox-gl-native
RenderData Style::getRenderData() const {
    RenderData result;

    for (const auto& source : sources) {
        if (source->enabled) {
            result.sources.insert(source.get());
        }
    }

    for (const auto& layer : layers) {
        if (layer->visibility == VisibilityType::None)
            continue;

        if (const BackgroundLayer* background = layer->as<BackgroundLayer>()) {
            if (layer.get() == layers[0].get() && background->paint.pattern.value.from.empty()) {
                // This is a solid background. We can use glClear().
                result.backgroundColor = background->paint.color;
                result.backgroundColor[0] *= background->paint.opacity;
                result.backgroundColor[1] *= background->paint.opacity;
                result.backgroundColor[2] *= background->paint.opacity;
                result.backgroundColor[3] *= background->paint.opacity;
            } else {
                // This is a textured background, or not the bottommost layer. We need to render it with a quad.
                result.order.emplace_back(*layer);
            }
            continue;
        }

        if (layer->is<CustomLayer>()) {
            result.order.emplace_back(*layer);
            continue;
        }

        Source* source = getSource(layer->source);
        if (!source) {
            Log::Warning(Event::Render, "can't find source for layer '%s'", layer->id.c_str());
            continue;
        }

        for (auto tile : source->getTiles()) {
            if (!tile->data || !tile->data->isReady())
                continue;

            // We're not clipping symbol layers, so when we have both parents and children of symbol
            // layers, we drop all children in favor of their parent to avoid duplicate labels.
            // See https://github.com/mapbox/mapbox-gl-native/issues/2482
            if (layer->is<SymbolLayer>()) {
                bool skip = false;
                // Look back through the buckets we decided to render to find out whether there is
                // already a bucket from this layer that is a parent of this tile. Tiles are ordered
                // by zoom level when we obtain them from getTiles().
                for (auto it = result.order.rbegin(); it != result.order.rend() && (&it->layer == layer.get()); ++it) {
                    if (tile->id.isChildOf(it->tile->id)) {
                        skip = true;
                        break;
                    }
                }
                if (skip) {
                    continue;
                }
            }

            auto bucket = tile->data->getBucket(*layer);
            if (bucket) {
                result.order.emplace_back(*layer, tile, bucket);
            }
        }
    }

    return result;
}
コード例 #21
0
void HostileReference::fireStatusChanged(ThreatRefStatusChangeEvent& pThreatRefStatusChangeEvent)
{
    if (getSource())
        getSource()->processThreatEvent(&pThreatRefStatusChangeEvent);
}
コード例 #22
0
int main(int argc, char * argv[]){
   int count=0;
   //int check = 0;
   int u, v;
   FILE *in, *out;
   char line[MAX_LEN];
   char* token;
   Graph G;
   List path = newList();

   // check command line for correct number of arguments
   if( argc != 3 ){
      printf("Usage: %s <input file> <output file>\n", argv[0]);
      exit(1);
   }

   // open files for reading and writing 
   in = fopen(argv[1], "r");
   out = fopen(argv[2], "w");
   if( in==NULL ){
      printf("Unable to open file %s for reading\n", argv[1]);
      exit(1);
   }
   if( out==NULL ){
      printf("Unable to open file %s for writing\n", argv[2]);
      exit(1);
   }

   /* read each line of input file, then count and print tokens */
   while(fgets(line, MAX_LEN, in) != NULL)  {
      count++;
	  // char *strtok(char *str, const char *delim) breaks string str into
	  // a series of tokens using the delimitrer delim. This function returns a pointer to the
	  // last token found in string. A null pointer is returned if there are no tokens left to retrieve.
      token = strtok(line, " \n");
	  
	  // int atoi(const char *str), This function returns the converted integral number as an int value.
	  // If no valid conversion could be performed, it returns zero.
	  // It converts char to int.
	  if(count == 1) {
	     // Takes in the first number as a token, sets a graph of that size
	     G = newGraph(atoi(token));
	  }
	  else {
	     // Here we want to read in both numbers
		 u = atoi(token);
		 token = strtok(NULL, " \n");
		 v = atoi(token);
		 if( u != 0 || v != 0) {
		       addEdge(G, u, v);
	     }		   
         else if (u == 0 && v == 0) {
		       //check = 1;
         }			   
      } 
   }
   printGraph(out, G);
   

   while( fgets(line, MAX_LEN, in) != NULL)  {
	  token = strtok(line, " \n");
      u = atoi(token);
      token = strtok(NULL, " \n");
	  v = atoi(token);
	  if( u != NIL) {
		 BFS(G, u);
	     clear(path);
		 getPath(path, G, v);
		 if(u != NIL ) {
		    fprintf(out, "The distance from %d to %d is %d\n", getSource(G), v, getDist(G, v));
			fprintf(out, "A shortest %d-%d path is: ", getSource(G), v);
			printList(out, path);
			fprintf(out, "\n");
		 }
	     else {
			fprintf(out, "There is no %d-%d path", getSource(G), v);
			fprintf(out, "\n");
	     }
      }
   }
	  
   freeGraph(&G);	
   freeList(&path);

   /* close files */
   fclose(in);
   fclose(out);

   return(0);
}
コード例 #23
0
ファイル: SavedStacks.cpp プロジェクト: JasonGross/mozjs
bool
SavedFrame::isSelfHosted()
{
    JSAtom *source = getSource();
    return StringEqualsAscii(source, "self-hosted");
}
コード例 #24
0
ファイル: InputService.cpp プロジェクト: noriter/nit
bool InputEvent::isRelated(InputSource* source) const
{
	return (getSource() == source) || (_related && _related->isRelated(source));
}
コード例 #25
0
void LayerBuffer::postBuffer(ssize_t offset)
{
    sp<Source> source(getSource());
    if (source != 0)
        source->postBuffer(offset);
}
コード例 #26
0
ファイル: MamaPublisherTest.cpp プロジェクト: antmd/OpenMAMA
/**
 * Test publish with callbacks
 */
TEST_F(MamaPublisherTest, PublishWithCallbacks)
{
    int numPublishes = 10;
	int waits = 0;

    // Create a callback object
    TestCallback *testCallback = new TestCallback();

    // Allocate a publisher
    MamaPublisher *publisher = new MamaPublisher();

    // Get the default queue
    MamaQueue *queue = Mama::getDefaultEventQueue(m_bridge);

    // Create the publisher
    publisher->createWithCallbacks(m_transport, queue, testCallback, NULL, getSymbol(), getSource(), NULL);

    // Process messages until the first message is received
    Mama::startBackground(m_bridge, this);

    MamaMsg* msg = new MamaMsg();
    msg->create();
    msg->addU8("", MamaFieldMsgType.mFid, MAMA_MSG_TYPE_INITIAL);
    msg->addU8("", MamaFieldMsgStatus.mFid, MAMA_MSG_STATUS_OK);
    msg->addString("", 11, "TEST STRING");    // MdFeedName

    for (int i = 0; i < numPublishes; ++i)
    {
        publisher->send(msg);
    }

    sleep(1);

    // Destroy the publisher
    publisher->destroy();            

    // Wait for onDestroy
	while (testCallback->getOnDestroyCount() == 0)
	{
		if (waits++ > 10) break;    /* way too long to wait for onDestroy */
        sleep(1);
	}
    ASSERT_EQ(1, testCallback->getOnDestroyCount());

    delete publisher;
    delete queue;

    Mama::stop(m_bridge);

    ASSERT_EQ(1, testCallback->getOnCreateCount());
    ASSERT_EQ(0, testCallback->getOnErrorCount());

    delete testCallback;
}
コード例 #27
0
Unit* HostileReference::getSourceUnit()
{
    return (getSource()->getOwner());
}
コード例 #28
0
ファイル: PacketHandler.cpp プロジェクト: DarrenRainey/nfpvr
void PacketHandler::handleFilename(const uint8* data, int length)
{
	const char* extension = "mpg";
	const char* path = 0;

	char number[5], channel[6];

	bool hasDetails = Utility::extractNumberChannel((const char*)data, length,
		number, sizeof(number),
		channel, sizeof(channel));
	
	const char* filename = Utility::composeDatedFilename(extension, hasDetails, number, channel);
	const char* outputDirectory = _nfpvrInterface.getOptions()._outputDirectory;

	// copy filename locally
	strncpy(_mpegFilename, filename, sizeof(_mpegFilename)-1);

	if (outputDirectory)
	{
		path = Utility::composePath(outputDirectory, filename);
	}
	else
	{
		path = filename;
	}

	if (_nfpvrInterface.getOptions()._writeMpeg)
	{
		_pMpegFile->open(path);

		if (_pMpegFile->isOpened())
		{
			_nfpvrInterface.notify(INfpvrInterface::NotifyMessage, "Started recording on \"%s\" from %s", path, getSource());
		}
		else
		{
			_nfpvrInterface.notify(INfpvrInterface::NotifyError, "Can't open mpeg file \"%s\"", path);
		}
	}
	else
	{
		_nfpvrInterface.notify(INfpvrInterface::NotifyMessage, "Simulating recording on \"%s\"", path);
	}

	if (hasDetails)
		_nfpvrInterface.notifyStartRecording(_mpegFilename, number, channel);
	else
		_nfpvrInterface.notifyStartRecording(_mpegFilename);

	sendFilenameReply();
}
コード例 #29
0
void FollowerReference::sourceObjectDestroyLink()
{
    getSource()->stopFollowing();
}
コード例 #30
0
ファイル: GraphTest.c プロジェクト: jszalaha/CMPS-101-Java-C
int main(int argc, char * argv[]){

    List path = newList();

    Graph G = newGraph(5);
    Graph H = newGraph(10);

    printf("%d\n", getOrder(G));
    printf("%d\n", getOrder(H));
    printf("%d\n", getSize(G));

    for(int i = 1; i < getOrder(G)-1; i++){
        addEdge(G, i, i+1);
        printf("%d\n", getSize(G));
    }
    printf("%d\n", getSize(G));

    printf("%d\n", getSize(H));
    for(int i = 1; i < getOrder(H)-2; i++){
        addEdge(H, i, i+1);
        addEdge(H, i, i+2);
    }
    printf("%d\n", getSize(H));

    printf("%d\n", getSource(G));
    printf("%d\n", getParent(G, 5));
    printf("%d\n", getDist(G, 5));
    printGraph(stdout, G);

    printf("%d\n", getSource(H));
    printf("%d\n", getParent(H, 10));
    printf("%d\n", getDist(H, 10));
    printGraph(stdout, H);

    BFS(G, 1);
    printf("%d\n", getSource(G));
    printf("%d\n", getParent(G, 5));
    printf("%d\n", getDist(G, 5));

    getPath(path, G, 5);
    printList(stdout, path);

    clear(path);
    printList(stdout, path);

    BFS(H, 5);
    printf("\n");
    printf("%d\n", getSource(H));
    printf("%d\n", getParent(H, 10));
    printf("%d\n", getDist(H, 10));
    printf("%d\n", getParent(H, 8));
    printf("%d\n", getParent(H, 6));
    printf("%d\n", getParent(H, 5));

    getPath(path, H, 10);
    printList(stdout, path);

    makeNull(G);
    makeNull(H);
    printf("%d\n", getSize(G));
    printf("%d\n", getSize(H));

    freeGraph(&G);
    freeGraph(&H);
    freeList(&path);

    printf("globalAlloc = %d\n", globalAlloc);

    return 0;
}