本文整理汇总了C++中Selector类的典型用法代码示例。如果您正苦于以下问题:C++ Selector类的具体用法?C++ Selector怎么用?C++ Selector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Selector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
int DeclarationName::compare(DeclarationName LHS, DeclarationName RHS) {
if (LHS.getNameKind() != RHS.getNameKind())
return (LHS.getNameKind() < RHS.getNameKind() ? -1 : 1);
switch (LHS.getNameKind()) {
case DeclarationName::Identifier: {
IdentifierInfo *LII = LHS.getAsIdentifierInfo();
IdentifierInfo *RII = RHS.getAsIdentifierInfo();
if (!LII) return RII ? -1 : 0;
if (!RII) return 1;
return LII->getName().compare(RII->getName());
}
case DeclarationName::ObjCZeroArgSelector:
case DeclarationName::ObjCOneArgSelector:
case DeclarationName::ObjCMultiArgSelector: {
Selector LHSSelector = LHS.getObjCSelector();
Selector RHSSelector = RHS.getObjCSelector();
unsigned LN = LHSSelector.getNumArgs(), RN = RHSSelector.getNumArgs();
for (unsigned I = 0, N = std::min(LN, RN); I != N; ++I) {
switch (LHSSelector.getNameForSlot(I).compare(
RHSSelector.getNameForSlot(I))) {
case -1: return true;
case 1: return false;
default: break;
}
}
return compareInt(LN, RN);
}
case DeclarationName::CXXConstructorName:
case DeclarationName::CXXDestructorName:
case DeclarationName::CXXConversionFunctionName:
if (QualTypeOrdering()(LHS.getCXXNameType(), RHS.getCXXNameType()))
return -1;
if (QualTypeOrdering()(RHS.getCXXNameType(), LHS.getCXXNameType()))
return 1;
return 0;
case DeclarationName::CXXOperatorName:
return compareInt(LHS.getCXXOverloadedOperator(),
RHS.getCXXOverloadedOperator());
case DeclarationName::CXXLiteralOperatorName:
return LHS.getCXXLiteralIdentifier()->getName().compare(
RHS.getCXXLiteralIdentifier()->getName());
case DeclarationName::CXXUsingDirective:
return 0;
}
llvm_unreachable("Invalid DeclarationName Kind!");
}
示例2: IndexPointer
// Selection test
void MD5Surface::testSelect(Selector& selector,
SelectionTest& test,
const Matrix4& localToWorld)
{
test.BeginMesh(localToWorld);
SelectionIntersection best;
test.TestTriangles(
vertexpointer_arbitrarymeshvertex(_vertices.data()),
IndexPointer(_indices.data(), IndexPointer::index_type(_indices.size())),
best
);
if(best.valid()) {
selector.addIntersection(best);
}
}
示例3: possible
// ICI l'id du client correspond a l'id du client auquel on veut envoyer les bails
void TCPWinServSocket::SendData(CircularBuff &circbuff, Selector &sel)
{
std::vector<Message> &to_send = circbuff.get_data();
DWORD sentbytes;
WSABUF databuf[3];
char first_buff[4];
char second_buff[4];
char third_buff[256];
databuf[0].len = 4;
databuf[0].buf = first_buff;
databuf[1].len = 4;
databuf[1].buf = second_buff;
databuf[2].len = 256;
databuf[2].buf = third_buff;
//pour tous les messages
for (size_t i = 0; i < to_send.size(); i++)
if (sel.Is_writable(to_send.at(i).get_client().get_socket()))
{
//reset des buffers
memset(&first_buff, '\0', 4);
memset(&second_buff, '\0', 4);
memset(&third_buff, '\0', 256);
// on crée des variables parce qu'on a besoin d'une adresse pour memcpy (donc juste des getters ca suffit pas)
int rq_type = to_send.at(i).get_rq_type();
int data_length = to_send.at(i).get_data_length();
//on rempli nos 3 buffers
memcpy(&first_buff, (char *)&(rq_type), 4);
memcpy(&second_buff, (char *)&(data_length), 4);
memcpy(&third_buff, to_send.at(i).get_packet(), data_length);
// et on les envoi
WSASend(to_send.at(i).get_client().get_socket(), databuf, 3, &sentbytes, 0, NULL, NULL);
delete[] to_send.at(i).get_packet();
}
else
std::cerr << "Corruption possible (1)" << std::endl;
to_send.clear();
}
示例4: writev
// ICI l'id du client correspond a l'id du client auquel on veut envoyer les bails
void TCPLinServSocket::SendData(CircularBuff &circbuff, Selector &sel)
{
std::vector<Message> &to_send = circbuff.get_data();
struct iovec databuf[3];
char first_buff[4];
char second_buff[4];
char third_buff[256];
int sentbytes = 0;
databuf[0].iov_len = 4;
databuf[0].iov_base = first_buff;
databuf[1].iov_len = 4;
databuf[1].iov_base = second_buff;
databuf[2].iov_len = 256;
databuf[2].iov_base = third_buff;
//pour tous les messages
for (size_t i = 0; i < to_send.size(); i++)
if (sel.Is_writable(to_send.at(i).get_client().get_socket()))
{
//reset des buffers
memset(&first_buff, '\0', 4);
memset(&second_buff, '\0', 4);
memset(&third_buff, '\0', 256);
// on crée des variables parce qu'on a besoin d'une
//adresse pour memcpy (donc juste des getters ca suffit pas)
int rq_type = to_send.at(i).get_rq_type();
int data_length = to_send.at(i).get_data_length();
//on rempli nos 3 buffers
memcpy(&first_buff, (char *)&(rq_type), 4);
memcpy(&second_buff, (char *)&(data_length), 4);
memcpy(&third_buff, to_send.at(i).get_packet(), data_length);
// et on les envoi
sentbytes = writev(to_send.at(i).get_client().get_socket(), databuf, 3);
delete[] to_send.at(i).get_packet();
}
to_send.clear();
}
示例5: AddBoolean
void ODRHash::AddDeclarationName(DeclarationName Name) {
AddBoolean(Name.isEmpty());
if (Name.isEmpty())
return;
auto Kind = Name.getNameKind();
ID.AddInteger(Kind);
switch (Kind) {
case DeclarationName::Identifier:
AddIdentifierInfo(Name.getAsIdentifierInfo());
break;
case DeclarationName::ObjCZeroArgSelector:
case DeclarationName::ObjCOneArgSelector:
case DeclarationName::ObjCMultiArgSelector: {
Selector S = Name.getObjCSelector();
AddBoolean(S.isNull());
AddBoolean(S.isKeywordSelector());
AddBoolean(S.isUnarySelector());
unsigned NumArgs = S.getNumArgs();
for (unsigned i = 0; i < NumArgs; ++i) {
AddIdentifierInfo(S.getIdentifierInfoForSlot(i));
}
break;
}
case DeclarationName::CXXConstructorName:
case DeclarationName::CXXDestructorName:
AddQualType(Name.getCXXNameType());
break;
case DeclarationName::CXXOperatorName:
ID.AddInteger(Name.getCXXOverloadedOperator());
break;
case DeclarationName::CXXLiteralOperatorName:
AddIdentifierInfo(Name.getCXXLiteralIdentifier());
break;
case DeclarationName::CXXConversionFunctionName:
AddQualType(Name.getCXXNameType());
break;
case DeclarationName::CXXUsingDirective:
break;
case DeclarationName::CXXDeductionGuideName: {
auto *Template = Name.getCXXDeductionGuideTemplate();
AddBoolean(Template);
if (Template) {
AddDecl(Template);
}
}
}
}
示例6: GlobalSelector
/// \brief Get a GlobalSelector for the ASTContext-specific selector.
GlobalSelector GlobalSelector::get(Selector Sel, Program &Prog) {
if (Sel.isNull())
return GlobalSelector();
ProgramImpl &ProgImpl = *static_cast<ProgramImpl*>(Prog.Impl);
llvm::SmallVector<IdentifierInfo *, 8> Ids;
for (unsigned i = 0, e = Sel.isUnarySelector() ? 1 : Sel.getNumArgs();
i != e; ++i) {
IdentifierInfo *II = Sel.getIdentifierInfoForSlot(i);
IdentifierInfo *GlobII = &ProgImpl.getIdents().get(II->getName(),
II->getName() + II->getLength());
Ids.push_back(GlobII);
}
Selector GlobSel = ProgImpl.getSelectors().getSelector(Sel.getNumArgs(),
Ids.data());
return GlobalSelector(GlobSel.getAsOpaquePtr());
}
示例7: deriveNamingConvention
cocoa::NamingConvention cocoa::deriveNamingConvention(Selector S) {
switch (S.getMethodFamily()) {
case OMF_None:
case OMF_autorelease:
case OMF_dealloc:
case OMF_release:
case OMF_retain:
case OMF_retainCount:
return NoConvention;
case OMF_init:
return InitRule;
case OMF_alloc:
case OMF_copy:
case OMF_mutableCopy:
case OMF_new:
return CreateRule;
}
llvm_unreachable("unexpected naming convention");
return NoConvention;
}
示例8: testSelect
// Perform selection test for this surface
void RenderablePicoSurface::testSelect(Selector& selector,
SelectionTest& test,
const Matrix4& localToWorld) const
{
if (!_vertices.empty() && !_indices.empty())
{
// Test for triangle selection
test.BeginMesh(localToWorld);
SelectionIntersection result;
test.TestTriangles(
VertexPointer(&_vertices[0].vertex, sizeof(ArbitraryMeshVertex)),
IndexPointer(&_indices[0],
IndexPointer::index_type(_indices.size())),
result
);
// Add the intersection to the selector if it is valid
if(result.valid()) {
selector.addIntersection(result);
}
}
}
示例9: draw_beta
void BLSSS::draw_beta() {
Selector g = m_->coef().inc();
if(g.nvars() == 0) {
m_->drop_all();
return;
}
SpdMatrix ivar = g.select(pri_->siginv());
Vector ivar_mu = ivar * g.select(pri_->mu());
ivar += g.select(suf().xtx());
ivar_mu += g.select(suf().xty());
Vector b = ivar.solve(ivar_mu);
b = rmvn_ivar_mt(rng(), b, ivar);
// If model selection is turned off and some elements of beta
// happen to be zero (because, e.g., of a failed MH step) we don't
// want the dimension of beta to change.
m_->set_included_coefficients(b, g);
}
示例10: draw_beta
void BLSSS::draw_beta() {
Selector g = model_->coef().inc();
if (g.nvars() == 0) {
model_->drop_all();
return;
}
SpdMatrix precision = g.select(slab_->siginv());
Vector scaled_mean = precision * g.select(slab_->mu());
precision += g.select(suf().xtx());
Cholesky precision_cholesky_factor(precision);
scaled_mean += g.select(suf().xty());
Vector posterior_mean = precision_cholesky_factor.solve(scaled_mean);
Vector beta = rmvn_precision_upper_cholesky_mt(
rng(), posterior_mean, precision_cholesky_factor.getLT());
// If model selection is turned off and some elements of beta
// happen to be zero (because, e.g., of a failed MH step) we don't
// want the dimension of beta to change.
model_->set_included_coefficients(beta, g);
}
示例11: Specificity
Specificity Wt::Render::Match::isMatch(const Block* block, const Selector& selector)
{
if(!selector.size())
return Specificity(false);
if(!isMatch(block, selector.at(selector.size()-1)))
return Specificity(false);
const Block* parent = block->parent();
for(int i = selector.size()-2; i >= 0; --i)
{
bool matchFound;
while(parent)
{
matchFound = isMatch(parent, selector.at(i));
parent = parent->parent();
if(matchFound)
break;
}
if(!matchFound && !parent)
return Specificity(false);
}
return selector.specificity();
}
示例12: TRACE_BEGIN
void EventTest::Func2( uint32_t p1, uint16_t p2 )
{
TRACE_BEGIN( LOG_LVL_INFO );
mSelector->sendEventSync( jh_new Event2( p1, p2 ) );
}
示例13: dprintf
bool
VanillaProc::JobReaper(int pid, int status)
{
dprintf(D_FULLDEBUG,"Inside VanillaProc::JobReaper()\n");
//
// Run all the reapers first, since some of them change the exit status.
//
if( m_pid_ns_status_filename.length() > 0 ) {
status = pidNameSpaceReaper( status );
}
bool jobExited = OsProc::JobReaper( pid, status );
if( pid != JobPid ) { return jobExited; }
#if defined(LINUX)
// On newer kernels if memory.use_hierarchy==1, then we cannot disable
// the OOM killer. Hence, we have to be ready for a SIGKILL to be delivered
// by the kernel at the same time we get the notification. Hence, if we
// see an exit signal, we must also check the event file descriptor.
//
// outOfMemoryEvent() is aware of checkpointing and will mention that
// the OOM event happened during a checkpoint.
int efd = -1;
if( (m_oom_efd >= 0) && daemonCore->Get_Pipe_FD(m_oom_efd, &efd) && (efd != -1) ) {
Selector selector;
selector.add_fd(efd, Selector::IO_READ);
selector.set_timeout(0);
selector.execute();
if( !selector.failed() && !selector.timed_out() && selector.has_ready() && selector.fd_ready(efd, Selector::IO_READ) ) {
outOfMemoryEvent( m_oom_efd );
}
}
#endif
//
// We have three cases to consider:
// * if we're checkpointing; or
// * if we see a special checkpoint exit code; or
// * there's no special case to consider.
//
bool wantsFileTransferOnCheckpointExit = false;
JobAd->LookupBool( ATTR_WANT_FT_ON_CHECKPOINT, wantsFileTransferOnCheckpointExit );
int checkpointExitCode = 0;
JobAd->LookupInteger( ATTR_CHECKPOINT_EXIT_CODE, checkpointExitCode );
int checkpointExitSignal = 0;
JobAd->LookupInteger( ATTR_CHECKPOINT_EXIT_SIGNAL, checkpointExitSignal );
bool checkpointExitBySignal = 0;
JobAd->LookupBool( ATTR_CHECKPOINT_EXIT_BY_SIGNAL, checkpointExitBySignal );
int successfulCheckpointStatus = 0;
if( checkpointExitBySignal ) {
successfulCheckpointStatus = checkpointExitSignal;
} else if( checkpointExitCode != 0 ) {
successfulCheckpointStatus = checkpointExitCode << 8;
#if defined( WINDOWS )
successfulCheckpointStatus = checkpointExitCode;
#endif
}
if( isCheckpointing ) {
dprintf( D_FULLDEBUG, "Inside VanillaProc::JobReaper() during a checkpoint\n" );
if( exit_status == successfulCheckpointStatus ) {
if( isSoftKilling ) {
notifySuccessfulEvictionCheckpoint();
return true;
}
restartCheckpointedJob();
isCheckpointing = false;
return false;
} else {
// The job exited without taking a checkpoint. If we don't do
// anything, it will be reported as if the error code or signal
// had happened naturally (and the job will usually exit the
// queue). This could confuse the users.
//
// Instead, we'll put the job on hold, figuring that if the job
// requested that we (periodically) send it a signal, and we
// did, that it's not our fault that the job failed. This has
// the convenient side-effect of not overwriting the job's
// previous checkpoint(s), if any (since file transfer doesn't
// occur when the job goes on hold).
killFamilyIfWarranted();
recordFinalUsage();
std::string holdMessage;
formatstr( holdMessage, "Job did not exit as promised when sent its checkpoint signal. "
"Promised exit was %s %u, actual exit status was %s %u.",
checkpointExitBySignal ? "on signal" : "with exit code",
checkpointExitBySignal ? checkpointExitSignal : checkpointExitCode,
WIFSIGNALED( exit_status ) ? "on signal" : "with exit code",
WIFSIGNALED( exit_status ) ? WTERMSIG( exit_status ) : WEXITSTATUS( exit_status ) );
Starter->jic->holdJob( holdMessage.c_str(), CONDOR_HOLD_CODE_FailedToCheckpoint, exit_status );
Starter->Hold();
return true;
}
} else if( wantsFileTransferOnCheckpointExit && exit_status == successfulCheckpointStatus ) {
//.........这里部分代码省略.........
示例14: main
int main(int argc, char** argv)
{
LBCHECK(co::init(argc, argv));
co::ConnectionDescriptionPtr description = new co::ConnectionDescription;
description->type = co::CONNECTIONTYPE_TCPIP;
description->port = 4242;
bool isClient = true;
bool useThreads = false;
size_t packetSize = 1048576;
size_t nPackets = 0xffffffffu;
uint32_t waitTime = 0;
try // command line parsing
{
po::options_description options(
"netperf - Collage network benchmark tool " +
co::Version::getString());
std::string clientString("");
std::string serverString("");
bool showHelp(false);
options.add_options()("help,h",
po::bool_switch(&showHelp)->default_value(false),
"show help message")(
"client,c", po::value<std::string>(&clientString),
"run as client, format IP[:port][:protocol]")(
"server,s", po::value<std::string>(&serverString),
"run as server, format IP[:port][:protocol]")(
"threaded,t", po::bool_switch(&useThreads)->default_value(false),
"Run each receive in a separate thread (server only)")(
"packetSize,p", po::value<std::size_t>(&packetSize),
"packet size")("numPackets,n", po::value<std::size_t>(&nPackets),
"number of packets to send, unsigned int")(
"wait,w", po::value<uint32_t>(&waitTime),
"wait time (ms) between sends (client only)")(
"delay,d", po::value<uint32_t>(&_delay),
"wait time (ms) between receives (server only");
// parse program options
po::variables_map variableMap;
po::store(po::command_line_parser(argc, argv)
.options(options)
.allow_unregistered()
.run(),
variableMap);
po::notify(variableMap);
// evaluate parsed arguments
if (showHelp)
{
std::cout << options << std::endl;
co::exit();
return EXIT_SUCCESS;
}
if (variableMap.count("client") == 1)
description->fromString(clientString);
else if (variableMap.count("server") == 1)
{
isClient = false;
description->fromString(serverString);
}
}
catch (std::exception& exception)
{
std::cerr << "Command line parse error: " << exception.what()
<< std::endl;
co::exit();
return EXIT_FAILURE;
}
// run
co::ConnectionPtr connection = co::Connection::create(description);
if (!connection)
{
LBWARN << "Unsupported connection: " << description << std::endl;
co::exit();
return EXIT_FAILURE;
}
Selector* selector = 0;
if (isClient)
{
if (description->type == co::CONNECTIONTYPE_RSP)
{
selector = new Selector(connection, packetSize, useThreads);
selector->start();
}
else if (!connection->connect())
::exit(EXIT_FAILURE);
lunchbox::Buffer<uint8_t> buffer;
buffer.resize(packetSize);
for (size_t i = 0; i < packetSize; ++i)
buffer[i] = static_cast<uint8_t>(i);
const float mBytesSec = buffer.getSize() / 1024.0f / 1024.0f * 1000.0f;
//.........这里部分代码省略.........
示例15: findKnownClass
void NilArgChecker::checkPreObjCMessage(const ObjCMethodCall &msg,
CheckerContext &C) const {
const ObjCInterfaceDecl *ID = msg.getReceiverInterface();
if (!ID)
return;
FoundationClass Class = findKnownClass(ID);
static const unsigned InvalidArgIndex = UINT_MAX;
unsigned Arg = InvalidArgIndex;
bool CanBeSubscript = false;
if (Class == FC_NSString) {
Selector S = msg.getSelector();
if (S.isUnarySelector())
return;
if (StringSelectors.empty()) {
ASTContext &Ctx = C.getASTContext();
Selector Sels[] = {
getKeywordSelector(Ctx, "caseInsensitiveCompare", nullptr),
getKeywordSelector(Ctx, "compare", nullptr),
getKeywordSelector(Ctx, "compare", "options", nullptr),
getKeywordSelector(Ctx, "compare", "options", "range", nullptr),
getKeywordSelector(Ctx, "compare", "options", "range", "locale",
nullptr),
getKeywordSelector(Ctx, "componentsSeparatedByCharactersInSet",
nullptr),
getKeywordSelector(Ctx, "initWithFormat",
nullptr),
getKeywordSelector(Ctx, "localizedCaseInsensitiveCompare", nullptr),
getKeywordSelector(Ctx, "localizedCompare", nullptr),
getKeywordSelector(Ctx, "localizedStandardCompare", nullptr),
};
for (Selector KnownSel : Sels)
StringSelectors[KnownSel] = 0;
}
auto I = StringSelectors.find(S);
if (I == StringSelectors.end())
return;
Arg = I->second;
} else if (Class == FC_NSArray) {
Selector S = msg.getSelector();
if (S.isUnarySelector())
return;
if (ArrayWithObjectSel.isNull()) {
ASTContext &Ctx = C.getASTContext();
ArrayWithObjectSel = getKeywordSelector(Ctx, "arrayWithObject", nullptr);
AddObjectSel = getKeywordSelector(Ctx, "addObject", nullptr);
InsertObjectAtIndexSel =
getKeywordSelector(Ctx, "insertObject", "atIndex", nullptr);
ReplaceObjectAtIndexWithObjectSel =
getKeywordSelector(Ctx, "replaceObjectAtIndex", "withObject", nullptr);
SetObjectAtIndexedSubscriptSel =
getKeywordSelector(Ctx, "setObject", "atIndexedSubscript", nullptr);
ArrayByAddingObjectSel =
getKeywordSelector(Ctx, "arrayByAddingObject", nullptr);
}
if (S == ArrayWithObjectSel || S == AddObjectSel ||
S == InsertObjectAtIndexSel || S == ArrayByAddingObjectSel) {
Arg = 0;
} else if (S == SetObjectAtIndexedSubscriptSel) {
Arg = 0;
CanBeSubscript = true;
} else if (S == ReplaceObjectAtIndexWithObjectSel) {
Arg = 1;
}
} else if (Class == FC_NSDictionary) {
Selector S = msg.getSelector();
if (S.isUnarySelector())
return;
if (DictionaryWithObjectForKeySel.isNull()) {
ASTContext &Ctx = C.getASTContext();
DictionaryWithObjectForKeySel =
getKeywordSelector(Ctx, "dictionaryWithObject", "forKey", nullptr);
SetObjectForKeySel =
getKeywordSelector(Ctx, "setObject", "forKey", nullptr);
SetObjectForKeyedSubscriptSel =
getKeywordSelector(Ctx, "setObject", "forKeyedSubscript", nullptr);
RemoveObjectForKeySel =
getKeywordSelector(Ctx, "removeObjectForKey", nullptr);
}
if (S == DictionaryWithObjectForKeySel || S == SetObjectForKeySel) {
Arg = 0;
warnIfNilArg(C, msg, /* Arg */1, Class);
} else if (S == SetObjectForKeyedSubscriptSel) {
CanBeSubscript = true;
Arg = 0;
warnIfNilArg(C, msg, /* Arg */1, Class, CanBeSubscript);
} else if (S == RemoveObjectForKeySel) {
Arg = 0;
}
}
//.........这里部分代码省略.........