glc_rep.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the GLC-lib library.
00004  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00005  http://glc-lib.sourceforge.net
00006 
00007  GLC-lib is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU Lesser General Public License as published by
00009  the Free Software Foundation; either version 3 of the License, or
00010  (at your option) any later version.
00011 
00012  GLC-lib is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU Lesser General Public License for more details.
00016 
00017  You should have received a copy of the GNU Lesser General Public License
00018  along with GLC-lib; if not, write to the Free Software
00019  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021  *****************************************************************************/
00022 
00023 #include "glc_rep.h"
00024 #include "QtDebug"
00025 
00026 // Default constructor
00027 GLC_Rep::GLC_Rep()
00028 : m_pIsLoaded(new bool(false))
00029 , m_pNumberOfRepresentation(new int(1))
00030 , m_pFileName(new QString())
00031 , m_pName(new QString())
00032 , m_pDateTime(new QDateTime)
00033 {
00034 
00035 }
00036 
00037 // Copy Constructor
00038 GLC_Rep::GLC_Rep(const GLC_Rep& rep)
00039 : m_pIsLoaded(rep.m_pIsLoaded)
00040 , m_pNumberOfRepresentation(rep.m_pNumberOfRepresentation)
00041 , m_pFileName(rep.m_pFileName)
00042 , m_pName(rep.m_pName)
00043 , m_pDateTime(rep.m_pDateTime)
00044 {
00045         ++(*m_pNumberOfRepresentation);
00046 }
00047 
00048 // Assignement operator
00049 GLC_Rep& GLC_Rep::operator=(const GLC_Rep& rep)
00050 {
00051         if (this != &rep)
00052         {
00053                 // Clear this representation
00054                 clear();
00055                 m_pIsLoaded= rep.m_pIsLoaded;
00056                 m_pNumberOfRepresentation= rep.m_pNumberOfRepresentation;
00057                 ++(*m_pNumberOfRepresentation);
00058                 m_pFileName= rep.m_pFileName;
00059                 m_pName= rep.m_pName;
00060                 m_pDateTime= rep.m_pDateTime;
00061         }
00062 
00063         return *this;
00064 }
00065 
00066 // Destructor
00067 GLC_Rep::~GLC_Rep()
00068 {
00069         // Clear this representation
00070         clear();
00071 }
00072 
00073 
00075 // private services functions
00077 // Clear current representation
00078 void GLC_Rep::clear()
00079 {
00080         Q_ASSERT(NULL != m_pNumberOfRepresentation);
00081         if ((--(*m_pNumberOfRepresentation)) == 0)
00082         {
00083                 delete m_pIsLoaded;
00084                 m_pIsLoaded= NULL;
00085                 delete m_pNumberOfRepresentation;
00086                 m_pNumberOfRepresentation= NULL;
00087                 delete m_pFileName;
00088                 m_pFileName= NULL;
00089                 delete m_pName;
00090                 m_pName= NULL;
00091                 delete m_pDateTime;
00092                 m_pDateTime= NULL;
00093         }
00094 }

SourceForge.net Logo

©2005-2011 Laurent Ribon