本文整理汇总了C++中UnitPtr类的典型用法代码示例。如果您正苦于以下问题:C++ UnitPtr类的具体用法?C++ UnitPtr怎么用?C++ UnitPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UnitPtr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: assert
void recall::apply_temp_modifier(unit_map& unit_map)
{
assert(valid());
temp_unit_->set_location(recall_hex_);
DBG_WB << "Inserting future recall " << temp_unit_->name() << " [" << temp_unit_->id()
<< "] at position " << temp_unit_->get_location() << ".\n";
//temporarily remove unit from recall list
UnitPtr it = resources::teams->at(team_index()).recall_list().extract_if_matches_id(temp_unit_->id());
assert(it);
//Add cost to money spent on recruits.
int cost = resources::teams->at(team_index()).recall_cost();
if (it->recall_cost() > -1) {
cost = it->recall_cost();
}
// Temporarily insert unit into unit_map
//unit map takes ownership of temp_unit
unit_map.insert(temp_unit_);
resources::teams->at(team_index()).get_side_actions()->change_gold_spent_by(cost);
// Update gold in top bar
resources::screen->invalidate_game_status();
}
开发者ID:AlainODea,项目名称:wesnoth,代码行数:26,代码来源:recall.cpp
示例2: on_buttonBox_accepted
void dlgUnitEditor::on_buttonBox_accepted()
{
UnitPtr unit = qSharedPointerDynamicCast<Unit>(_entity);
unit->setName(ui->txtNombre->text());
unit->setDescripcion(ui->txtDescripcion->text());
close();
}
开发者ID:Wushaowei001,项目名称:mksPlanner,代码行数:8,代码来源:dlguniteditor.cpp
示例3: QDialog
dlgUnitEditor::dlgUnitEditor(UnitsModel *model, int selectedEntity, QWidget *parent) :
QDialog(parent),
ui(new Ui::dlgUnitEditor)
{
_model = model;
ui->setupUi(this);
_entity = model->getItemByRowid(selectedEntity);
UnitPtr unit = qSharedPointerDynamicCast<Unit>(_entity);
ui->txtNombre->setText(unit->name());
ui->txtDescripcion->setText(unit->description());
}
开发者ID:Wushaowei001,项目名称:mksPlanner,代码行数:12,代码来源:dlguniteditor.cpp
示例4: sep
UnitPtr Restorer::ExtractUnitFromLine(string & str) {
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> sep("\t");
tokenizer tokens(str, sep);
int size = 0;
for (tokenizer::iterator tit = tokens.begin(); tit != tokens.end(); ++tit) {
++size;
}
if (size < 6) {//至少有六段
MCE_INFO("Restorer::ExtractUnitFromLine. wrong size:" << size << " str:" << str);
return NULL;
}
tokenizer::iterator itr = tokens.begin();
++itr;
Ice::Long id = lexical_cast<Ice::Long> (*itr++);
set<Ice::Long>::iterator it = outtag_ids_.find(id);
if (it != outtag_ids_.end()) {
MCE_INFO("Restorer::ExtractUnitFromLine. matched. id:" << id);
return NULL;
}
// if (it != outtag_ids_.end()) {
// --(it->second);
// if (it->second == 0) {
// outtag_ids_.erase(it);
// }
// MCE_INFO("Restorer::ExtractUnitFromLine. matched. id:" << id);
// return NULL;
// }
int retry = lexical_cast<int> (*itr++);
string instance = lexical_cast<string> (*itr++);
int wrflag = lexical_cast<int> (*itr++);
string pattern = lexical_cast<string> (*itr++);
string statement;
for (; itr != tokens.end(); ++itr) {
statement += lexical_cast<string> (*itr);
statement += "\t";
}
UnitPtr unit = new Unit(id, retry + 1, instance, wrflag, pattern, statement);
if (retry > MAX_RETRY) {
MCE_INFO("Restorer::ExtractUnitFromLine. retry exceed max_retry. " << unit->DumpToString());
return NULL;
}
return unit;
}
开发者ID:bradenwu,项目名称:oce,代码行数:48,代码来源:Restore.cpp
示例5: IsOutOfBoundary
bool Section::IsOutOfBoundary(const UnitPtr& unit, OUT Direction& dir)
{
auto x = unit->GetPos().GetX();
auto y = unit->GetPos().GetY();
if (x < m_Boundary.left)
{
dir = Direction::LEFT;
return true;
}
if (y < m_Boundary.top)
{
dir = Direction::TOP;
return true;
}
if (x > m_Boundary.right)
{
dir = Direction::RIGHT;
return true;
}
if (y > m_Boundary.bottom)
{
dir = Direction::BOTTOM;
return true;
}
return false;
}
开发者ID:dlakwwkd,项目名称:SimpleConsoleGame,代码行数:26,代码来源:Section.cpp
示例6: visitClassDefStart
void
FreezeScript::collectCompactIds(const UnitPtr& u, const FreezeScript::CompactIdResolverIPtr& r)
{
class Visitor : public ParserVisitor
{
public:
Visitor(const FreezeScript::CompactIdResolverIPtr& resolver) : _r(resolver)
{
}
virtual bool visitClassDefStart(const ClassDefPtr& p)
{
if(p->compactId() != -1)
{
_r->add(p->compactId(), p->scoped());
}
return true;
}
FreezeScript::CompactIdResolverIPtr _r;
};
Visitor v(r);
u->visit(&v, false);
}
开发者ID:ming-hai,项目名称:freeze,代码行数:26,代码来源:Util.cpp
示例7: v
void
PackageVisitor::createModules(const UnitPtr& unit, const string& module, const string& dir)
{
StringList modules;
PackageVisitor v(modules);
unit->visit(&v, false);
for(StringList::iterator p = modules.begin(); p != modules.end(); ++p)
{
vector<string> v;
if(!IceUtilInternal::splitString(*p, ".", v))
{
assert(false);
}
string currentModule;
string path = dir.empty() ? "." : dir;
for(vector<string>::iterator q = v.begin(); q != v.end(); ++q)
{
if(q != v.begin())
{
addSubmodule(path, currentModule, *q);
currentModule += ".";
}
currentModule += *q;
path += "/" + *q;
createDirectory(path);
addModule(path, currentModule, module);
}
}
}
开发者ID:2008hatake,项目名称:zeroc-ice,代码行数:32,代码来源:Main.cpp
示例8: codeVisitor
void
Slice::Ruby::generate(const UnitPtr& un, bool all, bool checksum, const vector<string>& includePaths, Output& out)
{
out << nl << "require 'Ice'";
if(!all)
{
vector<string> paths = includePaths;
for(vector<string>::iterator p = paths.begin(); p != paths.end(); ++p)
{
*p = fullPath(*p);
}
StringList includes = un->includeFiles();
for(StringList::const_iterator q = includes.begin(); q != includes.end(); ++q)
{
string file = changeInclude(*q, paths);
out << nl << "require '" << file << ".rb'";
}
}
CodeVisitor codeVisitor(out);
un->visit(&codeVisitor, false);
if(checksum)
{
ChecksumMap checksums = createChecksums(un);
if(!checksums.empty())
{
out << sp;
for(ChecksumMap::const_iterator p = checksums.begin(); p != checksums.end(); ++p)
{
out << nl << "::Ice::SliceChecksums[\"" << p->first << "\"] = \"";
ostringstream str;
str.flags(ios_base::hex);
str.fill('0');
for(vector<unsigned char>::const_iterator q = p->second.begin(); q != p->second.end(); ++q)
{
str << (int)(*q);
}
out << str.str() << "\"";
}
}
}
out << nl; // Trailing newline.
}
开发者ID:bholl,项目名称:zeroc-ice,代码行数:47,代码来源:RubyUtil.cpp
示例9: assert
bool
Slice::ObjCGenerator::MetaDataVisitor::visitUnitStart(const UnitPtr& p)
{
//
// Validate global metadata in the top-level file and all included files.
//
StringList files = p->allFiles();
for(StringList::iterator q = files.begin(); q != files.end(); ++q)
{
string file = *q;
DefinitionContextPtr dc = p->findDefinitionContext(file);
assert(dc);
StringList globalMetaData = dc->getMetaData();
int headerDir = 0;
for(StringList::const_iterator r = globalMetaData.begin(); r != globalMetaData.end(); ++r)
{
string s = *r;
if(_history.count(s) == 0)
{
if(s.find(_objcPrefix) == 0)
{
static const string objcHeaderDirPrefix = "objc:header-dir:";
if(s.find(objcHeaderDirPrefix) == 0 && s.size() > objcHeaderDirPrefix.size())
{
headerDir++;
if(headerDir > 1)
{
ostringstream ostr;
ostr << "ignoring invalid global metadata `" << s
<< "': directive can appear only once per file";
emitWarning(file, -1, ostr.str());
_history.insert(s);
}
continue;
}
ostringstream ostr;
ostr << "ignoring invalid global metadata `" << s << "'";
emitWarning(file, -1, ostr.str());
}
_history.insert(s);
}
}
}
return true;
}
开发者ID:joshmoore,项目名称:ice,代码行数:47,代码来源:ObjCUtil.cpp
示例10: UnRegisterUnit
void Section::UnRegisterUnit(const UnitPtr& unit)
{
unit->SetSection(nullptr);
m_UnitList.remove_if([&unit](auto& target)
{
return target.lock() == unit;
});
}
开发者ID:dlakwwkd,项目名称:SimpleConsoleGame,代码行数:8,代码来源:Section.cpp
示例11: createChecksums
Slice::ChecksumMap Slice::createChecksums(const UnitPtr& u)
{
ChecksumMap result;
ChecksumVisitor visitor(result);
u->visit(&visitor, false);
return result;
}
开发者ID:wuhua988,项目名称:icm,代码行数:9,代码来源:Checksum.cpp
示例12: Push
void SqlQueue::Push(const UnitPtr& unit) {
{
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
q_.push(unit);
notify();
}
MCE_INFO(unit->MakeInLog());
manager_->Update(1);
return;
}
开发者ID:bradenwu,项目名称:oce,代码行数:10,代码来源:SqlQueue.cpp
示例13: Execute
void SqlQueue::Execute(const UnitPtr& unit) {
// return;//TODO del
Statement st;
st << unit->statement_;
try {
MCE_INFO(unit->MakeOutLog());
// QueryRunner(unit->info_->instance, unit->info_->wrflag,
// unit->info_->pattern).store(st);
usleep(7000);//db平均为7毫秒
// sleep(10000);
} catch (Ice::Exception& e) {
MCE_WARN("SqlQueue::Execute --> error:" << e);
} catch (std::exception& e) {
MCE_WARN("SqlQueue::Execute --> error:" << e.what());
}
}
开发者ID:bradenwu,项目名称:oce,代码行数:16,代码来源:SqlQueue.cpp
示例14: RegisterUnit
bool Section::RegisterUnit(const UnitPtr& unit)
{
if (unit == nullptr)
return false;
Direction dir;
if (IsOutOfBoundary(unit, dir))
{
// 유닛이 바운더리 바깥이면 해당 방향의 섹션에 등록을 시도한다.
return RegisterUnit(unit, dir);
}
// 유닛 리스트에 등록하고, 유닛에게 등록된 섹션을 알려준다.
// 섹션끼리는 weak_ptr만 들고있기 때문에, 여기서 유닛에게 보관시키는
// shared_ptr이 유효 카운트이다.
// 즉, 이 섹션에 포함된 유닛이 0이 될때, 자동으로 이 섹션도 파괴된다.
m_UnitList.push_back(unit);
unit->SetSection(shared_from_this());
return true;
}
开发者ID:dlakwwkd,项目名称:SimpleConsoleGame,代码行数:19,代码来源:Section.cpp
示例15: IcePy_loadSlice
//.........这里部分代码省略.........
{
cppArgs.push_back("-D" + *i);
}
}
if(opts.isSet("U"))
{
vector<string> optargs = opts.argVec("U");
for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
{
cppArgs.push_back("-U" + *i);
}
}
if(opts.isSet("I"))
{
includePaths = opts.argVec("I");
for(vector<string>::const_iterator i = includePaths.begin(); i != includePaths.end(); ++i)
{
cppArgs.push_back("-I" + *i);
}
}
debug = opts.isSet("d") || opts.isSet("debug");
all = opts.isSet("all");
checksum = opts.isSet("checksum");
bool ignoreRedefs = false;
bool keepComments = true;
for(vector<string>::const_iterator p = files.begin(); p != files.end(); ++p)
{
string file = *p;
Slice::PreprocessorPtr icecpp = Slice::Preprocessor::create("icecpp", file, cppArgs);
FILE* cppHandle = icecpp->preprocess(keepComments, "-D__SLICE2PY__");
if(cppHandle == 0)
{
PyErr_Format(PyExc_RuntimeError, "Slice preprocessing failed for `%s'", cmd);
return 0;
}
UnitPtr u = Slice::Unit::createUnit(ignoreRedefs, all, ice, underscore);
int parseStatus = u->parse(file, cppHandle, debug);
if(!icecpp->close() || parseStatus == EXIT_FAILURE)
{
PyErr_Format(PyExc_RuntimeError, "Slice parsing failed for `%s'", cmd);
u->destroy();
return 0;
}
//
// Generate the Python code into a string stream.
//
ostringstream codeStream;
IceUtilInternal::Output out(codeStream);
out.setUseTab(false);
//
// Emit a Python magic comment to set the file encoding.
// It must be the first or second line.
//
out << "# -*- coding: utf-8 -*-\n";
generate(u, all, checksum, includePaths, out);
u->destroy();
string code = codeStream.str();
//
// We need to invoke Ice.updateModules() so that all of the types we've just generated
// are made "public".
//
code += "\nIce.updateModules()\n";
PyObjectHandle src = Py_CompileString(const_cast<char*>(code.c_str()), const_cast<char*>(file.c_str()),
Py_file_input);
if(!src.get())
{
return 0;
}
PyObjectHandle globals = PyDict_New();
if(!globals.get())
{
return 0;
}
PyDict_SetItemString(globals.get(), "__builtins__", PyEval_GetBuiltins());
#if PY_VERSION_HEX >= 0x03000000
PyObjectHandle val = PyEval_EvalCode(src.get(), globals.get(), 0);
#else
PyObjectHandle val = PyEval_EvalCode(reinterpret_cast<PyCodeObject*>(src.get()), globals.get(), 0);
#endif
if(!val.get())
{
return 0;
}
}
Py_INCREF(Py_None);
return Py_None;
}
开发者ID:zeroc-ice,项目名称:ice-debian-packaging,代码行数:101,代码来源:Slice.cpp
示例16: compile
//.........这里部分代码省略.........
int status = EXIT_SUCCESS;
IceUtil::CtrlCHandler ctrlCHandler;
ctrlCHandler.setCallback(interruptedCallback);
DependOutputUtil out(dependFile);
if(dependxml)
{
out.os() << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dependencies>" << endl;
}
for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i)
{
//
// Ignore duplicates.
//
vector<string>::iterator p = find(args.begin(), args.end(), *i);
if(p != i)
{
continue;
}
if(depend || dependxml)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
FILE* cppHandle = icecpp->preprocess(false, "-D__SLICE2CS__");
if(cppHandle == 0)
{
out.cleanup();
return EXIT_FAILURE;
}
UnitPtr u = Unit::createUnit(false, false, ice, underscore);
int parseStatus = u->parse(*i, cppHandle, debug);
u->destroy();
if(parseStatus == EXIT_FAILURE)
{
out.cleanup();
return EXIT_FAILURE;
}
if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::CSharp : Preprocessor::SliceXML, includePaths,
"-D__SLICE2CS__"))
{
out.cleanup();
return EXIT_FAILURE;
}
if(!icecpp->close())
{
out.cleanup();
return EXIT_FAILURE;
}
}
else
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
FILE* cppHandle = icecpp->preprocess(true, "-D__SLICE2CS__");
if(cppHandle == 0)
{
return EXIT_FAILURE;
}
if(preprocess)
开发者ID:zhangwei5095,项目名称:ice,代码行数:67,代码来源:Main.cpp
示例17:
void
Slice::ObjCGenerator::validateMetaData(const UnitPtr& u)
{
MetaDataVisitor visitor;
u->visit(&visitor, true);
}
开发者ID:joshmoore,项目名称:ice,代码行数:6,代码来源:ObjCUtil.cpp
示例18: compile
//.........这里部分代码省略.........
if(args.empty())
{
getErrorStream() << argv[0] << ": error: no input file" << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
int status = EXIT_SUCCESS;
IceUtil::CtrlCHandler ctrlCHandler;
ctrlCHandler.setCallback(interruptedCallback);
for(i = args.begin(); i != args.end(); ++i)
{
//
// Ignore duplicates.
//
vector<string>::iterator p = find(args.begin(), args.end(), *i);
if(p != i)
{
continue;
}
if(depend)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
FILE* cppHandle = icecpp->preprocess(false);
if(cppHandle == 0)
{
return EXIT_FAILURE;
}
UnitPtr u = Unit::createUnit(false, false, ice, underscore);
int parseStatus = u->parse(*i, cppHandle, debug);
u->destroy();
if(parseStatus == EXIT_FAILURE)
{
return EXIT_FAILURE;
}
if(!icecpp->printMakefileDependencies(Preprocessor::PHP, includePaths))
{
return EXIT_FAILURE;
}
if(!icecpp->close())
{
return EXIT_FAILURE;
}
}
else
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
FILE* cppHandle = icecpp->preprocess(false);
if(cppHandle == 0)
{
return EXIT_FAILURE;
}
if(preprocess)
{
char buf[4096];
while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
开发者ID:bholl,项目名称:zeroc-ice,代码行数:67,代码来源:Main.cpp
示例19: main
//.........这里部分代码省略.........
argv[i] = argv[i + 1];
}
--argc;
}
else if(strcmp(argv[idx], "--ice") == 0)
{
ice = true;
for(int i = idx ; i + 1 < argc ; ++i)
{
argv[i] = argv[i + 1];
}
--argc;
}
else if(strcmp(argv[idx], "--case-sensitive") == 0)
{
caseSensitive = true;
for(int i = idx ; i + 1 < argc ; ++i)
{
argv[i] = argv[i + 1];
}
--argc;
}
else if(strcmp(argv[idx], "--output-dir") == 0)
{
if(idx + 1 >= argc)
{
cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
output = argv[idx + 1];
for(int i = idx ; i + 2 < argc ; ++i)
{
argv[i] = argv[i + 2];
}
argc -= 2;
}
else if(argv[idx][0] == '-')
{
cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
else
{
++idx;
}
}
if(argc < 2)
{
cerr << argv[0] << ": no input file" << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
UnitPtr p = Unit::createUnit(true, false, ice, caseSensitive);
int status = EXIT_SUCCESS;
for(idx = 1 ; idx < argc ; ++idx)
{
Preprocessor icecpp(argv[0], argv[idx], cppArgs);
FILE* cppHandle = icecpp.preprocess(false);
if(cppHandle == 0)
{
return EXIT_FAILURE;
}
UnitPtr u = Unit::createUnit(false, false, ice, caseSensitive);
int parseStatus = u->parse(cppHandle, debug);
if(!icecpp.close())
{
u->destroy();
return EXIT_FAILURE;
}
if(parseStatus == EXIT_FAILURE)
{
status = EXIT_FAILURE;
}
else
{
Gen gen(argv[0], icecpp.getBaseName(), output);
if(!gen)
{
u->destroy();
return EXIT_FAILURE;
}
gen.generate(u);
}
u->destroy();
}
return status;
}
开发者ID:emtees,项目名称:old-code,代码行数:101,代码来源:Main.cpp
示例20: find_if_matches_helper
bool find_if_matches_helper(const UnitPtr & ptr, const std::string & unit_id)
{
return ptr->matches_id(unit_id);
}
开发者ID:tremblayEric,项目名称:wesnoth,代码行数:4,代码来源:recall_list_manager.cpp
注:本文中的UnitPtr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论