本文整理汇总了C++中NullPointerException函数的典型用法代码示例。如果您正苦于以下问题:C++ NullPointerException函数的具体用法?C++ NullPointerException怎么用?C++ NullPointerException使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NullPointerException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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();
}
}
}
示例7: m_rpOutputStream
//==============================================================================
BufferedOutputStream::BufferedOutputStream(OutputStream* pOutputStream, size_t bufSize) :
m_rpOutputStream(pOutputStream)
{
if(!pOutputStream) throw NullPointerException();
init(bufSize ? bufSize : DefaultBufferSize);
}
示例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;
}
示例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);
}
示例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));
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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);
}
示例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" );
}
}