]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
bos #16517 Implement method CanOpen() to check that study file is accessible and...
authorvsr <vsr@opencascade.com>
Mon, 30 Dec 2019 09:01:33 +0000 (12:01 +0300)
committervsr <vsr@opencascade.com>
Mon, 30 Dec 2019 09:01:33 +0000 (12:01 +0300)
idl/SALOMEDS.idl
src/SALOMEDS/SALOMEDS_Study.cxx
src/SALOMEDS/SALOMEDS_Study.hxx
src/SALOMEDS/SALOMEDS_Study_i.cxx
src/SALOMEDS/SALOMEDS_Study_i.hxx
src/SALOMEDSClient/SALOMEDSClient_Study.hxx

index 5ddf9b081bbf64f880e65533fea0ea023f403514..9488ca344139a9caca4e0bb08e26aa07864f81e8 100644 (file)
@@ -574,6 +574,13 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin
 */
     boolean Open (in URLPath aStudyUrl) raises (SALOME::SALOME_Exception);
 
+/*! \brief Check if study can be opened
+
+    Tries to open and read given url.
+    \param aStudyUrl The path to the study
+*/
+    boolean CanOpen (in URLPath aStudyUrl);
+
 /*! \brief Saving the study in a file (or files).
 
     Saves a study.
index 2a14971d7f632ed0283c3130f02e220456d8bd80..8f12cf461644cc7b204557fbaeac83371e1b6759 100644 (file)
@@ -132,10 +132,16 @@ bool SALOMEDS_Study::Open(const std::string& theStudyUrl)
     return false;
   std::wstring wtheStudyUrl = Kernel_Utils::decode_s( theStudyUrl );
   
-  if (!_corba_impl->Open( (wchar_t*)wtheStudyUrl.c_str() ) )
-    return false;
+  return _corba_impl->Open( (wchar_t*)wtheStudyUrl.c_str() );
+}
 
-  return true;
+bool SALOMEDS_Study::CanOpen(const std::string& theStudyUrl)
+{
+  if(CORBA::is_nil(_corba_impl))
+    return false;
+  std::wstring wtheStudyUrl = Kernel_Utils::decode_s( theStudyUrl );
+  
+  return _corba_impl->CanOpen( (wchar_t*)wtheStudyUrl.c_str() );
 }
 
 bool SALOMEDS_Study::Save(bool theMultiFile, bool theASCII)
index c6dc5848695a943b27687e372730373d2ea15244..3f8de21eb5f1b0e21a5e3bc907ccbd0b30e730d7 100644 (file)
@@ -56,6 +56,7 @@ public:
   virtual void Init();
 
   virtual bool Open(const std::string& theStudyUrl);
+  virtual bool CanOpen(const std::string& theStudyUrl);
 
   virtual bool Save(bool theMultiFile, bool theASCII);
   virtual bool SaveAs(const std::string& theUrl, bool theMultiFile, bool theASCII);
index e5a26a9fb7581b4b25f0f389c56d7ce00cefa741..b7f8654d3273605a75d93610869a443a30d20f2e 100644 (file)
@@ -413,6 +413,21 @@ bool SALOMEDS_Study_i::Open(const wchar_t* aWUrl)
   return res;
 }
 
+//============================================================================
+/*! Function : CanOpen
+ *  Purpose  : Check that a Study can be opened
+ */
+//============================================================================
+bool SALOMEDS_Study_i::CanOpen(const wchar_t* aWUrl)
+{
+  SALOMEDS::Locker lock;
+
+  Unexpect aCatch(SalomeException);
+  std::string aUrl = Kernel_Utils::encode_s(aWUrl);
+
+  return SALOMEDSImpl_Study().Open( aUrl );
+}
+
 PortableServer::POA_ptr SALOMEDS_Study_i::GetThePOA()
 {
   return _poa;
index f16e029a74045ed854abc68e071ecde335c3f38a..ad39fde89a57a7a310bc9ac5f36a6f1bae9d497a 100644 (file)
@@ -74,13 +74,20 @@ public:
   virtual void Init();
   virtual void Clear();
 
-  //! method to Open a Study
+  //! method to open a Study
   /*!
     \param char* arguments, the study URL
-    \return Study_ptr arguments
+    \return bool arguments
   */
   virtual bool Open(const wchar_t* aStudyUrl) throw (SALOME::SALOME_Exception);
 
+  //! method to check that a Study can be opened
+  /*!
+    \param char* arguments, the study URL
+    \return bool arguments
+  */
+  virtual bool CanOpen(const wchar_t* aStudyUrl);
+
   //! method to save a Study
   virtual CORBA::Boolean Save(CORBA::Boolean theMultiFile, CORBA::Boolean theASCII);
 
index 7a9c7ba4cbcf18fb72e42d08c6523f53d6d0718c..e696d66eb38910f5e5fa0108294c0b180a0c24da 100644 (file)
@@ -53,6 +53,7 @@ public:
   virtual void Clear() = 0;
 
   virtual bool Open(const std::string& theStudyUrl) = 0;
+  virtual bool CanOpen(const std::string& theStudyUrl) = 0;
 
   virtual std::string GetPersistentReference() = 0;
   virtual bool IsEmpty() = 0;