#ifndef DBS_NODE_TEST_FACTORY_H #define DBS_NODE_TEST_FACTORY_H #include "Algebras/DBService2/Node.hpp" namespace DBServiceTest { class NodeTestFactory { // static int nextNodePort; public: /* Returns a saved (non-new) targetNode. If ~save~ is set to ~false~ then the targetNode will be returned unsaved. */ static std::shared_ptr buildTargetNode( std::string recordDatabase, int nodePort, bool save = true ) { std::shared_ptr targetNode = buildNode( recordDatabase, DBService::Node::nodeTypeDBService(), nodePort, false ); targetNode->setType(DBService::Node::nodeTypeDBService()); if (save == true) targetNode->save(); return targetNode; } /* Creates the given number of nodes. */ static std::vector > buildNodes( std::string recordDatabase, std::string nodeType, int lowestNodePort, int numberOfNodes, bool save = true ) { std::vector > nodes; std::shared_ptr node; int currentNodePort = lowestNodePort; for(int i=0; i buildNode( std::string recordDatabase, std::string nodeType, int nodePort, bool save = true ) { std::shared_ptr targetNode = std::make_shared( "localhost", nodePort, "", "/home/doesnt_exist/secondo", 9941, 9942); targetNode->setDatabase(recordDatabase); targetNode->setType(nodeType); if (save == true) targetNode->save(); return targetNode; } //TODO Using statics in header files causes linker errors. Thank you c++! :) // static int getUniqueNodePort() { // if (NodeTestFactory::nextNodePort == 0) // NodeTestFactory::nextNodePort = 4740; // // 4740, 4741, ... // return NodeTestFactory::nextNodePort++; // } }; } #endif