Browse Source

Replace `NULL` with `0` everywhere

master
Krisjanis Rijnieks 10 years ago
parent
commit
f160fbd232
  1. 2
      src/MediaServer/DirectoryWatcher.cpp
  2. 10
      src/MediaServer/MediaServer.cpp
  3. 2
      src/Sources/BaseSource.cpp
  4. 12
      src/Sources/FboSource.cpp
  5. 4
      src/Sources/ImageSource.cpp
  6. 12
      src/Sources/VideoSource.cpp
  7. 4
      src/Surfaces/BaseSurface.cpp
  8. 2
      src/Surfaces/QuadSurface.cpp
  9. 22
      src/Surfaces/SurfaceManager.cpp
  10. 20
      src/Surfaces/SurfaceManagerGui.cpp
  11. 2
      src/Surfaces/TriangleSurface.cpp
  12. 20
      src/UserInterface/ProjectionEditor.cpp
  13. 24
      src/UserInterface/SourcesEditor.cpp
  14. 12
      src/UserInterface/TextureEditor.cpp

2
src/MediaServer/DirectoryWatcher.cpp

@ -32,7 +32,7 @@ DirectoryWatcher::DirectoryWatcher(std::string path, int watcherMediaType){
DirectoryWatcher::~DirectoryWatcher(){
delete filter;
filter = NULL;
filter = 0;
}
std::vector <std::string> & DirectoryWatcher::getFilePaths(){

10
src/MediaServer/MediaServer.cpp

@ -85,11 +85,11 @@ BaseSource * MediaServer::loadMedia(string & path, int mediaType){
ofLogFatalError("MediaServer") << ss.str();
std::exit(EXIT_FAILURE);
}
return NULL;
return 0;
}
BaseSource * MediaServer::loadImage(string & path){
ImageSource * imageSource = NULL;
ImageSource * imageSource = 0;
// Check if this image is already loaded
bool isImageLoaded = false;
if(loadedSources.count(path)){
@ -158,7 +158,7 @@ void MediaServer::unloadImage(string & path){
}
BaseSource * MediaServer::loadVideo(string & path){
VideoSource * videoSource = NULL;
VideoSource * videoSource = 0;
// Check if this video is already loaded
bool isVideoLoaded = false;
if(loadedSources.count(path)){
@ -302,7 +302,7 @@ void MediaServer::addFboSource(ofx::piMapper::FboSource & fboSource){
BaseSource * MediaServer::loadFboSource(std::string & fboSourceName){
ofLogNotice("MediaServer") << "Attempting to load FBO source with name " << fboSourceName;
// Search for FBO source name in our storage
FboSource * source = NULL;
FboSource * source = 0;
for(int i = 0; i < fboSources.size(); i++){
if(fboSources[i]->getName() == fboSourceName){
source = fboSources[i];
@ -310,7 +310,7 @@ BaseSource * MediaServer::loadFboSource(std::string & fboSourceName){
}
}
// Panic if not in storage
if(source == NULL){
if(source == 0){
ofLogError("MediaServer") << "Attempt to load non existing FBO source: " << fboSourceName;
ofExit(EXIT_FAILURE);
}

2
src/Sources/BaseSource.cpp

@ -40,7 +40,7 @@ std::string & BaseSource::getPath(){
}
void BaseSource::init(){
texture = NULL;
texture = 0;
name = "";
path = "";
loadable = false;

12
src/Sources/FboSource.cpp

@ -3,7 +3,7 @@
namespace ofx {
namespace piMapper {
FboSource::FboSource() : fbo(NULL){
FboSource::FboSource() : fbo(0){
name = PIMAPPER_FBO_SOURCE_DEF_NAME;
loadable = false;
loaded = false;
@ -53,7 +53,7 @@ void FboSource::onAppSetup(ofEventArgs & args){
}
void FboSource::onAppUpdate(ofEventArgs & args){
if(fbo == NULL || !fbo->isAllocated()){
if(fbo == 0 || !fbo->isAllocated()){
ofLogWarning("FboSource") << "FBO not allocated";
return;
}
@ -61,7 +61,7 @@ void FboSource::onAppUpdate(ofEventArgs & args){
}
void FboSource::onAppDraw(ofEventArgs & args){
if(fbo == NULL || !fbo->isAllocated()){
if(fbo == 0 || !fbo->isAllocated()){
ofLogWarning("FboSource") << "FBO not allocated";
return;
}
@ -92,10 +92,10 @@ void FboSource::allocate(int width, int height){
}
void FboSource::clear(){
texture = NULL;
if(fbo != NULL){
texture = 0;
if(fbo != 0){
delete fbo;
fbo = NULL;
fbo = 0;
}
}

4
src/Sources/ImageSource.cpp

@ -35,10 +35,10 @@ void ImageSource::loadImage(std::string & filePath){
}
void ImageSource::clear(){
texture = NULL;
texture = 0;
image->clear();
delete image;
image = NULL;
image = 0;
//path = "";
//name = "";
loaded = false;

12
src/Sources/VideoSource.cpp

@ -10,9 +10,9 @@ VideoSource::VideoSource(){
loaded = false;
type = SourceType::SOURCE_TYPE_VIDEO;
#ifdef TARGET_RASPBERRY_PI
omxPlayer = NULL;
omxPlayer = 0;
#else
videoPlayer = NULL;
videoPlayer = 0;
#endif
}
@ -44,24 +44,24 @@ void VideoSource::loadVideo(std::string & filePath){
}
void VideoSource::clear(){
texture = NULL;
texture = 0;
#ifdef TARGET_RASPBERRY_PI
omxPlayer->close();
delete omxPlayer;
omxPlayer = NULL;
omxPlayer = 0;
#else
ofRemoveListener(ofEvents().update, this, &VideoSource::update);
videoPlayer->stop();
videoPlayer->close();
delete videoPlayer;
videoPlayer = NULL;
videoPlayer = 0;
#endif
loaded = false;
}
#ifndef TARGET_RASPBERRY_PI
void VideoSource::update(ofEventArgs & args){
if(videoPlayer != NULL){
if(videoPlayer != 0){
videoPlayer->update();
}
}

4
src/Surfaces/BaseSurface.cpp

@ -11,7 +11,7 @@ BaseSurface::BaseSurface(){
BaseSurface::~BaseSurface(){
delete defaultSource;
defaultSource = NULL;
defaultSource = 0;
defaultTexture.clear();
}
@ -52,7 +52,7 @@ void BaseSurface::createDefaultTexture(){
}
void BaseSurface::drawTexture(ofVec2f position){
if(source->getTexture() == NULL){
if(source->getTexture() == 0){
ofLogWarning("BaseSurface") << "Source texture empty. Not drawing.";
return;
}

2
src/Surfaces/QuadSurface.cpp

@ -70,7 +70,7 @@ void QuadSurface::setup(ofVec2f p1, ofVec2f p2, ofVec2f p3, ofVec2f p4,
}
void QuadSurface::draw(){
if(source->getTexture() == NULL){
if(source->getTexture() == 0){
ofLogWarning("QuadSurface") << "Source texture empty. Not drawing.";
return;
}

22
src/Surfaces/SurfaceManager.cpp

@ -4,8 +4,8 @@ namespace ofx {
namespace piMapper {
SurfaceManager::SurfaceManager() :
mediaServer(NULL),
selectedSurface(NULL){}
mediaServer(0),
selectedSurface(0){}
SurfaceManager::~SurfaceManager(){
clear();
@ -127,7 +127,7 @@ void SurfaceManager::addSurface(BaseSurface * surface){
}
void SurfaceManager::removeSelectedSurface(){
if(selectedSurface == NULL){
if(selectedSurface == 0){
return;
}
for(int i = 0; i < surfaces.size(); i++){
@ -136,7 +136,7 @@ void SurfaceManager::removeSelectedSurface(){
// surface in the RemoveSurfaceCommand.
//delete surfaces[i];
surfaces.erase(surfaces.begin() + i);
selectedSurface = NULL;
selectedSurface = 0;
break;
}
}
@ -160,7 +160,7 @@ void SurfaceManager::clear(){
void SurfaceManager::saveXmlSettings(string fileName){
// Exit if mediaServer not set
if(mediaServer == NULL){
if(mediaServer == 0){
ofLogFatalError("SurfaceManager") << "Media server not set";
std::exit(EXIT_FAILURE);
}
@ -217,7 +217,7 @@ void SurfaceManager::saveXmlSettings(string fileName){
void SurfaceManager::loadXmlSettings(string fileName){
// Exit if there is no media server
if(mediaServer == NULL){
if(mediaServer == 0){
ofLogFatalError("SurfaceManager") << "Media server not set";
std::exit(EXIT_FAILURE);
}
@ -239,7 +239,7 @@ void SurfaceManager::loadXmlSettings(string fileName){
xmlSettings.pushTag("source");
string sourceType = xmlSettings.getValue("source-type", "");
string sourceName = xmlSettings.getValue("source-name", "");
BaseSource * source = NULL;
BaseSource * source = 0;
if(sourceName != "" && sourceName != "none" && sourceType != ""){
// Load source depending on type
int typeEnum = SourceType::GetSourceTypeEnum(sourceType);
@ -303,7 +303,7 @@ void SurfaceManager::loadXmlSettings(string fileName){
// now we have variables sourceName and sourceTexture
// by checking those we can use one or another addSurface method
if(sourceName != "none" && source != NULL){
if(sourceName != "none" && source != 0){
addSurface(SurfaceType::TRIANGLE_SURFACE, source, vertices,
texCoords);
}else{
@ -363,7 +363,7 @@ void SurfaceManager::loadXmlSettings(string fileName){
// now we have variables sourceName and sourceTexture
// by checking those we can use one or another addSurface method
if(sourceName != "none" && source != NULL){
if(sourceName != "none" && source != 0){
addSurface(SurfaceType::QUAD_SURFACE, source, vertices,
texCoords);
}else{
@ -409,13 +409,13 @@ BaseSurface * SurfaceManager::getSelectedSurface(){
}
void SurfaceManager::deselectSurface(){
selectedSurface = NULL;
selectedSurface = 0;
}
BaseSurface * SurfaceManager::getSurface(int index){
if(index >= surfaces.size()){
throw std::runtime_error("Surface index out of bounds.");
return NULL;
return 0;
}
return surfaces[index];

20
src/Surfaces/SurfaceManagerGui.cpp

@ -4,7 +4,7 @@ namespace ofx {
namespace piMapper {
SurfaceManagerGui::SurfaceManagerGui(){
surfaceManager = NULL;
surfaceManager = 0;
guiMode = GuiMode::NONE;
bDrag = false;
registerMouseEvents();
@ -14,7 +14,7 @@ SurfaceManagerGui::SurfaceManagerGui(){
SurfaceManagerGui::~SurfaceManagerGui(){
unregisterMouseEvents();
surfaceManager = NULL;
surfaceManager = 0;
_cmdManager = 0;
}
@ -37,7 +37,7 @@ void SurfaceManagerGui::unregisterMouseEvents(){
}
void SurfaceManagerGui::draw(){
if(surfaceManager == NULL){
if(surfaceManager == 0){
return;
}
@ -45,7 +45,7 @@ void SurfaceManagerGui::draw(){
surfaceManager->draw();
}else if(guiMode == GuiMode::TEXTURE_MAPPING){
// draw the texture of the selected surface
if(surfaceManager->getSelectedSurface() != NULL){
if(surfaceManager->getSelectedSurface() != 0){
// Reset default color to white first
ofSetColor(255, 255, 255, 255);
surfaceManager->getSelectedSurface()->drawTexture(ofVec2f(0, 0));
@ -94,7 +94,7 @@ void SurfaceManagerGui::mousePressed(ofMouseEventArgs & args){
bool bSurfaceSelected = false;
CircleJoint * hitJoint =
textureEditor.hitTestJoints(ofVec2f(args.x, args.y));
if(hitJoint != NULL){
if(hitJoint != 0){
textureEditor.unselectAllJoints();
hitJoint->select();
@ -117,7 +117,7 @@ void SurfaceManagerGui::mousePressed(ofMouseEventArgs & args){
textureEditor.unselectAllJoints();
}
if(surfaceManager->getSelectedSurface() != NULL && !bSurfaceSelected){
if(surfaceManager->getSelectedSurface() != 0 && !bSurfaceSelected){
// hittest texture area to see if we are hitting the texture surface
if(surfaceManager->getSelectedSurface()->getTextureHitArea().inside(
args.x, args.y)){
@ -138,7 +138,7 @@ void SurfaceManagerGui::mousePressed(ofMouseEventArgs & args){
CircleJoint * hitJoint =
projectionEditor.hitTestJoints(ofVec2f(args.x, args.y));
if(hitJoint != NULL){
if(hitJoint != 0){
projectionEditor.unselectAllJoints();
hitJoint->select();
hitJoint->startDrag();
@ -176,7 +176,7 @@ void SurfaceManagerGui::mousePressed(ofMouseEventArgs & args){
}
}
if(bSurfaceSelected && hitJoint == NULL){
if(bSurfaceSelected && hitJoint == 0){
// if not hitting the joints, start drag only if
// we have a selected surface
@ -287,7 +287,7 @@ int SurfaceManagerGui::getMode(){
}
void SurfaceManagerGui::drawSelectedSurfaceHighlight(){
if(surfaceManager->getSelectedSurface() == NULL){
if(surfaceManager->getSelectedSurface() == 0){
return;
}
ofPolyline line = surfaceManager->getSelectedSurface()->getHitArea();
@ -299,7 +299,7 @@ void SurfaceManagerGui::drawSelectedSurfaceHighlight(){
}
void SurfaceManagerGui::drawSelectedSurfaceTextureHighlight(){
if(surfaceManager->getSelectedSurface() == NULL){
if(surfaceManager->getSelectedSurface() == 0){
return;
}
ofPolyline line = surfaceManager->getSelectedSurface()->getTextureHitArea();

2
src/Surfaces/TriangleSurface.cpp

@ -43,7 +43,7 @@ void TriangleSurface::setup(ofVec2f p1, ofVec2f p2, ofVec2f p3, ofVec2f t1,
}
void TriangleSurface::draw(){
if(source->getTexture() == NULL){
if(source->getTexture() == 0){
ofLogWarning("TriangleSurface") << "Source texture is empty. Not drawing.";
return;
}

20
src/UserInterface/ProjectionEditor.cpp

@ -4,7 +4,7 @@ namespace ofx {
namespace piMapper {
ProjectionEditor::ProjectionEditor(){
surfaceManager = NULL;
surfaceManager = 0;
bShiftKeyDown = false;
fSnapDistance = 10.0f;
enable();
@ -12,7 +12,7 @@ ProjectionEditor::ProjectionEditor(){
ProjectionEditor::~ProjectionEditor(){
clearJoints();
surfaceManager = NULL;
surfaceManager = 0;
disable();
}
@ -63,7 +63,7 @@ void ProjectionEditor::update(ofEventArgs & args){
// update surface if one of the joints is being dragged
for(int i = 0; i < joints.size(); i++){
if(joints[i]->isDragged() || joints[i]->isSelected()){
if(surfaceManager->getSelectedSurface() != NULL){
if(surfaceManager->getSelectedSurface() != 0){
// update vertex to new location
surfaceManager->getSelectedSurface()->setVertex(i, joints[i]->position);
}else{
@ -78,10 +78,10 @@ void ProjectionEditor::update(ofEventArgs & args){
}
void ProjectionEditor::draw(){
if(surfaceManager == NULL){
if(surfaceManager == 0){
return;
}
if(surfaceManager->getSelectedSurface() == NULL){
if(surfaceManager->getSelectedSurface() == 0){
return;
}
if(joints.size() <= 0){
@ -185,12 +185,12 @@ void ProjectionEditor::clearJoints(){
}
void ProjectionEditor::createJoints(){
if(surfaceManager == NULL){
if(surfaceManager == 0){
return;
}
clearJoints();
if(surfaceManager->getSelectedSurface() == NULL){
if(surfaceManager->getSelectedSurface() == 0){
ofLog(OF_LOG_WARNING, "Trying to create joints while no surface selected.");
return;
}
@ -222,10 +222,10 @@ void ProjectionEditor::unselectAllJoints(){
}
void ProjectionEditor::moveSelectedSurface(ofVec2f by){
if(surfaceManager == NULL){
if(surfaceManager == 0){
return;
}
if(surfaceManager->getSelectedSurface() == NULL){
if(surfaceManager->getSelectedSurface() == 0){
return;
}
surfaceManager->getSelectedSurface()->moveBy(by);
@ -272,7 +272,7 @@ CircleJoint * ProjectionEditor::hitTestJoints(ofVec2f pos){
return joints[i];
}
}
return NULL;
return 0;
}
vector <CircleJoint *> * ProjectionEditor::getJoints(){

24
src/UserInterface/SourcesEditor.cpp

@ -13,7 +13,7 @@ SourcesEditor::SourcesEditor(){
}
void SourcesEditor::init(){
mediaServer = NULL; // Pointers to NULL pointer so we can check later
mediaServer = 0; // Pointers to 0 pointer so we can check later
isMediaServerExternal = false;
registerAppEvents();
}
@ -90,7 +90,7 @@ void SourcesEditor::setup(ofEventArgs & args){
void SourcesEditor::draw(){
// Don't draw if there is no source selected
if(surfaceManager->getSelectedSurface() == NULL){
if(surfaceManager->getSelectedSurface() == 0){
//ofLogNotice("SourcesEditor") << "No surface selected";
return;
}
@ -120,7 +120,7 @@ void SourcesEditor::disable(){
void SourcesEditor::enable(){
// Don't enable if there is no surface selected
if(surfaceManager->getSelectedSurface() == NULL){
if(surfaceManager->getSelectedSurface() == 0){
ofLogNotice("SourcesEditor") << "No surface selected. Not enabling and not showing source list.";
return;
}
@ -154,9 +154,9 @@ void SourcesEditor::setCmdManager(CmdManager * cmdManager){
void SourcesEditor::setMediaServer(MediaServer * newMediaServer){
// If the new media server is not valid
if(newMediaServer == NULL){
if(newMediaServer == 0){
// Log an error and return from the routine
ofLogFatalError("SourcesEditor") << "New media server is NULL";
ofLogFatalError("SourcesEditor") << "New media server is 0";
std::exit(EXIT_FAILURE);
}
// Attempt to clear existing media server and assign new one
@ -204,7 +204,7 @@ void SourcesEditor::selectSourceRadioButton(std::string & sourcePath){
void SourcesEditor::addMediaServerListeners(){
// Check if the media server is valid
if(mediaServer == NULL){
if(mediaServer == 0){
ofLogError("SourcesEditor::addMediaServerListeners", "Media server not set");
return;
}
@ -225,7 +225,7 @@ void SourcesEditor::addMediaServerListeners(){
void SourcesEditor::removeMediaServerListeners(){
// Check if the media server is valid
if(mediaServer == NULL){
if(mediaServer == 0){
ofLogError("SourcesEditor::addMediaServerListeners", "Media server not set");
return;
}
@ -255,7 +255,7 @@ void SourcesEditor::setImageSource(string & imagePath){
fboSelector->unselectAll();
BaseSurface * surface = surfaceManager->getSelectedSurface();
if(surface == NULL){
if(surface == 0){
ofLogWarning("SourcesEditor") << "No surface selected";
return;
}
@ -285,7 +285,7 @@ void SourcesEditor::setVideoSource(string & videoPath){
imageSelector->unselectAll();
BaseSurface * surface = surfaceManager->getSelectedSurface();
if(surface == NULL){
if(surface == 0){
ofLogWarning("SourcesEditor") << "No surface selected";
return;
}
@ -315,7 +315,7 @@ void SourcesEditor::setFboSource(string & fboName){
// Get selected surface
BaseSurface * surface = surfaceManager->getSelectedSurface();
if(surface == NULL){
if(surface == 0){
ofLogWarning("SourcesEditor") << "No surface selected";
return;
}
@ -352,9 +352,9 @@ void SourcesEditor::clearMediaServer(){
if(!isMediaServerExternal){
// Clear all loaded sources
mediaServer->clear();
// Destroy the pointer and set it to NULL pointer
// Destroy the pointer and set it to 0 pointer
delete mediaServer;
mediaServer = NULL;
mediaServer = 0;
}
}

12
src/UserInterface/TextureEditor.cpp

@ -43,7 +43,7 @@ void TextureEditor::disable(){
}
void TextureEditor::update(ofEventArgs & args){
if(surface == NULL){
if(surface == 0){
return;
}
@ -121,7 +121,7 @@ void TextureEditor::keyReleased(ofKeyEventArgs & args){
}
void TextureEditor::draw(){
if(surface == NULL){
if(surface == 0){
return;
}
@ -142,12 +142,12 @@ void TextureEditor::setSurface(BaseSurface * newSurface){
}
void TextureEditor::clear(){
surface = NULL;
surface = 0;
clearJoints();
}
void TextureEditor::createJoints(){
if(surface == NULL){
if(surface == 0){
return;
}
clearJoints();
@ -175,7 +175,7 @@ void TextureEditor::unselectAllJoints(){
}
void TextureEditor::moveTexCoords(ofVec2f by){
if(surface == NULL){
if(surface == 0){
return;
}
vector <ofVec2f> & texCoords = surface->getTexCoords();
@ -246,7 +246,7 @@ CircleJoint * TextureEditor::hitTestJoints(ofVec2f pos){
return joints[i];
}
}
return NULL;
return 0;
}
vector <CircleJoint *> & TextureEditor::getJoints(){

Loading…
Cancel
Save