本文整理汇总了C++中SmartPointer类的典型用法代码示例。如果您正苦于以下问题:C++ SmartPointer类的具体用法?C++ SmartPointer怎么用?C++ SmartPointer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SmartPointer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnPressA
bool OptionsInputEventHandler::OnPressA()
{
if (!InputHandler::OnPressA())
{
SmartPointer<OptionsScreen> sc = SmartPointerFunctions::Cast<Scene, OptionsScreen>(SceneManager::GetScene());
if (sc->GetMenuPosition() == 6)
{
sc->Save();
ReturnToPreviousScreen();
}
else
{
sc->IncrementValueAt();
}
}
return false;
}
示例2:
void Disk3D_BB::setMetric(SmartPointer<Metric::Generic> gg) {
//Metric must be KerrBL (see emission function)
string kind = gg->getKind();
if (kind != "KerrBL")
throwError
("Disk3D_BB::setMetric(): metric must be KerrBL");
Disk3D::setMetric(gg);
}
示例3: s
/***
* Loads textures, attributes, uniforms, shaders, etc.
*
* @param filename is the name for the file where we get the data
*/
void Scene::loadData(const string &filename) {
int currentLine = 0;
recentProgramHandle = -1;
const Resource *data = FAH::Viewer::resource0.find(filename);
if (!data) THROWS("Could not find resource: " << filename);
string s(data->getData(), data->getLength());
istringstream in(s);
freeResources();
while (!in.eof()) {
SmartPointer<Uniform> uniform;
string lineString;
string item;
string key;
getline(in, lineString);
stringstream line(lineString);
++currentLine;
line >> item;
if (8 < item.length() && item.substr(0, 8) == "uniform_") {
float val[16];
line >> key;
item = item.substr(8);
int count;
uniform_t type;
if (item == "float") {type = SAMPLE_FLOAT; count = 1;}
else if (item == "vec2") {type = SAMPLE_FLOAT_VEC2; count = 2;}
else if (item == "vec3") {type = SAMPLE_FLOAT_VEC3; count = 3;}
else if (item == "vec4") {type = SAMPLE_FLOAT_VEC4; count = 4;}
else if (item == "mat4") {type = SAMPLE_FLOAT_MAT4; count = 16;}
else THROWS("Invalid uniform type " << item);
for (int i = 0; i < count; i++) line >> val[i];
uniform = new Uniform(key, type);
uniform->setLocation(recentProgramHandle);
uniform->update(val);
} else if (item == "attribute") {
示例4: bounds
void STLModule::bounds(const js::Value &args, js::Sink &sink) {
SmartPointer<js::Value> facets = args.get("stl")->get("facets");
Rectangle3F bounds;
unsigned length = facets->length();
for (unsigned i = 0; i < length; i++) {
SmartPointer<js::Value> facet = facets->get(i);
for (unsigned j = 0; j < 3; j++)
bounds.add(toVector3F(*facet->get(j)));
}
sink.beginList();
append(sink, bounds.getMin());
append(sink, bounds.getMax());
sink.endList();
}
示例5: is_xml
static bool is_xml(const std::string &filename) {
try {
if (!SystemUtilities::exists(filename)) return false;
SmartPointer<iostream> stream = SystemUtilities::open(filename, ios::in);
while (true) {
int c = stream->peek();
if (c == '<') return true;
else if (isspace(c)) stream->get(); // Next
else return false; // Not XML
}
} CATCH_WARNING;
return false;
}
示例6:
void DynamicalDisk3D::metric(SmartPointer<Metric::Generic> gg) {
//Metric must be KerrBL (see emission function)
string kin = gg->kind();
if (kin != "KerrBL" && kin != "Minkowski")
throwError
("DynamicalDisk3D::metric(): metric must be KerrBL");
Disk3D::metric(gg);
}
示例7: create_bitmap_from_sdl
ALLEGRO_BITMAP *create_bitmap_ex(int color_depth, int width, int height) {
SmartPointer<SDL_Surface> surf;
if(color_depth == 8)
surf = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 8, 0,0,0,0);
else
surf = create_32bpp_sdlsurface__allegroformat(width, height);
if(!surf.get()) {
errors << "create_bitmap_ex: cannot create surface with " << width << "x" << height << "x" << color_depth << endl;
return NULL;
}
FillSurface(surf.get(), Color());
if(surf->format->BitsPerPixel != color_depth)
warnings << "create_bitmap_ex: couldn't create surface with " << color_depth << " bpp" << endl;
return create_bitmap_from_sdl(surf);
}
示例8: metric
void PatternDiskBB::metric(SmartPointer<Metric::Generic> gg) {
//Metric must be KerrBL or alike
string kin = gg->kind();
if ((kin != "KerrBL") && (kin != "ChernSimons"))
throwError
("PatternDiskBB::metric(): metric must be KerrBL or CS");
ThinDisk::metric(gg);
}
示例9: resolve_encounter
void LifeForm::resolve_encounter(SmartPointer<LifeForm> alien) {
Action my_act = this->encounter(this->info_about_them(alien));
// my action (EAT or IGNORE)
SmartPointer<LifeForm> self = SmartPointer<LifeForm>(this);
// alien's action
Action alien_act = alien->encounter(alien->info_about_them(self));
// if both sides are willing to eat each other
if (my_act == Action::LIFEFORM_EAT && alien_act == Action::LIFEFORM_EAT) {
bool me_succeed = LifeForm::eat_trial(self, alien);
bool alien_succeed = LifeForm::eat_trial(alien, self);
// break the tie based on the strategy
if (me_succeed && alien_succeed) {
if (::encounter_strategy == EncounterResolver::EVEN_MONEY) {
drand48() > 0.5 ? this->eat(alien) : alien->eat(self);
} else if (::encounter_strategy == EncounterResolver::BIG_GUY_WINS) {
this->energy > alien->energy ? this->eat(alien) : alien->eat(self);
} else if (::encounter_strategy == EncounterResolver::UNDERDOG_IS_HERE) {
this->energy < alien->energy ? this->eat(alien) : alien->eat(self);
} else if (::encounter_strategy == EncounterResolver::FASTER_GUY_WINS) {
this->speed > alien->speed ? this->eat(alien) : alien->eat(self);
} else if (::encounter_strategy == EncounterResolver::SLOWER_GUY_WINS) {
this->speed < alien->speed ? this->eat(alien) : alien->eat(self);
}
} else if (me_succeed) {
this->eat(alien);
} else if (alien_succeed) {
alien->eat(self);
}
} else if (my_act == Action::LIFEFORM_EAT && alien_act == Action::LIFEFORM_IGNORE) {
if (LifeForm::eat_trial(self, alien)) {
this->eat(alien);
}
} else if (my_act == Action::LIFEFORM_IGNORE && alien_act == Action::LIFEFORM_EAT) {
if (LifeForm::eat_trial(alien, self)) {
alien->eat(self);
}
}
}
示例10: CreateIdentifierId
QString ContributionRoot::CreateIdentifierId(const SmartPointer<IContributionItem>& item)
{
QString namespaze = factory->GetNamespace();
// create the activity identifier ID. If this factory doesn't have a namespace
// it will be null.
QString identifierID = (!namespaze.isEmpty()) ? namespaze + '/' + item->GetId()
: QString();
return identifierID;
}
示例11: SetController
void WorldSimulation::SetController(int index,SmartPointer<RobotController> c)
{
if(robotControllers.empty()) {
robotControllers.resize(world->robots.size());
}
robotControllers[index] = c;
controlSimulators[index].controller = c;
if(c) c->Reset();
}
示例12: Event
Action byf69::encounter(const ObjInfo& info) {
if (this->is_byf69(info) && info.species != this->m_name_eat_me) {
return LIFEFORM_IGNORE;
}
else {
if (info.species == this->m_name_eat_me) {
if ((this->m_eat_health_factor - 1.0) * this->health() > info.health) {
return LIFEFORM_IGNORE; // false encounter with eat_me lifeform
}
}
this->sniff_event->cancel();
this->reverse_direction_event->cancel();
SmartPointer<byf69> self = SmartPointer<byf69>(this);
this->sniff_event = new Event(0.0, [self](void) { self->sniff(); });
this->reverse_direction_event = new Event(0.0, [self]() { self->reverse_direction(); });
return LIFEFORM_EAT;
}
}
示例13: Add
void EditorHistory::Add(const SmartPointer<EditorHistoryItem>& newItem, int index)
{
// Remove the item if it already exists so that it will be put
// at the top of the list.
if (newItem->IsRestored())
{
this->Remove(newItem->GetInput());
}
// Remove the oldest one
if (fifoList.size() == MAX_SIZE)
{
fifoList.pop_back();
}
// Add the new item.
fifoList.insert(index < MAX_SIZE ? index : MAX_SIZE - 1, newItem);
}
示例14: ctkInvalidArgumentException
ParameterValueConverterProxy::ParameterValueConverterProxy(
const SmartPointer<IConfigurationElement>& converterConfigurationElement)
: converterConfigurationElement(converterConfigurationElement)
{
if (converterConfigurationElement.IsNull())
{
throw ctkInvalidArgumentException(
"converterConfigurationElement must not be null");
}
}
示例15: VM_PRINTF_LOG
SmartPointer<VMEntryType> VirtualMachine::findType(std::string const& name) {
NamespaceEntry entry;
//If the namespace entry is not found in the namespace
if (!VM::NamespaceEntry::searchNamespace(namespace_, name, entry)) {
VM_PRINTF_LOG("Type %s not found, inspecting to check if array\n", name.c_str());
//If it starts with 'array(' try to generate it from existing types
char const* prefix = "array(";
if (strncmp(prefix, name.c_str(), strlen(prefix)) == 0) {
std::string subtypeName = name.substr(strlen(prefix), name.size() - strlen(prefix) - 1);
VM_PRINTF_LOG("Generating subtype %s\n", subtypeName.c_str());
SmartPointer<VMEntryType> subtype = findType(subtypeName);
if (subtype.get() == nullptr) {
VM_PRINTF_FATAL("Cannot create array of invalid subtype %s\n", subtypeName.c_str());
return nullptr;
}
SmartPointer<VMEntryType> entryType = SmartPointer<VMEntryType>(new VMEntryType(name, subtype));
registerEntry(name, entryType);
VM_PRINTF_LOG("Generating new type %s\n", name.c_str());
return entryType;
} else {
VM_PRINTF_LOG("Prefix of %s does not match with array(\n", name.c_str());
return nullptr;
}
}
//If the entry in the namespace specified is not a type then return null
if (entry.getType() != Type) {
VM_PRINTF_LOG("Error searched type %s (%i)\n", name.c_str(), entry.getType());
return nullptr;
}
return entry.getTypeReference();
}