[opengtl-commits] [610] move the function to read from file from Library to Source

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 610
Author:   cyrille
Date:     2009-03-13 21:37:12 +0100 (Fri, 13 Mar 2009)

Log Message:
-----------
move the function to read from file from Library to Source

Modified Paths:
--------------
    trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/Source.cpp
    trunk/OpenGTL/OpenShiva/OpenShiva/Source.h


Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp	2009-03-13 18:44:07 UTC (rev 609)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Library.cpp	2009-03-13 20:37:12 UTC (rev 610)
@@ -21,7 +21,6 @@
 #include "Library_p.h"
 
 #include <sstream>
-#include <fstream>
 
 #include <llvm/Module.h>
 #include <llvm/ModuleProvider.h>
@@ -126,6 +125,7 @@
 void Library::setSource(const Source& source)
 {
     d->source = source;
+    d->initparameters();
 }
 
 const Source& Library::source() const
@@ -136,22 +136,7 @@
 void Library::loadFromFile(const GTLCore::String& _fileName)
 {
   d->isStandardLibrary = _fileName.endWith( "shivastdlib.shiva" );
-  GTLCore::String source = "";
-  std::ifstream in;
-  in.open(_fileName.c_str() );
-  if(not in)
-  {
-    SHIVA_DEBUG( "Impossible to open file " << _fileName );
-    return;
-  }
-  GTLCore::String str;
-  std::getline(in,str);
-  while ( in ) {
-    source += str;
-    source += "\n";
-    std::getline(in,str);
-  }
-  d->source.setSource(source);
+  d->source.loadFromFile(_fileName);
   d->initparameters();
 }
 

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Source.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Source.cpp	2009-03-13 18:44:07 UTC (rev 609)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Source.cpp	2009-03-13 20:37:12 UTC (rev 610)
@@ -21,6 +21,8 @@
 
 using namespace OpenShiva;
 
+#include <fstream>
+
 #include <GTLCore/String.h>
 
 #include "Debug.h"
@@ -140,6 +142,26 @@
   d->source = _source;
 }
 
+void Source::loadFromFile(const GTLCore::String& _fileName)
+{
+  GTLCore::String source = "";
+  std::ifstream in;
+  in.open(_fileName.c_str() );
+  if(not in)
+  {
+    SHIVA_DEBUG( "Impossible to open file " << _fileName );
+    return;
+  }
+  GTLCore::String str;
+  std::getline(in,str);
+  while ( in ) {
+    source += str;
+    source += "\n";
+    std::getline(in,str);
+  }
+  setSource(source);
+}
+
 const Metadata* Source::metadata() const
 {
   if(not d->metadata and not d->metadataCompilationFailed)

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Source.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Source.h	2009-03-13 18:44:07 UTC (rev 609)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Source.h	2009-03-13 20:37:12 UTC (rev 610)
@@ -44,6 +44,7 @@
       const GTLCore::String& name() const;
       const GTLCore::String& source() const;
       void setSource( const GTLCore::String& );
+      void loadFromFile(const GTLCore::String& _fileName);
       /**
        * @return the metadata for this kernel.
        */


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/