本文整理汇总了C++中NullPointerException函数的典型用法代码示例。如果您正苦于以下问题:C++ NullPointerException函数的具体用法?C++ NullPointerException怎么用?C++ NullPointerException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NullPointerException函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: NullPointerException
/*!
* Returns the element for the pair (p1, p2), either by retrieving an
* existing element (see \ref retrieveElement) or by creating a new one, if
* no element for that pair exists yet.
*
* \return Either the value of \ref retrieveElement or a new element for
* (p1,p2), if \ref retrieveElement returns NULL.
*/
CollisionCacheElement* CollisionCache::retrieveOrAddElement(Proxy* p1, Proxy* p2) {
if (!p1) {
throw NullPointerException("p1");
}
if (!p2) {
throw NullPointerException("p2");
}
CollisionCacheElement* element = retrieveElement(p1, p2);
if (element) {
return element;
}
element = new CollisionCacheElement(p1, p2);
element->mCachePosition1 = mMap.insert(std::make_pair(p1, element));
//insert the second element only for non-selfcollisions
if (p1 != p2) {
element->mCachePosition2 = mMap.insert(std::make_pair(p2, element));
} else {
element->mCachePosition2 = element->mCachePosition1;
}
return element;
}
开发者ID:ColinGilbert,项目名称:d-collide,代码行数:34,代码来源:collisioncache.cpp
示例2: memset
std::istream& RouteCost::load(std::istream& input)
{
// if (CityMap::Instance().fileLength < 5*sizeof(int)) {
// throw NullPointerException();
// }
// CityMap::Instance().fileLength -= 5*sizeof(int);
char intBuf[sizeof(int)];
memset(intBuf,0,sizeof(int));
input.read(intBuf, sizeof(int));
moneyCost = *(reinterpret_cast<int*>(intBuf));
std::cout << "read moneyCost "<<moneyCost<<std::endl;
int hour,min,sec;
input.read(intBuf, sizeof(int));
hour = *(reinterpret_cast<int*>(intBuf));
input.read(intBuf, sizeof(int));
min = *(reinterpret_cast<int*>(intBuf));
input.read(intBuf, sizeof(int));
sec = *(reinterpret_cast<int*>(intBuf));
this->timeCost = QTime(hour, min, sec);
std::cout << "read time "<<hour<<" "<<min<<" "<<sec<<std::endl;
input.read(intBuf, sizeof(int));
unsigned int interestsCount = *(reinterpret_cast<int*>(intBuf));
interests = std::set<Interest>();
if (interestsCount > 20) {
throw NullPointerException();
}
std::cout<<"read interests count "<<interestsCount << std::endl;
for (int i = 0; i < interestsCount; i++) {
input.read(intBuf, sizeof(int));
Interest interest = *(reinterpret_cast<Interest*>(intBuf));
interests.insert(interest);
}
input.read(intBuf, sizeof(int));
unsigned int transportsCount = *(reinterpret_cast<int*>(intBuf));
transports = std::set<Transport>();
if (transportsCount > 20) {
throw NullPointerException();
}
std::cout<<"read transports count "<<transportsCount << std::endl;
for (int i = 0; i < transportsCount; i++) {
input.read(intBuf, sizeof(int));
Transport transport = *(reinterpret_cast<Transport*>(intBuf));
transports.insert((Transport) transport);
}
return input;
}
开发者ID:LepilkinaElena,项目名称:EasyRouting,代码行数:58,代码来源:routecost.cpp
示例3: NullPointerException
/** Add one thread.
* Add the given thread to the thread manager. The thread is initialized
* as appropriate and started. See the class documentation for supported
* specialisations of threads and the performed initialisation steps.
* If the thread initializer cannot initalize the thread it is not added.
* @param thread thread to add
* @param lock if true the environment is locked before adding the thread
* @exception CannotInitializeThreadException thrown if at least the
* thread could not be initialised
*/
void
ThreadManager::add_maybelocked(Thread *thread, bool lock)
{
if ( thread == NULL ) {
throw NullPointerException("FawkesThreadMananger: cannot add NULL as thread");
}
if ( ! (__initializer && __finalizer) ) {
throw NullPointerException("ThreadManager: initializer/finalizer not set");
}
try {
__initializer->init(thread);
} catch (CannotInitializeThreadException &e) {
thread->notify_of_failed_init();
e.append("Adding thread in ThreadManager failed");
throw;
}
// if the thread's init() method fails, we need to finalize that very
// thread only with the finalizer, already initialized threads muts be
// fully finalized
try {
thread->init();
} catch (CannotInitializeThreadException &e) {
thread->notify_of_failed_init();
__finalizer->finalize(thread);
throw;
} catch (Exception &e) {
thread->notify_of_failed_init();
CannotInitializeThreadException
cite("Could not initialize thread '%s'", thread->name());
cite.append(e);
__finalizer->finalize(thread);
throw cite;
} catch (std::exception &e) {
thread->notify_of_failed_init();
CannotInitializeThreadException
cite("Could not initialize thread '%s'", thread->name());
cite.append("Caught std::exception or derivative: %s", e.what());
__finalizer->finalize(thread);
throw cite;
} catch (...) {
thread->notify_of_failed_init();
CannotInitializeThreadException
cite("Could not initialize thread '%s'", thread->name());
cite.append("Unknown exception caught");
__finalizer->finalize(thread);
throw cite;
}
thread->start();
MutexLocker locker(__threads.mutex(), lock);
internal_add_thread(thread);
}
开发者ID:tempbottle,项目名称:fawkes,代码行数:65,代码来源:thread_manager.cpp
示例4: NullPointerException
void BvHierarchyAlgorithm::translateProxy(Proxy* proxy, const Vector3& translateBy) {
if (!proxy) {
throw NullPointerException("proxy");
}
BvHierarchyProxyData* data = static_cast<BvHierarchyProxyData*>(proxy->getDetectorDeformProxyData(getProxyDataIndex()));
if (!data) {
throw NullPointerException("data");
}
data->mDeformableNode->translate(translateBy);
}
开发者ID:ColinGilbert,项目名称:d-collide,代码行数:11,代码来源:bvhierarchyalgorithm.cpp
示例5: NullPointerException
/*!
* Create \ref PipelineThreadJobCollection object that uses \p
* pipeline nd starts its jobs in \p phase (see \ref Pipeline::Phase).
*/
PipelineThreadJobCollection::PipelineThreadJobCollection(Pipeline* pipeline, Pipeline::Phase phase) {
mPipeline = pipeline;
if (!mPipeline) {
throw NullPointerException("mPipeline");
}
mPhase = phase;
}
开发者ID:ColinGilbert,项目名称:d-collide,代码行数:11,代码来源:pipeline.cpp
示例6: md
/** Run dialog and try to connect.
* This runs the service chooser dialog and connects to the given service
* with the attached FawkesNetworkClient. If the connection couldn't be established
* an error dialog is shown. You should not rely on the connection to be
* active after calling this method, rather you should use a ConnectionDispatcher
* to get the "connected" signal.
*/
void
ServiceChooserDialog::run_and_connect()
{
if (! __client) throw NullPointerException("FawkesNetworkClient not set");
if (__client->connected()) throw Exception("Client is already connected");
if ( run() ) {
try {
Glib::ustring name;
Glib::ustring hostname;
Glib::ustring ipaddr;
unsigned short int port;
get_selected_service(name, hostname, ipaddr, port);
if ( port == 0 ) port = 1910;
__client->connect(hostname.c_str(), ipaddr.c_str(), port);
} catch (Exception &e) {
Glib::ustring message = *(e.begin());
Gtk::MessageDialog md(__parent, message, /* markup */ false,
Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK,
/* modal */ true);
md.set_title("Connection failed");
md.run();
}
}
}
开发者ID:fuxiang90,项目名称:fawkes,代码行数:33,代码来源:service_chooser_dialog.cpp
示例7: m_rpOutputStream
//==============================================================================
BufferedOutputStream::BufferedOutputStream(OutputStream* pOutputStream, size_t bufSize) :
m_rpOutputStream(pOutputStream)
{
if(!pOutputStream) throw NullPointerException();
init(bufSize ? bufSize : DefaultBufferSize);
}
开发者ID:twangjie,项目名称:quickcpp,代码行数:8,代码来源:BufferedOutputStream.cpp
示例8: NullPointerException
/*!
* \brief Create a new BoundingVolume object.
*
* This method creates and returns a new BoundingVolume object, according to
* the preferred BoundingVolume-type settings.
*
* \param parent The BvhNode that the BoundingVolume should be in. See \ref
* setHierarchyNode.
*
* \return A new BoundingVolume object. The caller is responsible for
* deleting it.
*/
BoundingVolume* BoundingVolume::createBoundingVolume(World* world, BvhNode* parent) {
if (!world) {
throw NullPointerException("Parameter world");
}
BoundingVolume* bv = 0;
switch (getCreateRigidBoundingVolumeType(world)) {
case BV_TYPE_AABB:
bv = new Aabb();
break;
case BV_TYPE_KDOP:
bv = new Kdop();
break;
case BV_TYPE_SPHERE:
bv = new BoundingSphere();
break;
case BV_TYPE_OBB:
bv = new Obb();
break;
default:
// TODO: exception!!
std::cerr << dc_funcinfo << "FATAL ERROR: bounding volume type " << getCreateRigidBoundingVolumeType(world) << " not supported" << std::endl;
exit(1);
return 0;
}
bv->setHierarchyNode(parent);
return bv;
}
开发者ID:ColinGilbert,项目名称:d-collide,代码行数:39,代码来源:boundingvolume.cpp
示例9: NullPointerException
/*!
* Add \p job to the \ref ThreadPool, see \ref setPool.
*
* This method is NOT thread safe and assumes that it will always be called
* from the main thread only.
*/
void ThreadJobCollection::startJob(ThreadJob* job) {
if (!mThreadPool) {
throw NullPointerException("mThreadPool");
}
mThreadPool->addJob(job);
}
开发者ID:ColinGilbert,项目名称:d-collide,代码行数:13,代码来源:threadjobcollection.cpp
示例10: NullPointerException
void Expression::addOperator(OperationCode *opcode, Token *token) {
if (!token) {
throw NullPointerException("Token cannot be nil");
}
if ((token->aType & Token::OPERATOR) == 0) {
throw InvalidTokenException("Expected an operator, got: " + token->token);
}
byte oper = 0;
string s = token->token;
if (s == "+") {
oper = OP_ADD;
} else if (s == "-") {
oper = OP_SUB;
} else if (s == "*") {
oper = OP_MUL;
} else if (s == "/") {
oper = OP_DIV;
} else if (s == "%") {
oper = OP_MOD;
} else {
throw NotImplementedException("Operator is not implemented: " + s);
}
opcode->addInterop(new ByteOperation(oper));
}
开发者ID:freakypain,项目名称:Aiki,代码行数:28,代码来源:Expression.cpp
示例11: TestBufferIsValid
//==============================================================================
// SystemUtils::TestBufferIsValid
//
// Test that the passed buffer is appropriate for calls to read() operations.
//==============================================================================
void SystemUtils::TestBufferIsValid(const void* pBuffer, size_t& bufLen)
{
if(!pBuffer) throw NullPointerException();
if(!bufLen) throw IllegalArgumentException(QC_T("zero buffer length"));
if(bufLen > LONG_MAX)
bufLen = LONG_MAX;
}
开发者ID:twangjie,项目名称:quickcpp,代码行数:12,代码来源:SystemUtils.cpp
示例12: write
//==============================================================================
void BufferedOutputStream::write(const Byte* pBuffer, size_t bufLen)
{
if(!pBuffer) throw NullPointerException();
if(!m_rpOutputStream) throw IOException(QC_T("stream closed"));
if(m_used + bufLen > m_bufferSize)
{
QC_DBG_ASSERT(m_pBuffer!=0);
// Write our buffer without flushing out the stream
writeBuffer();
QC_DBG_ASSERT(0 == m_used);
}
if(bufLen > m_bufferSize)
{
QC_DBG_ASSERT(0 == m_used);
m_rpOutputStream->write(pBuffer, bufLen);
}
else
{
QC_DBG_ASSERT(m_pBuffer!=0);
QC_DBG_ASSERT(bufLen + m_used <= m_bufferSize);
::memcpy(m_pBuffer+m_used, pBuffer, bufLen);
m_used+=bufLen;
}
}
开发者ID:twangjie,项目名称:quickcpp,代码行数:27,代码来源:BufferedOutputStream.cpp
示例13: LOG_DEBUG_F
void MultiInterventionEventCoordinator::DistributeInterventionsToNodes( INodeEventContext* event_context )
{
const json::Array & interventions_array = json::QuickInterpreter( intervention_config._json ).As<json::Array>();
LOG_DEBUG_F( "interventions array size = %d\n", interventions_array.Size() );
for( int idx = 0; idx < interventions_array.Size(); idx++ )
{
const json::Object& actualIntervention = json_cast<const json::Object&>(interventions_array[ idx ]);
Configuration * config = Configuration::CopyFromElement( actualIntervention );
assert( config );
LOG_DEBUG_F( "Attempting to instantiate intervention of class %s\n",
std::string( (*config)[ "class" ].As<json::String>() ).c_str() );
INodeDistributableIntervention *ndi = InterventionFactory::getInstance()->CreateNDIIntervention( config );
if( ndi == nullptr )
{
throw NullPointerException( __FILE__, __LINE__, __FUNCTION__, "Should have constructed a node-level intervention." );
}
if( ndi->Distribute( event_context, this ) )
{
LOG_INFO_F( "UpdateNodes() distributed '%s' intervention to node %d\n", ndi->GetName().c_str(), event_context->GetId().data );
}
ndi->Release();
delete config;
config = nullptr;
}
}
开发者ID:clorton,项目名称:EMOD,代码行数:28,代码来源:MultiInterventionEventCoordinator.cpp
示例14: NullPointerException
/** Register BB event listener.
* @param listener BlackBoard event listener to register
* @param flag flags what to register for
*/
void
BlackBoard::register_listener(BlackBoardInterfaceListener *listener, ListenerRegisterFlag flag)
{
if (!notifier_)
throw NullPointerException("BlackBoard initialized without notifier");
notifier_->register_listener(listener, flag);
}
开发者ID:fawkesrobotics,项目名称:fawkes,代码行数:11,代码来源:blackboard.cpp
示例15: LOG_DEBUG_F
void
DiagnosticTreatNeg::onPatientDefault()
{
LOG_DEBUG_F( "Individual %d got the test but defaulted, receiving Defaulters intervention without waiting for days_to_diagnosis (actually means days_to_intervention) \n", parent->GetSuid().data );
// Important: Use the instance method to obtain the intervention factory obj instead of static method to cross the DLL boundary
IGlobalContext *pGC = nullptr;
const IInterventionFactory* ifobj = nullptr;
if (s_OK == parent->QueryInterface(GET_IID(IGlobalContext), (void**)&pGC))
{
ifobj = pGC->GetInterventionFactory();
}
if (!ifobj)
{
throw NullPointerException( __FILE__, __LINE__, __FUNCTION__, "parent->GetInterventionFactoryObj()" );
}
if( !defaulters_event.IsUninitialized() )
{
if( defaulters_event != NO_TRIGGER_STR )
{
INodeTriggeredInterventionConsumer* broadcaster = nullptr;
if (s_OK != parent->GetEventContext()->GetNodeEventContext()->QueryInterface(GET_IID(INodeTriggeredInterventionConsumer), (void**)&broadcaster))
{
throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "parent->GetEventContext()->GetNodeEventContext()", "INodeTriggeredInterventionConsumer", "INodeEventContext" );
}
broadcaster->TriggerNodeEventObserversByString( parent->GetEventContext(), defaulters_event );
}
}
else if( defaulters_config._json.Type() != ElementType::NULL_ELEMENT )
{
auto tmp_config = Configuration::CopyFromElement(defaulters_config._json);
// Distribute the defaulters intervention, right away (do not use the days_to_diagnosis
IDistributableIntervention *di = const_cast<IInterventionFactory*>(ifobj)->CreateIntervention( tmp_config );
delete tmp_config;
tmp_config = nullptr;
ICampaignCostObserver* pICCO;
// Now make sure cost of the test-positive intervention is reported back to node
if (s_OK == parent->GetEventContext()->GetNodeEventContext()->QueryInterface(GET_IID(ICampaignCostObserver), (void**)&pICCO) )
{
di->Distribute( parent->GetInterventionsContext(), pICCO );
pICCO->notifyCampaignEventOccurred( (IBaseIntervention*)di, (IBaseIntervention*)this, parent );
}
else
{
throw QueryInterfaceException( __FILE__, __LINE__, __FUNCTION__, "parent->GetEventContext()->GetNodeEventContext()", "ICampaignCostObserver", "INodeEventContext" );
}
}
else
{
throw GeneralConfigurationException( __FILE__, __LINE__, __FUNCTION__, "neither event or config defined" );
}
}
开发者ID:Bridenbecker,项目名称:EMOD,代码行数:60,代码来源:DiagnosticsTreatNeg.cpp
示例16: NullPointerException
void vmtkImageFeature::BuildFWHMBasedFeatureImage(vtkImageData*originalData,vtkImageData* res)
{
log4cpp::Category& rootLog = log4cpp::Category::getRoot();
log4cpp::Category& subLog = log4cpp::Category::getInstance(std::string("sub1"));
if(res == 0||res->GetReferenceCount() < 1)
{
throw NullPointerException("BuildFWHMBasedFeatureImage(vtkImageData*originalData,vtkImageData* res):res是空指针,请初始化");
}
rootLog.info("void vmtkImageFeature::BuildFWHMBasedFeatureImage(vtkImageData*originalData,vtkImageData* res) start......");
subLog.info("void vmtkImageFeature::BuildFWHMBasedFeatureImage(vtkImageData*originalData,vtkImageData* res) start.......");
vtkSmartPointer<vtkImageCast> cast = vtkSmartPointer<vtkImageCast>::New();
cast->SetInputData(originalData);
cast->SetOutputScalarTypeToFloat();
cast->Update();
vtkSmartPointer<vtkvmtkFWHMFeatureImageFilter> fwhmFeatureImageFilter = vtkSmartPointer<vtkvmtkFWHMFeatureImageFilter>::New();
//fwhmFeatureImageFilter->SetInputConnection(cast->GetOutputPort());
fwhmFeatureImageFilter->SetInputData(cast->GetOutput());
int _FWHMRadius[3];
for(int i = 0; i < 3;i++)
{
_FWHMRadius[i] = FWHMRadius[i];
}
fwhmFeatureImageFilter->SetRadius(_FWHMRadius);
fwhmFeatureImageFilter->SetBackgroundValue(FWHMBackgroundValue);
fwhmFeatureImageFilter->Update();
res->DeepCopy(fwhmFeatureImageFilter->GetOutput());
}
开发者ID:bleachzou3,项目名称:vascuview,代码行数:29,代码来源:vmtkImageFeatures.cpp
示例17:
/** Unregister BB interface observer.
* This will remove the given BlackBoard event listener from any event that it was
* previously registered for.
* @param observer BlackBoard event listener to remove
*/
void
BlackBoard::unregister_observer(BlackBoardInterfaceObserver *observer)
{
if (! __notifier) throw NullPointerException("BlackBoard initialized without notifier");
if (! observer) return;
__notifier->unregister_observer(observer);
}
开发者ID:tempbottle,项目名称:fawkes,代码行数:12,代码来源:blackboard.cpp
示例18: m_rpWriter
//==============================================================================
BufferedWriter::BufferedWriter(Writer* pWriter, size_t bufSize) :
m_rpWriter(pWriter)
{
if(!pWriter) throw NullPointerException();
m_rpLock = pWriter->getLock();
init(bufSize ? bufSize : DefaultBufferSize);
}
开发者ID:twangjie,项目名称:quickcpp,代码行数:9,代码来源:BufferedWriter.cpp
示例19: NullPointerException
void Group::AddObserver(INotifiableSystem* pObserver)
{
if(!pObserver){
throw NullPointerException("Group::AddObserver", "Observer is null");
}
m_pObservers.push_back(pObserver);
}
开发者ID:TimJGit,项目名称:ECS,代码行数:8,代码来源:Group.cpp
示例20: NullPointerException
/** Return payload size
* @return payload size
* @exception NullPointerException thrown if _payload does not point to a valid
* buffer or if _payload_size is zero.
*/
size_t
FawkesNetworkMessageContent::payload_size()
{
if ( (_payload == NULL) || (_payload_size == 0) ) {
throw NullPointerException("Payload in network message content may not be NULL");
}
return _payload_size;
}
开发者ID:fuxiang90,项目名称:fawkes,代码行数:13,代码来源:message_content.cpp
注:本文中的NullPointerException函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论