// HINT: Once queried this information remains static throughout the object's lifetime
inline VmbErrorType FeatureContainer::GetFeatures( FeaturePtrVector &features )
{
    VmbErrorType    res;
    VmbUint32_t     nSize;

    res = GetFeatures( NULL, nSize );
    if (    VmbErrorSuccess == res )
    {
        if( 0 != nSize)
        {
            try
            {
                FeaturePtrVector tmpFeatures( nSize );
                res = GetFeatures( &tmpFeatures[0], nSize );
                if( VmbErrorSuccess == res)
                {
                    features.swap( tmpFeatures );
                }
            }
            catch(...)
            {
                return VmbErrorResources;
            }
        }
        else
        {
            features.clear();
        }
    }

    return res;
}
Beispiel #2
0
bp::object CalcFeaturesPy(const GameState& gameState, uint32_t ourHero, const Card& card, const std::string& featureType, bool hasLayers) {
	auto features = CalcFeatures(gameState, card, ourHero, StringToTag(featureType));
	if (hasLayers) {
		return PyModels::ConvertLayeredFeatureVector(features.GetFeatures(), /*hasFirstDim=*/false);
	} else {
		return PyModels::ConvertFeatureVector(features.GetFeatures(), /*hasFirstDim=*/false);
	}
}
	void AccountsListWidget::handleAccountClicked (const QModelIndex& idx)
	{
		QModelIndex index = idx.sibling (idx.row (), Columns::Name);
		if (!index.isValid ())
			return;

		QStandardItem *item = AccountsModel_->itemFromIndex (index);
		if (item &&
				Item2Account_.contains (item))
		{
			IAccount *acc = Item2Account_ [item];
			auto ibp = qobject_cast<IBloggingPlatform*> (acc->GetParentBloggingPlatform ());
			if (!ibp)
			{
				qWarning () << Q_FUNC_INFO
						<< "account"
						<< acc->GetAccountID ()
						<< "hasn't valid parent blogging platform"
						<< acc->GetParentBloggingPlatform ();
				return;
			}

			Ui_.Profile_->setEnabled ((ibp->GetFeatures () &
					IBloggingPlatform::BPFSupportsProfiles) &&
					acc->IsValidated ());
		}
	}
	QWidget* SelectTargetDelegate::createEditor (QWidget *parent,
			const QStyleOptionViewItem&, const QModelIndex& index) const
	{
		QComboBox *box = new QComboBox (parent);
		IAccount *acc = Dlg_->GetAccountFromIndex (index.sibling (index.row (),
				SubmitToDialog::Account));
		if (!acc)
			return box;
		auto ibp = qobject_cast<IBloggingPlatform*> (acc->GetParentBloggingPlatform ());
		if (!ibp)
			return box;

		if (ibp->GetFeatures () & IBloggingPlatform::BPFSelectablePostDestination)
		{
			auto profile = qobject_cast<IProfile*> (acc->GetProfile ());
			if (!profile)
				box->addItem (tr ("<Default>"));
			else
				for (const auto& pair : profile->GetPostingTargets ())
					box->addItem (pair.first, pair.second);
		}
		else
			box->addItem (tr ("<Default>"));

		box->setCurrentIndex (0);
		Dlg_->GetModel ()->setData (index, box->currentText (), TargetRole);

		return box;
	}
Beispiel #5
0
VP8StatusCode WebPGetFeaturesInternal(const uint8_t* data, size_t data_size,
                                      WebPBitstreamFeatures* features,
                                      int version) {
  if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_DECODER_ABI_VERSION)) {
    return VP8_STATUS_INVALID_PARAM;   // version mismatch
  }
  if (features == NULL) {
    return VP8_STATUS_INVALID_PARAM;
  }
  return GetFeatures(data, data_size, features);
}
Beispiel #6
0
	void AccountsSelectDialog::FillAccounts (const QList<IAccount*>& accounts)
	{
		for (auto acc : accounts)
		{
			auto ibp = qobject_cast<IBloggingPlatform*> (acc->GetParentBloggingPlatform ());
			if (!ibp ||
					!(ibp->GetFeatures () & IBloggingPlatform::BPFSupportsBackup))
				continue;

			QStandardItem *item = new QStandardItem (acc->GetAccountName ());
			item->setCheckable (true);
			item->setEditable (false);
			Item2Accotun_ [item] = acc;
			Model_->appendRow (item);
		}
	}
Beispiel #7
0
int WebPGetInfo(const uint8_t* data, size_t data_size,
                int* width, int* height) {
  WebPBitstreamFeatures features;

  if (GetFeatures(data, data_size, &features) != VP8_STATUS_OK) {
    return 0;
  }

  if (width != NULL) {
    *width  = features.width;
  }
  if (height != NULL) {
    *height = features.height;
  }

  return 1;
}
Beispiel #8
0
VP8StatusCode WebPGetFeaturesInternal(const uint8_t* data, size_t data_size,
                                      WebPBitstreamFeatures* features,
                                      int version) {
  VP8StatusCode status;
  if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_DECODER_ABI_VERSION)) {
    return VP8_STATUS_INVALID_PARAM;   // version mismatch
  }
  if (features == NULL) {
    return VP8_STATUS_INVALID_PARAM;
  }

  status = GetFeatures(data, data_size, features);
  if (status == VP8_STATUS_NOT_ENOUGH_DATA) {
    return VP8_STATUS_BITSTREAM_ERROR;  // Not-enough-data treated as error.
  }
  return status;
}
Beispiel #9
0
VP8StatusCode WebPDecode(const uint8_t* data, size_t data_size,
                         WebPDecoderConfig* config) {
  WebPDecParams params;
  VP8StatusCode status;

  if (config == NULL) {
    return VP8_STATUS_INVALID_PARAM;
  }

  status = GetFeatures(data, data_size, &config->input);
  if (status != VP8_STATUS_OK) {
    if (status == VP8_STATUS_NOT_ENOUGH_DATA) {
      return VP8_STATUS_BITSTREAM_ERROR;  // Not-enough-data treated as error.
    }
    return status;
  }

  WebPResetDecParams(&params);
  params.options = &config->options;
  params.output = &config->output;
  if (WebPAvoidSlowMemory(params.output, &config->input)) {
    // decoding to slow memory: use a temporary in-mem buffer to decode into.
    WebPDecBuffer in_mem_buffer;
    WebPInitDecBuffer(&in_mem_buffer);
    in_mem_buffer.colorspace = config->output.colorspace;
    in_mem_buffer.width = config->input.width;
    in_mem_buffer.height = config->input.height;
    params.output = &in_mem_buffer;
    status = DecodeInto(data, data_size, &params);
    if (status == VP8_STATUS_OK) {  // do the slow-copy
      status = WebPCopyDecBufferPixels(&in_mem_buffer, &config->output);
    }
    WebPFreeDecBuffer(&in_mem_buffer);
  } else {
    status = DecodeInto(data, data_size, &params);
  }

  return status;
}
VP8StatusCode WebPDecode(const uint8_t* data, size_t data_size,
                         WebPDecoderConfig* config) {
  WebPDecParams params;
  VP8StatusCode status;

  if (config == NULL) {
    return VP8_STATUS_INVALID_PARAM;
  }

  status = GetFeatures(data, data_size, &config->input);
  if (status != VP8_STATUS_OK) {
    if (status == VP8_STATUS_NOT_ENOUGH_DATA) {
      return VP8_STATUS_BITSTREAM_ERROR;  // Not-enough-data treated as error.
    }
    return status;
  }

  WebPResetDecParams(&params);
  params.output = &config->output;
  params.options = &config->options;
  status = DecodeInto(data, data_size, &params);

  return status;
}
Beispiel #11
0
bool HasFeature(u32 major_version, Feature feature)
{
  return HasFeature(GetFeatures(major_version), feature);
}
Beispiel #12
0
	int TLServer_IP::ServiceMessage(int MessageType, CString msg)
	{
		switch (MessageType)
		{
			case ORDERCANCELREQUEST :
				return CancelRequest((long)atoi(msg.GetBuffer()));
			case ACCOUNTREQUEST :
				return AccountResponse(msg);
			case CLEARCLIENT :
				return ClearClient(msg);
			case CLEARSTOCKS :
				return ClearStocks(msg);
			case REGISTERSTOCK :
				{
				vector<CString> rec;
				gsplit(msg,CString("+"),rec);
				CString client = rec[0];
				vector<CString> hisstocks;
				// make sure client sent a basket, otherwise clear the basket
				if (rec.size()!=2) return ClearStocks(client);
				// get the basket
				gsplit(rec[1],CString(","),hisstocks);
				// make sure we have the client
				unsigned int cid = FindClient(client); 
				if (cid==-1) return CLIENTNOTREGISTERED; //client not registered
				// save the basket
				stocks[cid] = hisstocks; 
				D(CString(_T("Client ")+client+_T(" registered: ")+gjoin(hisstocks,",")));
				HeartBeat(client);
				return RegisterStocks(client);
				}
			case POSITIONREQUEST :
				{
				vector<CString> r;
				gsplit(msg,CString("+"),r);
				if (r.size()!=2) return UNKNOWN_MESSAGE;
				return PositionResponse(r[1],r[0]);
				}
			case REGISTERCLIENT :
				return RegisterClient(msg);
			case HEARTBEAT :
				return HeartBeat(msg);
			case BROKERNAME :
				return BrokerName();
			case SENDORDER :
				return SendOrder(TLOrder::Deserialize(msg));
			case FEATUREREQUEST:
				{
					// get features supported by child class
					std::vector<int> stub = GetFeatures();
					// append basic feature we provide as parent
					stub.push_back(REGISTERCLIENT);
					stub.push_back(HEARTBEAT);
					stub.push_back(CLEARSTOCKS);
					stub.push_back(CLEARCLIENT);
					stub.push_back(VERSION);
					// send entire feature set back to client
					TLSend(FEATURERESPONSE,SerializeIntVec(stub),msg);
					return OK;
				}
			case VERSION :
					return MinorVer;
		}

		return UnknownMessage(MessageType,msg);
	}