From 474e6d1f15a2409669873ea2ed05dc80c1ba47b3 Mon Sep 17 00:00:00 2001
From: wfg <wfg@pc0098504.ornl.gov>
Date: Wed, 11 Jan 2017 18:06:13 -0500
Subject: [PATCH] Renamed SingleBP to Writer

Run and tested helloWriter under examples/hello/writer
Fixed Makefile
---
 examples/hello/dataman/helloDataMan.cpp       |  9 ++-
 examples/hello/{singleBP => writer}/Makefile  |  6 +-
 .../helloWriter.cpp}                          | 12 ++--
 .../helloWriter_OOP.cpp}                      | 12 ++--
 include/ADIOS.h                               | 10 +--
 include/ADIOS_OOP.h                           |  2 +-
 include/core/Method.h                         |  4 +-
 include/engine/{SingleBP.h => Writer.h}       | 17 ++---
 src/ADIOS.cpp                                 |  6 +-
 src/core/Method.cpp                           |  6 +-
 src/engine/{SingleBP.cpp => Writer.cpp}       | 72 +++++++++----------
 11 files changed, 74 insertions(+), 82 deletions(-)
 rename examples/hello/{singleBP => writer}/Makefile (86%)
 rename examples/hello/{singleBP/helloSingleBP.cpp => writer/helloWriter.cpp} (84%)
 rename examples/hello/{singleBP/helloSingleBP_OOP.cpp => writer/helloWriter_OOP.cpp} (83%)
 rename include/engine/{SingleBP.h => Writer.h} (88%)
 rename src/engine/{SingleBP.cpp => Writer.cpp} (62%)

diff --git a/examples/hello/dataman/helloDataMan.cpp b/examples/hello/dataman/helloDataMan.cpp
index 43991600c..33db0b1c1 100644
--- a/examples/hello/dataman/helloDataMan.cpp
+++ b/examples/hello/dataman/helloDataMan.cpp
@@ -42,8 +42,8 @@ int main( int argc, char* argv [] )
         adios.DefineVariable( groupName, "myInts", "double", "myIntsSize" );
 
         //Define method
-        const std::string methodName( "singleBP" );
-        adios.DeclareMethod( methodName, "singleBP" );
+        const std::string methodName( "DataManSend" );
+        adios.DeclareMethod( methodName, "DataMan" );
         adios.AddCapsule( methodName, "Heap" );
         adios.AddTransport( methodName, "POSIX", "fname=myfile.bp" );
         adios.AddTransport( methodName, "TCP_IP", "fname=myfile.tcp" );
@@ -53,9 +53,8 @@ int main( int argc, char* argv [] )
         adios.SetDefaultGroup( handler, groupName );
 
         double varDouble = 10.;
-        adios.Write( handler, "myIntsSize", &varDouble );
-        adios.Write( handler, "myInts", &myInts.front() );
-        adios.Write( 10, "myInts", &myInts.front() );
+        adios.Write<double>( handler, "myIntsSize", &varDouble );
+        adios.Write<double>( handler, "myInts", &myInts.front() );
         adios.Close( handler );
     }
     catch( std::invalid_argument& e )
diff --git a/examples/hello/singleBP/Makefile b/examples/hello/writer/Makefile
similarity index 86%
rename from examples/hello/singleBP/Makefile
rename to examples/hello/writer/Makefile
index 96edd8f1d..5b5d6ae4d 100644
--- a/examples/hello/singleBP/Makefile
+++ b/examples/hello/writer/Makefile
@@ -3,7 +3,7 @@
 #     Author: wfg
 
 
-BASE_NAME=helloSingleBP_OOP
+BASE_NAME=helloWriter_OOP
      
 TOOL_DIR=/usr/bin
 
@@ -25,10 +25,10 @@ CFLAGS=-Wall -O0 -g -Wpedantic -std=c++11
 all: mpi
 
 mpi: $(ADIOS_LIB) $(ADIOS_HFiles)
-	$(MPICC) $(CFLAGS) $(ADIOS_INCLUDE) -DHAVE_MPI $(BASE_NAME).cpp -o $(BASE_NAME)_mpi $(ADIOS_LIB)
+	$(MPICC) $(CFLAGS) $(ADIOS_INCLUDE) -DHAVE_MPI $(BASE_NAME).cpp -o $(BASE_NAME)_mpi $(ADIOS_LIB) -lpthread
 	
 nompi: $(ADIOS_NOMPI_LIB) $(NoMPI_HFiles)
-	$(CC) $(CFLAGS) $(ADIOS_INCLUDE) $(BASE_NAME).cpp -o $(BASE_NAME)_nompi $(ADIOS_NOMPI_LIB)
+	$(CC) $(CFLAGS) $(ADIOS_INCLUDE) $(BASE_NAME).cpp -o $(BASE_NAME)_nompi $(ADIOS_NOMPI_LIB) -lpthread
 
 clean:
 	rm *_mpi; rm *_nompi
diff --git a/examples/hello/singleBP/helloSingleBP.cpp b/examples/hello/writer/helloWriter.cpp
similarity index 84%
rename from examples/hello/singleBP/helloSingleBP.cpp
rename to examples/hello/writer/helloWriter.cpp
index 35815996a..e1467d60f 100644
--- a/examples/hello/singleBP/helloSingleBP.cpp
+++ b/examples/hello/writer/helloWriter.cpp
@@ -42,16 +42,16 @@ int main( int argc, char* argv [] )
         adios.DefineVariable( groupName, "myInts", "double", "myIntsSize" );
 
         //Define method
-        const std::string methodName( "singleBP" );
-        adios.DeclareMethod( methodName, "singleBP" );
-        adios.AddCapsule( methodName, "buffer=Heap" );
-        adios.AddTransport( methodName, "transport=POSIX" );
+        const std::string methodName( "IntsWriter" );
+        adios.DeclareMethod( methodName, "Writer" );
+        adios.AddCapsule( methodName, "Heap" );
+        adios.AddTransport( methodName, "POSIX" );
 
         //Create engine handler and Write
         int handler = adios.Open( "myInts.bp", "w", methodName );
         adios.SetDefaultGroup( handler, groupName );
-        adios.Write( handler, "myIntsSize", &myIntsSize );
-        adios.Write( handler, "myInts", &myInts.front() );
+        adios.Write<int>( handler, "myIntsSize", &myIntsSize );
+        adios.Write<double>( handler, "myInts", &myInts.front() );
         adios.Close( handler );
     }
     catch( std::invalid_argument& e )
diff --git a/examples/hello/singleBP/helloSingleBP_OOP.cpp b/examples/hello/writer/helloWriter_OOP.cpp
similarity index 83%
rename from examples/hello/singleBP/helloSingleBP_OOP.cpp
rename to examples/hello/writer/helloWriter_OOP.cpp
index 5a77e93eb..36bfd1b49 100644
--- a/examples/hello/singleBP/helloSingleBP_OOP.cpp
+++ b/examples/hello/writer/helloWriter_OOP.cpp
@@ -40,16 +40,16 @@ int main( int argc, char* argv [] )
         group.DefineVariable( "myInts",     "double", "myIntsSize" ); //define variable with associate size
 
         //Define method
-        adios::Method method; //( "SingleBP", adiosDebug );
+        adios::Method method( "Writer");
         method.AddCapsule( "Heap" );
         method.AddTransport( "POSIX", "have_metadata_file=0" );
 
         //Create engine and Write
-        adios::engine::SingleBP singleBP( "myInts.bp", "w", MPI_COMM_WORLD, method, adiosDebug );
-        singleBP.SetDefaultGroup( group );
-        singleBP.Write( "myIntsSize", &myIntsSize  );
-        singleBP.Write( "myInts", &myInts.front() );
-        singleBP.Close( );
+        adios::Writer writer( "myInts.bp", "w", MPI_COMM_WORLD, method, adiosDebug );
+        writer.SetDefaultGroup( group );
+        writer.Write( "myIntsSize", &myIntsSize  );
+        writer.Write( "myInts", &myInts.front() );
+        writer.Close( );
     }
     catch( std::invalid_argument& e )
     {
diff --git a/include/ADIOS.h b/include/ADIOS.h
index 60a5247e1..918932963 100644
--- a/include/ADIOS.h
+++ b/include/ADIOS.h
@@ -129,7 +129,7 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO
      * @param name
      * @param type
      */
-    void DeclareMethod( const std::string methodName, const std::string type = "SingleBP" );
+    void DeclareMethod( const std::string methodName, const std::string type );
 
     /**
      * Add a capsule type to method name defined from DeclareMethod
@@ -137,13 +137,13 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO
      * @param args variadic parameters with format parameter=value
      */
     template< class ...Args>
-    void AddCapsule( const std::string methodName, const Args... args )
+    void AddCapsule( const std::string methodName, const std::string type, const Args... args )
     {
         auto itMethod = m_Methods.find( methodName );
         if( m_DebugMode == true )
             CheckMethod( itMethod, methodName, " from call to AddBuffer\n" );
 
-        itMethod->second.AddCapsule( args... );
+        itMethod->second.AddCapsule( type, args... );
     }
 
     /**
@@ -152,13 +152,13 @@ public: // PUBLIC Constructors and Functions define the User Interface with ADIO
      * @param args variadic parameters with format parameter=value
      */
     template< class ...Args>
-    void AddTransport( const std::string methodName, const Args... args )
+    void AddTransport( const std::string methodName, const std::string type, const Args... args )
     {
         auto itMethod = m_Methods.find( methodName );
         if( m_DebugMode == true )
             CheckMethod( itMethod, methodName, " from call to AddTransport\n" );
 
-        itMethod->second.AddTransport( args... );
+        itMethod->second.AddTransport( type, args... );
     }
 
     /**
diff --git a/include/ADIOS_OOP.h b/include/ADIOS_OOP.h
index 988e327de..a9321d3a4 100644
--- a/include/ADIOS_OOP.h
+++ b/include/ADIOS_OOP.h
@@ -11,9 +11,9 @@
 
 #include "core/Group.h"
 #include "core/Method.h"
+#include "engine/Writer.h"
 
 //TRANSFORMS
-#include "engine/SingleBP.h"
 #include "transform/BZip2.h"
 
 
diff --git a/include/core/Method.h b/include/core/Method.h
index 1c871a8da..ebb0196f6 100644
--- a/include/core/Method.h
+++ b/include/core/Method.h
@@ -26,7 +26,7 @@ class Method
 
 public:
 
-    const std::string m_Type = "SingleBP"; ///< Method type
+    const std::string m_Type; ///< Method type
     const bool m_DebugMode = false; ///< true: on, throws exceptions and do additional checks, false: off, faster, but unsafe
     std::vector< std::map<std::string, std::string> > m_CapsuleParameters; ///< each is a separate Transport containing their own parameters
     std::vector< std::map<std::string, std::string> > m_TransportParameters; ///< each is a separate Transport containing their own parameters
@@ -35,7 +35,7 @@ public:
      * Unique constructor, must have a type
      * @param type must be an engine type, default = SingleBP
      */
-    Method( const std::string type = "", const bool debugMode = false );
+    Method( const std::string type, const bool debugMode = false );
 
     ~Method( );
 
diff --git a/include/engine/SingleBP.h b/include/engine/Writer.h
similarity index 88%
rename from include/engine/SingleBP.h
rename to include/engine/Writer.h
index 346978149..fa822bd35 100644
--- a/include/engine/SingleBP.h
+++ b/include/engine/Writer.h
@@ -5,35 +5,33 @@
  *      Author: wfg
  */
 
-#ifndef SINGLEBP_H_
-#define SINGLEBP_H_
+#ifndef WRITER_H_
+#define WRITER_H_
 
 #include "core/Engine.h"
 
 
 namespace adios
 {
-namespace engine
-{
 
 
-class SingleBP : public Engine
+class Writer : public Engine
 {
 
 public:
 
     /**
-     * Constructor for single BP capsule engine, writes in BP format into a single heap capsule
+     * Constructor for Writer writes in BP format into a single heap capsule, manages several transports
      * @param name unique name given to the engine
      * @param accessMode
      * @param mpiComm
      * @param method
      * @param debugMode
      */
-    SingleBP( const std::string name, const std::string accessMode, MPI_Comm mpiComm,
+    Writer( const std::string name, const std::string accessMode, MPI_Comm mpiComm,
               const Method& method, const bool debugMode = false, const unsigned int cores = 1 );
 
-    ~SingleBP( );
+    ~Writer( );
 
     void Write( Group& group, const std::string variableName, const char* values );
     void Write( Group& group, const std::string variableName, const unsigned char* values );
@@ -72,8 +70,7 @@ private:
 };
 
 
-} //end namespace engine
 } //end namespace adios
 
 
-#endif /* SINGLEBP_H_ */
+#endif /* WRITER_H_ */
diff --git a/src/ADIOS.cpp b/src/ADIOS.cpp
index fd25ef8df..7f568f99b 100644
--- a/src/ADIOS.cpp
+++ b/src/ADIOS.cpp
@@ -6,6 +6,7 @@
  */
 
 /// \cond EXCLUDE_FROM_DOXYGEN
+#include <engine/Writer.h>
 #include <iostream>
 #include <fstream>
 #include <sstream>
@@ -16,7 +17,6 @@
 #include "functions/adiosFunctions.h"
 
 //Engine
-#include "engine/SingleBP.h"
 
 namespace adios
 {
@@ -115,9 +115,9 @@ unsigned int ADIOS::Open( const std::string name, const std::string accessMode,
     ++m_EngineCounter;
     const std::string type( itMethod->second.m_Type );
 
-    if( type == "SingleBP" || type == "singleBP" || type == "singlebp" )
+    if( type == "Writer" || type == "writer" )
     {
-        m_Engines.emplace( m_EngineCounter, std::make_shared<engine::SingleBP>( name, accessMode, mpiComm, itMethod->second, cores ) );
+        m_Engines.emplace( m_EngineCounter, std::make_shared<Writer>( name, accessMode, mpiComm, itMethod->second, cores ) );
     }
 //    else if( type == "SIRIUS" )
 //    {
diff --git a/src/core/Method.cpp b/src/core/Method.cpp
index 8b475893f..044adfefd 100644
--- a/src/core/Method.cpp
+++ b/src/core/Method.cpp
@@ -52,16 +52,16 @@ void Method::AddTransportParameters( const std::string type, const std::vector<s
             throw std::invalid_argument( "ERROR: first argument in AddTransport must be a single word for transport\n" );
     }
 
-    std::map<std::string, std::string> mapParameters = BuildParametersMap(parameters, m_DebugMode);
+    std::map<std::string, std::string> mapParameters = BuildParametersMap( parameters, m_DebugMode );
     if( m_DebugMode == true )
     {
-        if( mapParameters.count("transport") )
+        if( mapParameters.count("transport") == 1 )
             std::invalid_argument( "ERROR: transport can't be redefined with transport=, "
                                    "must be the first argument, in AddTransportParameters( transport, ...);\n" );
     }
 
     mapParameters["transport"] = type;
-    m_TransportParameters.push_back( BuildParametersMap(parameters, m_DebugMode) );
+    m_TransportParameters.push_back( mapParameters );
 }
 
 
diff --git a/src/engine/SingleBP.cpp b/src/engine/Writer.cpp
similarity index 62%
rename from src/engine/SingleBP.cpp
rename to src/engine/Writer.cpp
index 20c3bcff3..8c0e4d772 100644
--- a/src/engine/SingleBP.cpp
+++ b/src/engine/Writer.cpp
@@ -7,7 +7,7 @@
 
 #include <iostream>
 
-#include "engine/SingleBP.h"
+#include "engine/Writer.h"
 #include "core/Support.h"
 
 //supported capsules
@@ -21,170 +21,168 @@
 
 namespace adios
 {
-namespace engine
-{
 
 
-SingleBP::SingleBP( const std::string streamName, const std::string accessMode, const MPI_Comm mpiComm,
+Writer::Writer( const std::string streamName, const std::string accessMode, const MPI_Comm mpiComm,
                     const Method& method, const bool debugMode, const unsigned int cores ):
-    Engine( "SingleBP", streamName, accessMode, mpiComm, method, debugMode, cores, " SingleBP constructor (or call to ADIOS Open).\n" )
+    Engine( "Writer", streamName, accessMode, mpiComm, method, debugMode, cores, " Writer constructor (or call to ADIOS Open).\n" )
 {
     Init( );
 }
 
 
-SingleBP::~SingleBP( )
+Writer::~Writer( )
 { }
 
 
-void SingleBP::Init( )
+void Writer::Init( )
 {
     InitCapsules( );
     InitTransports( );
 }
 
 
-void SingleBP::Write( Group& group, const std::string variableName, const char* values )
+void Writer::Write( Group& group, const std::string variableName, const char* values )
 {
 
 }
 
-void SingleBP::Write( Group& group, const std::string variableName, const unsigned char* values )
+void Writer::Write( Group& group, const std::string variableName, const unsigned char* values )
 {
 
 }
 
-void SingleBP::Write( Group& group, const std::string variableName, const short* values )
+void Writer::Write( Group& group, const std::string variableName, const short* values )
 {
 
 }
 
-void SingleBP::Write( Group& group, const std::string variableName, const unsigned short* values )
+void Writer::Write( Group& group, const std::string variableName, const unsigned short* values )
 {
 
 }
 
-void SingleBP::Write( Group& group, const std::string variableName, const int* values )
+void Writer::Write( Group& group, const std::string variableName, const int* values )
 {
 
 }
 
-void SingleBP::Write( Group& group, const std::string variableName, const unsigned int* values )
+void Writer::Write( Group& group, const std::string variableName, const unsigned int* values )
 {
 
 }
 
-void SingleBP::Write( Group& group, const std::string variableName, const long int* values )
+void Writer::Write( Group& group, const std::string variableName, const long int* values )
 {
 
 }
 
-void SingleBP::Write( Group& group, const std::string variableName, const unsigned long int* values )
+void Writer::Write( Group& group, const std::string variableName, const unsigned long int* values )
 {
 
 }
 
-void SingleBP::Write( Group& group, const std::string variableName, const long long int* values )
+void Writer::Write( Group& group, const std::string variableName, const long long int* values )
 {
 
 }
 
-void SingleBP::Write( Group& group, const std::string variableName, const unsigned long long int* values )
+void Writer::Write( Group& group, const std::string variableName, const unsigned long long int* values )
 {
 
 }
 
-void SingleBP::Write( Group& group, const std::string variableName, const float* values )
+void Writer::Write( Group& group, const std::string variableName, const float* values )
 {
 
 }
 
-void SingleBP::Write( Group& group, const std::string variableName, const double* values )
+void Writer::Write( Group& group, const std::string variableName, const double* values )
 {
     //auto index = PreSetVariable( group, variableName, Support::DatatypesAliases.at("double"), " from call to Write double*" );
 }
 
 
-void SingleBP::Write( Group& group, const std::string variableName, const long double* values )
+void Writer::Write( Group& group, const std::string variableName, const long double* values )
 {
 
 }
 
 
-void SingleBP::Write( const std::string variableName, const char* values )
+void Writer::Write( const std::string variableName, const char* values )
 {
 
 }
 
-void SingleBP::Write( const std::string variableName, const unsigned char* values )
+void Writer::Write( const std::string variableName, const unsigned char* values )
 {
 
 }
 
-void SingleBP::Write( const std::string variableName, const short* values )
+void Writer::Write( const std::string variableName, const short* values )
 {
 
 }
 
-void SingleBP::Write( const std::string variableName, const unsigned short* values )
+void Writer::Write( const std::string variableName, const unsigned short* values )
 {
 
 }
 
-void SingleBP::Write( const std::string variableName, const int* values )
+void Writer::Write( const std::string variableName, const int* values )
 {
     auto index = PreSetVariable( *m_Group, variableName, Support::DatatypesAliases.at("int"), " from call to Write int*" );
-    std::cout << "Hello from SingleBP Write integer with index " << index << "\n";
+    std::cout << "Hello from Writer for an integer with index " << index << "\n";
 //    Variable<int>& variable = m_Group->m_Int[index];
 //    variable.Values = values;
 //    auto localDimensions = m_Group->GetDimensions( variable.DimensionsCSV );
 
 }
 
-void SingleBP::Write( const std::string variableName, const unsigned int* values )
+void Writer::Write( const std::string variableName, const unsigned int* values )
 {
 
 }
 
-void SingleBP::Write( const std::string variableName, const long int* values )
+void Writer::Write( const std::string variableName, const long int* values )
 {
 
 }
 
-void SingleBP::Write( const std::string variableName, const unsigned long int* values )
+void Writer::Write( const std::string variableName, const unsigned long int* values )
 {
 
 }
 
-void SingleBP::Write( const std::string variableName, const long long int* values )
+void Writer::Write( const std::string variableName, const long long int* values )
 {
 
 }
 
-void SingleBP::Write( const std::string variableName, const unsigned long long int* values )
+void Writer::Write( const std::string variableName, const unsigned long long int* values )
 {
 
 }
 
-void SingleBP::Write( const std::string variableName, const float* values )
+void Writer::Write( const std::string variableName, const float* values )
 {
 
 }
 
-void SingleBP::Write( const std::string variableName, const double* values )
+void Writer::Write( const std::string variableName, const double* values )
 {
     auto index = PreSetVariable( *m_Group, variableName, Support::DatatypesAliases.at("double"), " from call to Write double*" );
     std::cout << "Hello from SingleBP Write double with index " << index << "\n";
 }
 
 
-void SingleBP::Write( const std::string variableName, const long double* values )
+void Writer::Write( const std::string variableName, const long double* values )
 {
 
 }
 
 
-void SingleBP::InitCapsules( )
+void Writer::InitCapsules( )
 {
     if( m_DebugMode == true )
     {
@@ -212,7 +210,7 @@ void SingleBP::InitCapsules( )
 
 
 
-void SingleBP::InitTransports( )
+void Writer::InitTransports( )
 {
     std::set< std::string > transportStreamNames; //used to check for name conflict between transports
 
@@ -266,7 +264,6 @@ void SingleBP::InitTransports( )
                 m_Transports.back()->Open( m_Name, m_AccessMode );
             else
                 m_Transports.back()->Open( m_Name, m_AccessMode );
-
         }
         else if( transportsSize == 0 )
         {
@@ -278,6 +275,5 @@ void SingleBP::InitTransports( )
 
 
 
-} //end namespace engine
 } //end namespace adios
 
-- 
GitLab