ContentPtr Panel::getContent( const std::string contentID, int& index )
{
	for( TabItr i = tabList_.begin(); i != tabList_.end(); ++i )
	{
		Content* content = (*i)->getContent().getObject();
		if ( !content )
			continue;
		if ( contentID.compare( content->getContentID() ) == 0 )
		{
			if ( index <= 0 )
				return content;
			else
				index--;
		}
		else if ( content->getContentID() == ContentContainer::contentID &&
			((ContentContainer*)content)->contains( contentID ) )
		{
			content = ((ContentContainer*)content)->getContent( contentID, index ).getObject();
			if ( content )
				return content;
			// index already decremented by ContentContainer::getContent
		}
	}

	return 0;
}
Exemple #2
0
ContentPtr ContentFactory::createErrorContent(const Content& content)
{
    const auto& uri = content.getUri();
    const auto& size = content.getDimensions();

    return std::make_unique<ErrorContent>(uri, size);
}
int main()
{
#if 1
    Content * cont;     /// < 得到锦囊
    
    cont = new Content(new Backdoor());
    cont->operate();    /// < 开后门
    delete cont;

    cont = new Content(new Greelight());
    cont->operate();    /// < 开绿灯
    delete cont;

    cont = new Content(new BlockEnemy());
    cont->operate();    /// < 段后 
    delete cont;
#endif

    cout << "\n------------" << endl;

#if 1
    /// < 模板方式
    ContentT<Backdoor> contBck;
    contBck.operate();
    
    ContentT<Greelight> contGrl;
    contGrl.operate();
    
    ContentT<BlockEnemy> contBlk;
    contBlk.operate();
#endif

    return 0;
}
Exemple #4
0
	//method that's called when algorithm is registered                                                                                                                                                        
	//list input and output datasets here                                                                                                                                                                      
	static Algorithm* create() 
	{
		Content* algo = new Content();
		algo->addInputDataset("imagesIn");
		algo->addOutputDataset("imagesOut");
		return algo;
	}
Exemple #5
0
QPixmap
AtticaManager::iconForResolver( const Content& resolver )
{
    if ( !m_resolverStates[ resolver.id() ].pixmap )
        return QPixmap();

    return *m_resolverStates.value( resolver.id() ).pixmap;
}
 void Clear()
 {
   for (Content::iterator it = content_.begin();
        it != content_.end(); ++it)
   {
     delete *it;
   }
 }
	void ChannelPlayerAdapter::createPlayer() {
		Player* childPlayer = NULL;
		CompositeExecutionObject* cpExObj;
		ExecutionObject* childObj;
		vector<ExecutionObject*>* objects;
		map<string, Player*>* objectMap;
		Content* content;
		string mrlPlayer;
		string selectedObject = "";

		cpExObj = (CompositeExecutionObject*)object;
		objectMap = new map<string, Player*>; 
		objects = cpExObj->getExecutionObjects();

		if (objects != NULL && cpExObj->getDescriptor() != NULL) {
			vector<ExecutionObject*>::iterator i;
			i = objects->begin();
			while (i != objects->end()) {
				childObj = *i;
				if (childObj != NULL && childObj->getDataObject() != NULL &&
						childObj->getDataObject()->getDataEntity() != NULL &&
						((NodeEntity*)(childObj->getDataObject()->
							getDataEntity()))->getContent() != NULL) {

					content = ((NodeEntity*)(childObj->getDataObject()->
						    getDataEntity()))->getContent();

					if (content->instanceOf("ReferenceContent")) {
						mrlPlayer = ((ReferenceContent*)content)->
							    getCompleteReferenceUrl();

						childPlayer = new AVPlayer(mrlPlayer, hasVisual);
						(*objectMap)[childObj->
						             getDataObject()->getId()] = childPlayer;
					}
				}
				++i;
			}

			//cout << "ChannelPlayerAdapter::createPlayer objMap->size = ";
			//cout << objectMap->size() << endl;
			selectedObject = cpExObj->getDescriptor()->
				    getParameterValue("selectedObject");
		}

		if (objects != NULL) {
			delete objects;
			objects = NULL;
		}

		player = new ChannelPlayer(objectMap);
		if (selectedObject != "") {
			childPlayer = ((ChannelPlayer*)player)->getPlayer(selectedObject);
			((ChannelPlayer*)player)->select(childPlayer);
		}

		FormatterPlayerAdapter::createPlayer();
	}
 void Remove(const std::string& filename)
 {
   Content::iterator it = Find(filename);
   if (it != content_.end())
   {
     delete *it;
     content_.erase(it);
   }
 }
bool Panel::tabContains( TabPtr t, ContentPtr content )
{
	Content* tcontent = t->getContent().getObject();
	if ( !tcontent )
		return 0;
	
	return tcontent == content ||
			( tcontent->getContentID() == ContentContainer::contentID &&
			((ContentContainer*)tcontent)->contains( content ) );
}
Exemple #10
0
AtticaManager::ResolverState
AtticaManager::resolverState ( const Content& resolver ) const
{
    if ( !m_resolverStates.contains( resolver.id() ) )
    {
        return AtticaManager::Uninstalled;
    }

    return m_resolverStates[ resolver.id() ].state;
}
Exemple #11
0
std::unique_ptr<DataSource> DataSourceFactory::create(const Content& content)
{
    switch (content.getType())
    {
#if TIDE_ENABLE_MOVIE_SUPPORT
    case ContentType::movie:
        return std::make_unique<MovieUpdater>(content.getUri());
#endif

    case ContentType::pixel_stream:
#if TIDE_ENABLE_WEBBROWSER_SUPPORT
    case ContentType::webbrowser:
#endif
        return std::make_unique<PixelStreamUpdater>(content.getUri());
    case ContentType::svg:
        return std::make_unique<SVGTiler>(content.getUri(),
                                          content.getMaxDimensions());
    case ContentType::image:
        return std::make_unique<ImageSource>(content.getUri());

#if TIDE_ENABLE_PDF_SUPPORT
    case ContentType::pdf:
        return std::make_unique<PDFTiler>(content.getUri(),
                                          content.getMaxDimensions());
#endif

#if TIDE_USE_TIFF
    case ContentType::image_pyramid:
        return std::make_unique<ImagePyramidDataSource>(content.getUri());
#endif
    default:
        throw std::logic_error("No data source for this content type");
    }
}
Exemple #12
0
void Host::delete_content(int cid){
	std::vector<int>::iterator it;
	it = find(cids_.begin(), cids_.end(), cid);
	if(it!=cids_.begin())
		cids_.erase(it);

	/* Delete the content file */
	Content c;
	string filename = c.get_content_name_in_host(id_,cid);
	remove(filename.c_str());
}
// 0 -> not valid; 1 -> valid
int Xmlvalidator::checkNode(Item* node) {
	Tag* tagNode = dynamic_cast<Tag *>(node);

	if (tagNode) {
		string name = tagNode->getName();
		string transfo = "";

		vector<Item *> children = tagNode->getChildren();
		for(vector<Item *>::iterator itCh = children.begin(); itCh != children.end(); itCh++) {
			Element* elNode = dynamic_cast<Element *>(*itCh);
			if (elNode)
			{
				transfo += "<"+elNode->getName()+">";
			}
			else
			{
				Content* ctNode = dynamic_cast<Content *>(*itCh);
				if (ctNode)
				{
					transfo += ctNode->textContent();
				}

			}

			// Recursive call for each children
			if (checkNode((*itCh)) == 0)
			{
				// if it is not valid
				return 0;
			}
		}

		std::map<string,string>::iterator itRegex = mapRegex.find(name);

		if (itRegex == mapRegex.end())
		{
			std::map<string,string>::iterator itType = mapType.find(name);
		 	itRegex = mapRegex.find(itType->second);
			
			if (itRegex == mapRegex.end())
			{
		 		cerr << "XSD not exhaustive for this xml. Missing regex for the type " << itType->second << endl;
		 	}
		}

		string regex = itRegex->second;

		// cout << "DO THE CHECK " << regex << " on " << transfo << " for the node " << name << endl;
		std::regex rx(regex);
		return regex_match(transfo.begin(), transfo.end(), rx);
	}

	return 1;
}
Exemple #14
0
void Host::assign_content(int cid){
	std::vector<int>::iterator it;
	it = find (cids_.begin(), cids_.end(), cid);
	if(it!=cids_.end())
		return;
	cids_.push_back(cid);

	/* copy the content file into the folder */
	Content c;
	string destfile = c.get_content_name_in_host(id_,cid);
	copycontent(c.get_content_name(cid).c_str(), destfile.c_str());
}
    Content::iterator Find(const std::string& filename)
    {
      for (Content::iterator it = content_.begin();
           it != content_.end(); ++it)
      {
        if ((*it)->GetFilename() == filename)
        {
          return it;
        }
      }

      return content_.end();
    }
void Panel::showTab( const std::string contentID, bool show )
{
	for( TabItr i = tabList_.begin(); i != tabList_.end(); ++i )
	{
		if ( tabContains( *i, contentID ) )
		{
			showTab( *i, show );
			Content* tcontent = (*i)->getContent().getObject();
			if ( tcontent && tcontent->getContentID() == ContentContainer::contentID )
				((ContentContainer*)tcontent)->currentContent( contentID );
		}
	}
}
void Panel::broadcastMessage( UINT msg, WPARAM wParam, LPARAM lParam )
{
	for( TabItr i = tabList_.begin(); i != tabList_.end(); ++i )
	{
		Content* content = (*i)->getContent().getObject();
		if ( !content )
			continue;

		if ( content->getContentID() == ContentContainer::contentID )
			((ContentContainer*)content)->broadcastMessage( msg, wParam, lParam );
		else
			(*i)->getCWnd()->SendMessage( msg, wParam, lParam );
	}
}
int Panel::tabContains( TabPtr t, const std::string contentID )
{
	Content* tcontent = t->getContent().getObject();
	if ( !tcontent )
		return 0;
	
	int cnt = 0;

	if ( contentID.compare( tcontent->getContentID() ) == 0 )
		++cnt;
	else if ( tcontent->getContentID() == ContentContainer::contentID )
		cnt += ((ContentContainer*)tcontent)->contains( contentID );
	
	return cnt;
}
Exemple #19
0
  bool Place(Content<_T> content) {
     
    Sort();
    
    for( Coord::List::iterator itor = topLefts.begin(); itor != topLefts.end(); itor++ ) {
      
      content.coord = *itor;
      
      if( Fits( content ) ) {
	
	Use( content );
	topLefts.erase( itor );
	return true;
      }
    }
    
    // EXPERIMENTAL - TRY ROTATED?
    content.Rotate();
    for( Coord::List::iterator itor = topLefts.begin(); itor != topLefts.end(); itor++ ) {
      
      content.coord = *itor;
      
      if( Fits( content ) ) {
	
	Use( content );
	topLefts.erase( itor );
	return true;
      }
    }
    ////////////////////////////////
    
    
    return false;
  }
Exemple #20
0
void
AtticaManager::uploadRating( const Content& c )
{
    m_resolverStates[ c.id() ].userRating = c.rating();

    for ( int i = 0; i < m_resolvers.count(); i++ )
    {
        if ( m_resolvers[ i ].id() == c.id() )
        {
            Attica::Content atticaContent = m_resolvers[ i ];
            atticaContent.setRating( c.rating() );
            m_resolvers[ i ] = atticaContent;
            break;
        }
    }

    TomahawkSettings::instance()->setAtticaResolverStates( m_resolverStates );

    PostJob* job = m_resolverProvider.voteForContent( c.id(), (uint)c.rating() );
    connect( job, SIGNAL( finished( Attica::BaseJob* ) ), job, SLOT( deleteLater() ) );

    job->start();

    emit resolverStateChanged( c.id() );
}
void Path2dApp::update(){
  
  //cout<<thread.mPoints.size()<<endl;
  //cout<<(float)app::getFrameRate()<<endl;

  if(frameCount % 30 == 0){
  //float xPos = lerp( windowWidth, 0, pow(0,windowWidth+ 20));
  //float xPos = randFloat(windowWidth-20,windowWidth+20);
    float xPos = randFloat(windowWidth, windowWidth+200);
  controller->addParticles(NUM_PARTICLES_PER_FRAME, Vec2f(xPos,randFloat(windowHeight*3/8,windowHeight*5/8)), Vec2f(randFloat(),randFloat()));
  }
  thread.update();
  
  if(frameCount == 0 || frameCount % 620 == 0){
    Content *c = new Content(Vec3f(windowWidth+200,randFloat(windowHeight*3/8, windowHeight*5/8),randFloat(-1.0,-1.0)),postIndex);
    mContents.push_back(c);
    postIndex ++;
    if(postIndex>6) postIndex = 0;
  }
  
  frameCount ++;
  
  for(std::list<Content*>::iterator i = mContents.begin(); i!= mContents.end();){
    
    Content *c = (*i);
    if(c->die()){
      i = mContents.erase(i);
      delete c;
    }else{
      Vec2f steer = c->seek(thread.mPoints);
      c->addForce(steer);
      c->update();
      ++i;
    }
  }
  
  double currentTime = app::getElapsedSeconds();
  double deltaTime = currentTime - mLastTime;
  float delta = (float)app::getFrameRate() / (1.0 / deltaTime);
  
  mLastTime = currentTime;
  
	this->controller->update(delta, mPerlin, thread.mPoints);
  
}
Exemple #22
0
  void MapScreen::loadContent(const Content& content) {
    map_source_ = content.loadMap(map_name_);
    map_collision_ = std::make_unique<const MapCollision>(map_source_->collisionsLayer());

    player_.loadContent(content);

    map_ = std::make_unique<Map>(map_source_->tileSize(), screen_size_);
    map_->setup(player_position_);
  }
Exemple #23
0
int main()
{
    
    int a,b ;
    char c ;
    cin>>a>>b;
    cout<<"请输入字符";
    cin>>c;
    switch (c)
    {
        case '+':
            Content *context = new Content(new AddOpreation(a,b));
            cout<<context->GetResult()<<endl;
           break;
            }
    return 0;
 

}
Exemple #24
0
void ContentTest::testImplicitMultipartGeneration()
{
  Content *c1 = new Content();
  c1->contentType()->from7BitString( "text/plain" );
  c1->setBody( "textpart" );

  Content *c2 = new Content();
  c2->contentType()->from7BitString( "text/html" );
  c2->setBody( "htmlpart" );

  c1->addContent( c2 );

  // c1 implicitly converted into a multipart/mixed node.
  QVERIFY( c1->contentType( false ) );
  QCOMPARE( c1->contentType()->mimeType(), QByteArray( "multipart/mixed" ) );
  QVERIFY( c1->body().isEmpty() );

  QCOMPARE( c1->contents().count(), 2 );
  Content *c = c1->contents().at( 0 ); // Former c1.
  QVERIFY( c->contentType( false ) );
  QCOMPARE( c->contentType()->mimeType(), QByteArray( "text/plain" ) );
  QCOMPARE( c->body(), QByteArray( "textpart" ) );

  QCOMPARE( c1->contents().at( 1 ), c2 );

  // Now remove c2. c1 should be converted back to a text/plain content.
  c1->removeContent( c2, false );
  QVERIFY( c1->contents().isEmpty() );
  QVERIFY( c1->contentType( false ) );
  QCOMPARE( c1->contentType()->mimeType(), QByteArray( "text/plain" ) );
  QCOMPARE( c1->body(), QByteArray( "textpart" ) );

  // c2 should not have been touched.
  QVERIFY( c2->contents().isEmpty() );
  QVERIFY( c2->contentType( false ) );
  QCOMPARE( c2->contentType()->mimeType(), QByteArray( "text/html" ) );
  QCOMPARE( c2->body(), QByteArray( "htmlpart" ) );

  // Clean up.
  delete c1;
  delete c2;
}
void ComposerTest::testAttachments()
{
    Composer *composer = new Composer;
    fillComposerData(composer);
    AttachmentPart::Ptr attachment = AttachmentPart::Ptr(new AttachmentPart);
    attachment->setData("abc");
    attachment->setMimeType("x-some/x-type");
    composer->addAttachmentPart(attachment);

    QVERIFY(composer->exec());
    QCOMPARE(composer->resultMessages().size(), 1);
    KMime::Message::Ptr message = composer->resultMessages().first();
    delete composer;
    composer = Q_NULLPTR;

    // multipart/mixed
    {
        QVERIFY(message->contentType(false));
        QCOMPARE(message->contentType()->mimeType(), QByteArray("multipart/mixed"));
        QCOMPARE(message->contents().count(), 2);
        // text/plain
        {
            Content *plain = message->contents().at(0);
            QVERIFY(plain->contentType(false));
            QCOMPARE(plain->contentType()->mimeType(), QByteArray("text/plain"));
        }
        // x-some/x-type (attachment)
        {
            Content *plain = message->contents().at(1);
            QVERIFY(plain->contentType(false));
            QCOMPARE(plain->contentType()->mimeType(), QByteArray("x-some/x-type"));
        }
    }
}
vector<unsigned char> Downloader::download(const string& url) {
    
    //cout << "downloading " << url << endl;
    
    curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
    /* example.com is redirected, so we tell libcurl to follow redirection */
    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); //Prevent "longjmp causes uninitialized stack frame" bug
    curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "deflate");
    
    Content content;
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &content);
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &Content::Write);
    /* Perform the request, res will get the return code */
    CURLcode res = curl_easy_perform(curl);
    /* Check for errors */
    if (res != CURLE_OK) {
        fprintf(stderr, "curl_easy_perform() failed: %s\n",
                curl_easy_strerror(res));
    }
    return content.Data();
}
void Path2dApp::draw()
{
	gl::clear( Color( 245.0f/255.0f, 245.0f/255.0f, 245.0f/255.0f ) );
	gl::enableAlphaBlending();

   gl::color(Color::white());
  
  if(mImage){
    gl::draw( mImage, Area(0,0,1280,60) );
  }

  thread.draw();
  
  //gl::pushMatrices();
  this->controller->draw();
  //gl::popMatrices();
	 
  for(std::list<Content*>::iterator i = mContents.begin(); i!= mContents.end(); i++){
    Content *c = (*i);
    c->draw();
  }
}
Exemple #28
0
  bool Fits( const Content<_T> &content ) const {
   
    if( (content.coord.x + content.size.w) > w )
      return false;
    
    if( (content.coord.y + content.size.h) > h )
      return false;
    
    for( typename Content<_T>::Vector::const_iterator itor = contentVector.begin(); itor != contentVector.end(); itor++ )  
      if( content.intersects( *itor ) )
	return false;
    
    return true;
  }
void
FlattenDocsumWriter::onPrimitive(uint32_t, const Content & c)
{
    considerSeparator();
    const document::FieldValue & fv = c.getValue();
    if (fv.getClass().inherits(document::LiteralFieldValueB::classId)) {
        const document::LiteralFieldValueB & lfv = static_cast<const document::LiteralFieldValueB &>(fv);
        vespalib::stringref value = lfv.getValueRef();
        _output.put(value.data(), value.size());
    } else if (fv.getClass().inherits(document::NumericFieldValueBase::classId)) {
        vespalib::string value = fv.getAsString();
        _output.put(value.data(), value.size());
    } else {
        vespalib::string value = fv.toString();
        _output.put(value.data(), value.size());
    }
    _useSeparator = true;
}
    foreach ( Content resolver, m_resolvers )
    {
        if ( !m_resolverStates.contains( resolver.id() ) )
            m_resolverStates.insert( resolver.id(), Resolver() );

        if ( !m_resolverStates.value( resolver.id() ).pixmap && !resolver.icons().isEmpty() && !resolver.icons().first().url().isEmpty() )
        {
            QNetworkReply* fetch = Tomahawk::Utils::nam()->get( QNetworkRequest( resolver.icons().first().url() ) );
            fetch->setProperty( "resolverId", resolver.id() );

            connect( fetch, SIGNAL( finished() ), this, SLOT( resolverIconFetched() ) );
        }
    }