[GME-commit] GMESRC/GME/XmlBackEnd CoreXmlFile.cpp,1.5,1.6 CoreXmlFile.h,1.4,1.5

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Tue Nov 2 09:28:37 CST 2004


Update of /var/lib/gme/GMESRC/GME/XmlBackEnd
In directory braindrain:/tmp/cvs-serv22114

Modified Files:
	CoreXmlFile.cpp CoreXmlFile.h 
Log Message:
no message

CVS User: bogyom

Index: CoreXmlFile.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/XmlBackEnd/CoreXmlFile.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** CoreXmlFile.cpp	29 Oct 2004 17:27:47 -0000	1.5
--- CoreXmlFile.cpp	2 Nov 2004 15:28:34 -0000	1.6
***************
*** 707,714 ****
--- 707,723 ----
      }
  
+     /*if( m_metaAttributeId == ATTRID_MGAVERSION )
+     {
+         long gmepointer;
+         CopyTo(p, gmepointer);
+         m_gme = (IGMEOLEApp*)gmepointer;        
+         return S_OK;
+     }*/
+ 
      // ignore UpdateSourceControlInfo regnode
      if( m_openedObject->m_sourceControlInfoRegNode && m_metaAttributeId == ATTRID_REGNODEVALUE)
          return S_OK;
  
+     
      // TODO: return with specific error code
      //if( m_openedObject->m_readOnly )
***************
*** 786,792 ****
  		COMRETURN(E_INVALID_USAGE);
  	   
-     if( m_openedObject == (XmlObject*)objid )
- 		return S_OK;
- 
      metaobjidpair_type idpair;
  	idpair.metaid = m_metaObjectId;
--- 795,798 ----
***************
*** 796,799 ****
--- 802,808 ----
  	{
          m_openedObject = objectFromObjId(idpair);
+ 
+         if( m_openedObject->m_deleted )
+             m_openedObject = NULL;
  	}
  	COMCATCH(;)
***************
*** 843,847 ****
  		COMRETURN(E_INVALID_USAGE);
  
!     m_openedObject->m_deleted = true;   
      m_deletedObjects.insert( m_openedObject );
  
--- 852,856 ----
  		COMRETURN(E_INVALID_USAGE);
  
!     m_openedObject->m_deleted = true;
      m_deletedObjects.insert( m_openedObject );
  
***************
*** 875,879 ****
              getLatestVersion();        
  
!         readAll( true );
          //writeBinaryCache();
      }
--- 884,888 ----
              getLatestVersion();        
  
!         readAll( true );        
          //writeBinaryCache();
      }
***************
*** 1011,1014 ****
--- 1020,1025 ----
      CloseObject();
  
+     //m_needClose = false;
+ 
      if( !checkOutFiles(checkOutContainers) )
      {
***************
*** 1022,1026 ****
          m_undoMap.clear();
          m_inTransaction = false;
! 	    return S_OK;
      }
  }
--- 1033,1042 ----
          m_undoMap.clear();
          m_inTransaction = false;
! 
! 
!         //if( m_needClose )
!           //  m_gme->CloseProject( TRUE );
! 
!         return S_OK;
      }
  }
***************
*** 1717,1722 ****
      if( AfxMessageBox( "To perform this operation some files will be checked out. Do you want to continue?", MB_YESNO ) == IDYES )
      {
!         // TODO: get latest version
  
  
          // check out files
--- 1733,1745 ----
      if( AfxMessageBox( "To perform this operation some files will be checked out. Do you want to continue?", MB_YESNO ) == IDYES )
      {
!         getLatestVersion();
  
+         bool needClose = filesModifedByOthers();
+ 
+         if( needClose )
+         {
+             AfxMessageBox( "Part of the project has been modified by other users, it is highly recomended to close and reopen your project to synchronize it!");
+             return false;
+         }
  
          // check out files
***************
*** 1734,1745 ****
              return false;
          }
! 
!         // TODO: itt trukkozni kell!
!         // ha uj kapcsolatok vannak, akkor le kell venni egyeb dolgokat is
!         // primitiv megoldas: getlatest aztan readall
!         // a fellettunk levo undo buffer ilyenkor bedoglik, valahogy uriteni kell
! 
!         //readAll();
!         
  
          return true;
--- 1757,1761 ----
              return false;
          }
!                                
  
          return true;
***************
*** 2037,2040 ****
--- 2053,2059 ----
      getContainerFileName(container, fileName);
  
+     time_t        currentTime1 = time( &currentTime1 );
+     CTime         currentTime2( currentTime1 + 1 );
+ 
      // open file
      FILE * file = fopen( fileName.c_str(), "w" );
***************
*** 2042,2046 ****
      {
          // write objects recursively
!         writeObject( container, file, true, "" );
      
          fclose(file);
--- 2061,2065 ----
      {
          // write objects recursively
!         writeObject( container, file, true, "", currentTime2 );
      
          fclose(file);
***************
*** 2062,2066 ****
  }
  
! void CCoreXmlFile::writeObject(XmlObject * obj, FILE * file, bool container, const char * prefix)
  {        
      std::string                     str;
--- 2081,2085 ----
  }
  
! void CCoreXmlFile::writeObject(XmlObject * obj, FILE * file, bool container, const char * prefix, CTime lastWriteTime )
  {        
      std::string                     str;
***************
*** 2071,2074 ****
--- 2090,2095 ----
          return;
  
+     obj->m_lastWriteTime = lastWriteTime;
+ 
      COMTHROW( m_metaProject->get_Object( obj->m_metaid, PutOut(metaobject) ) );
      COMTHROW( metaobject->get_Token( &metaToken ) );
***************
*** 2142,2146 ****
                      ASSERT( it3 != m_parentMap.end() );
                      if( it3->second + ATTRID_COLLECTION == it->first )
!                         writeObject( obj2, file, false, newPrefix.c_str() );
                  }
              }
--- 2163,2167 ----
                      ASSERT( it3 != m_parentMap.end() );
                      if( it3->second + ATTRID_COLLECTION == it->first )
!                         writeObject( obj2, file, false, newPrefix.c_str(), lastWriteTime );
                  }
              }
***************
*** 2208,2213 ****
          ASSERT( parser != NULL );
  
          DOMDocument * doc = parser->parseURI( fileName );  
!         readObject( doc->getDocumentElement(), pointers, NULL, fullLoad );
  
          delete parser;
--- 2229,2239 ----
          ASSERT( parser != NULL );
  
+         // get last write time
+         WIN32_FILE_ATTRIBUTE_DATA attr;        
+         GetFileAttributesEx( fileName, GetFileExInfoStandard, &attr );
+         CTime lastWriteTime( attr.ftLastWriteTime );
+ 
          DOMDocument * doc = parser->parseURI( fileName );  
!         readObject( doc->getDocumentElement(), pointers, NULL, fullLoad, lastWriteTime );
  
          delete parser;
***************
*** 2222,2226 ****
  }
  
! void CCoreXmlFile::readObject(DOMElement * e, UnresolvedPointerVec& pointers, XmlObject * parent, bool fullLoad )
  {   
      // if the object is deleted do not deal with it
--- 2248,2252 ----
  }
  
! void CCoreXmlFile::readObject(DOMElement * e, UnresolvedPointerVec& pointers, XmlObject * parent, bool fullLoad, CTime lastWriteTime )
  {   
      // if the object is deleted do not deal with it
***************
*** 2265,2268 ****
--- 2291,2297 ----
              m_root = obj;
      }
+ 
+     obj->m_deleted = false;
+     obj->m_lastWriteTime = lastWriteTime;
      
      // read attributes
***************
*** 2317,2321 ****
          DOMNode * node = children->item(i);
          if( node->getNodeType() == DOMNode::ELEMENT_NODE )        
!             readObject( (DOMElement*)node, pointers, obj, fullLoad );
      }
  }
--- 2346,2350 ----
          DOMNode * node = children->item(i);
          if( node->getNodeType() == DOMNode::ELEMENT_NODE )        
!             readObject( (DOMElement*)node, pointers, obj, fullLoad, lastWriteTime );
      }
  }
***************
*** 2329,2333 ****
      // todo: preconditions
  
!     clearAll();
  
      sprintf( buf, "%s\\*.xml", m_folderPath.c_str() );
--- 2358,2362 ----
      // todo: preconditions
  
!     //clearAll();
  
      sprintf( buf, "%s\\*.xml", m_folderPath.c_str() );
***************
*** 2356,2360 ****
      _finddata_t   fileInfo;
      time_t        currentTime1 = time( &currentTime1 );
!     CTime         currentTime2( currentTime1 );
  
      // get latest version from source control
--- 2385,2389 ----
      _finddata_t   fileInfo;
      time_t        currentTime1 = time( &currentTime1 );
!     CTime         currentTime2( currentTime1 - 100 );
  
      // get latest version from source control
***************
*** 3048,3051 ****
--- 3077,3083 ----
      }
      //dumpSourceControlInfo();
+ 
+     //if( m_gme.p != NULL )
+       //  m_gme->CloseProject( TRUE );
  }
  
***************
*** 3068,3071 ****
--- 3100,3125 ----
  
      fclose(f);
+ }
+ 
+ bool CCoreXmlFile::filesModifedByOthers()
+ {
+     for( XmlObjVecIter it=m_objects.begin(); it!=m_objects.end(); ++it )
+     {   
+         XmlObject * obj = (*it);
+         if( obj->isContainer() )
+         {
+             string filename;
+             getContainerFileName(obj, filename);
+ 
+             // get last write time
+             WIN32_FILE_ATTRIBUTE_DATA attr;        
+             GetFileAttributesEx( filename.c_str(), GetFileExInfoStandard, &attr );
+             CTime lastWriteTime( attr.ftLastWriteTime );
+ 
+             if( lastWriteTime > obj->m_lastWriteTime )
+                 return true;           
+         }
+     }
+     return false;
  }
  

Index: CoreXmlFile.h
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/XmlBackEnd/CoreXmlFile.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** CoreXmlFile.h	29 Oct 2004 15:50:51 -0000	1.4
--- CoreXmlFile.h	2 Nov 2004 15:28:34 -0000	1.5
***************
*** 226,229 ****
--- 226,230 ----
      bool               m_modified;
      bool               m_sourceControlInfoRegNode;  
+     CTime              m_lastWriteTime;
  
      friend class CCoreXmlFile;
***************
*** 394,398 ****
      void         writeXMLFile           (XmlObject * container);
  
!     void         writeObject            (XmlObject * obj, FILE * file, bool container, const char * prefix);
  
      bool         moveContainerToDisk    (XmlObject * container);
--- 395,399 ----
      void         writeXMLFile           (XmlObject * container);
  
!     void         writeObject            (XmlObject * obj, FILE * file, bool container, const char * prefix, CTime lastWriteTime );
  
      bool         moveContainerToDisk    (XmlObject * container);
***************
*** 403,407 ****
  
      void         readObject             (XERCES_CPP_NAMESPACE::DOMElement * e, UnresolvedPointerVec& pointers, 
!                                          XmlObject * parent, bool fullLoad );
  
      void         readAll                ( bool fullLoad );
--- 404,408 ----
  
      void         readObject             (XERCES_CPP_NAMESPACE::DOMElement * e, UnresolvedPointerVec& pointers, 
!                                          XmlObject * parent, bool fullLoad, CTime lastWriteTime );
  
      void         readAll                ( bool fullLoad );
***************
*** 463,466 ****
--- 464,469 ----
  
      void         dumpSourceControlInfo  ();
+ 
+     bool         filesModifedByOthers   ();
  
  protected:



More information about the GME-commit mailing list