added member function const std::string type() const to all filters in both hpp and test code
test_thread_pool_observer
test_session1
test_session2
+test_filter_factory
test_filter_z3950_client
test_filter_backend_test
test_filter_virt_db
-## $Id: Makefile.am,v 1.30 2005-10-28 10:35:30 marc Exp $
+## $Id: Makefile.am,v 1.31 2005-10-29 22:23:36 marc Exp $
MAINTAINERCLEANFILES = Makefile.in config.in config.hpp
libyp2_la_LDFLAGS = -version-info 0:0:0
libyp2_la_SOURCES = \
- session.cpp session.hpp package.hpp filter.hpp\
+ session.cpp session.hpp package.hpp \
router.hpp router_chain.hpp router_chain.cpp \
router_flexml.hpp router_flexml.cpp \
thread_pool_observer.cpp thread_pool_observer.hpp \
- filter_factory.hpp \
+ filter.hpp filter.cpp filter_factory.hpp \
filter_frontend_net.cpp filter_frontend_net.hpp \
filter_log.cpp filter_log.hpp \
filter_virt_db.cpp filter_virt_db.hpp \
-/* $Id: ex_filter_frontend_net.cpp,v 1.14 2005-10-26 18:53:49 adam Exp $
+/* $Id: ex_filter_frontend_net.cpp,v 1.15 2005-10-29 22:23:36 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
}
return package.move();
};
+ const std::string type() const {
+ return "HTTPFilter";
+ };
};
int main(int argc, char **argv)
--- /dev/null
+/* $Id: filter.cpp,v 1.1 2005-10-29 22:23:36 marc Exp $
+ Copyright (c) 2005, Index Data.
+
+%LICENSE%
+ */
+
+#include <stdexcept>
+
+#include "filter.hpp"
+
+
+// defining and initializing static members
+
+// std::string yp2::filter::Base:m_type("Base");
+
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * c-file-style: "stroustrup"
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
-/* $Id: filter.hpp,v 1.6 2005-10-24 09:53:06 adam Exp $
+/* $Id: filter.hpp,v 1.7 2005-10-29 22:23:36 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
///sends Package off to next Filter, returns altered Package
virtual void process(Package & package) const = 0;
- virtual void configure(const xmlNode * ptr = 0) { } ;
+ virtual void configure(const xmlNode * ptr = 0) { };
- /// get function - right val in assignment
- std::string name() const {
- return m_name;
- }
- /// set function - left val in assignment
- std::string & name() {
- return m_name;
- }
-
- /// set function - can be chained
- Base & name(const std::string & name){
- m_name = name;
- return *this;
- }
-
- private:
- std::string m_name;
+ virtual const std::string type() const = 0;
};
}
-/* $Id: filter_backend_test.hpp,v 1.2 2005-10-29 15:54:29 adam Exp $
+/* $Id: filter_backend_test.hpp,v 1.3 2005-10-29 22:23:36 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
~Backend_test();
Backend_test();
void process(yp2::Package & package) const;
+ const std::string type() const {
+ return "Backend_test";
+ };
private:
boost::scoped_ptr<Rep> m_p;
};
-/* $Id: filter_frontend_net.hpp,v 1.5 2005-10-15 14:09:09 adam Exp $
+/* $Id: filter_frontend_net.hpp,v 1.6 2005-10-29 22:23:36 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
public:
FrontendNet::FrontendNet();
void process(yp2::Package & package) const;
+ const std::string type() const {
+ return "FrontendNet";
+ };
private:
int m_no_threads;
std::vector<std::string> m_ports;
-/* $Id: filter_log.hpp,v 1.7 2005-10-25 16:01:36 adam Exp $
+/* $Id: filter_log.hpp,v 1.8 2005-10-29 22:23:36 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
Log(const std::string &msg);
Log();
void process(yp2::Package & package) const;
+ const std::string type() const {
+ return "Log";
+ };
private:
/// static mutex to lock Ostream during logging operation
static boost::mutex m_log_mutex;
-/* $Id: filter_virt_db.hpp,v 1.2 2005-10-29 15:54:29 adam Exp $
+/* $Id: filter_virt_db.hpp,v 1.3 2005-10-29 22:23:36 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
~Virt_db();
Virt_db();
void process(yp2::Package & package) const;
+ const std::string type() const {
+ return "Virt_db";
+ };
void add_map_db2vhost(std::string db, std::string vhost);
private:
boost::scoped_ptr<Rep> m_p;
-/* $Id: filter_z3950_client.hpp,v 1.2 2005-10-29 15:54:29 adam Exp $
+/* $Id: filter_z3950_client.hpp,v 1.3 2005-10-29 22:23:36 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
~Z3950Client();
Z3950Client();
void process(yp2::Package & package) const;
+ const std::string type() const {
+ return "Z3950Client";
+ };
private:
boost::scoped_ptr<Rep> m_p;
};
-/* $Id: test_filter1.cpp,v 1.11 2005-10-15 14:09:09 adam Exp $
+/* $Id: test_filter1.cpp,v 1.12 2005-10-29 22:23:36 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
class TFilter: public yp2::filter::Base {
public:
void process(yp2::Package & package) const {};
+ const std::string type() const {
+ return "TFilter";
+ };
};
{
try{
TFilter filter;
+
- filter.name("filter1");
-
- BOOST_CHECK (filter.name() == "filter1");
-
- filter.name() = "filter1 rename";
-
- BOOST_CHECK(filter.name() == "filter1 rename");
+ BOOST_CHECK (filter.type() == "TFilter");
}
catch ( ... ) {
BOOST_CHECK (false);
-/* $Id: test_filter2.cpp,v 1.13 2005-10-26 10:55:26 marc Exp $
+/* $Id: test_filter2.cpp,v 1.14 2005-10-29 22:23:36 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
package.data() = m_constant;
package.move();
};
+ const std::string type() const {
+ return "FilterConstant";
+ };
void configure(const xmlNode* ptr = 0);
int get_constant() const { return m_constant; };
private:
package.data() = package.data() * 2;
package.move();
};
+ const std::string type() const {
+ return "FilterConstant";
+ };
};
{
try {
FilterConstant fc;
- fc.name() = "FilterConstant";
FilterDouble fd;
- fd.name() = "FilterDouble";
{
yp2::RouterChain router1;
-/* $Id: test_filter_factory.cpp,v 1.2 2005-10-29 17:58:14 marc Exp $
+/* $Id: test_filter_factory.cpp,v 1.3 2005-10-29 22:23:36 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
- */
+
+*/
#include <iostream>
class XFilter: public yp2::filter::Base {
public:
void process(yp2::Package & package) const {};
- std::string name(){
- return std::string("xfilter");
- }
+ const std::string type() const{
+ return "XFilter";
+ };
};
return new XFilter;
}
-
class YFilter: public yp2::filter::Base {
public:
void process(yp2::Package & package) const {};
- std::string name(){
- return std::string("yfilter");
- }
+ const std::string type() const{
+ return "YFilter";
+ };
};
yp2::filter::Base* yfilter_creator(){
yp2::filter::FilterFactory ffactory;
- BOOST_CHECK_EQUAL(ffactory.add_creator("xfilter", xfilter_creator),
+ XFilter xf;
+ YFilter yf;
+
+ const std::string xfid = xf.type();
+ const std::string yfid = yf.type();
+
+ //std::cout << "Xfilter name: " << xfid << std::endl;
+ //std::cout << "Yfilter name: " << yfid << std::endl;
+
+ BOOST_CHECK_EQUAL(ffactory.add_creator(xfid, xfilter_creator),
true);
- BOOST_CHECK_EQUAL(ffactory.drop_creator("xfilter"),
+ BOOST_CHECK_EQUAL(ffactory.drop_creator(xfid),
true);
- BOOST_CHECK_EQUAL(ffactory.add_creator("xfilter", xfilter_creator),
+ BOOST_CHECK_EQUAL(ffactory.add_creator(xfid, xfilter_creator),
true);
- BOOST_CHECK_EQUAL(ffactory.add_creator("yfilter", yfilter_creator),
+ BOOST_CHECK_EQUAL(ffactory.add_creator(yfid, yfilter_creator),
true);
- yp2::filter::Base* xfilter = ffactory.create("xfilter");
- yp2::filter::Base* yfilter = ffactory.create("yfilter");
-
- //BOOST_CHECK_EQUAL(xfilter->name(), std::string("xfilter"));
- //BOOST_CHECK_EQUAL(yfilter->name(), std::string("yfilter"));
+ yp2::filter::Base* xfilter = ffactory.create(xfid);
+ yp2::filter::Base* yfilter = ffactory.create(yfid);
+
+ BOOST_CHECK_EQUAL(xf.type(), xfilter->type());
+ BOOST_CHECK_EQUAL(yf.type(), yfilter->type());
+
+ //std::cout << "Xfilter pointer name: " << xfilter->type() << std::endl;
+ //std::cout << "Yfilter pointer name: " << yfilter->type() << std::endl;
+
}
catch ( ... ) {
+ throw;
BOOST_CHECK (false);
}
}
+
+
+
+ // get function - right val in assignment
+ //std::string name() const {
+ //return m_name;
+ // return "Base";
+ //}
+
+ // set function - left val in assignment
+ //std::string & name() {
+ // return m_name;
+ //}
+
+ // set function - can be chained
+ //Base & name(const std::string & name){
+ // m_name = name;
+ // return *this;
+ //}
+
+
/*
* Local variables:
* c-basic-offset: 4
-/* $Id: test_filter_frontend_net.cpp,v 1.10 2005-10-26 10:55:26 marc Exp $
+/* $Id: test_filter_frontend_net.cpp,v 1.11 2005-10-29 22:23:36 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
}
return package.move();
};
+ const std::string type() const {
+ return "FilterInit";
+ };
};
-/* $Id: test_filter_log.cpp,v 1.4 2005-10-26 10:55:26 marc Exp $
+/* $Id: test_filter_log.cpp,v 1.5 2005-10-29 22:23:36 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
}
return package.move();
};
+ const std::string type() const {
+ return "FilterBounceInit";
+ };
};
-/* $Id: test_router_flexml.cpp,v 1.1 2005-10-26 14:12:00 marc Exp $
+/* $Id: test_router_flexml.cpp,v 1.2 2005-10-29 22:23:36 marc Exp $
Copyright (c) 2005, Index Data.
%LICENSE%
class TFilter: public yp2::filter::Base {
public:
void process(yp2::Package & package) const {};
+ const std::string type() const {
+ return "TFilter";
+ };
};