# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
# by quotes) that should identify the project.
-PROJECT_NAME = YP2
+PROJECT_NAME = @PACKAGE@
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
ALWAYS_DETAILED_SEC = NO
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited
-# members of a class in the documentation of that class as if those members were
-# ordinary class members. Constructors, destructors and assignment operators of
-# the base classes will not be shown.
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show
+# all inherited members of a class in the documentation of that class
+# as if those members were ordinary class members. Constructors,
+# destructors and assignment operators of the base classes will not be
+# shown.
INLINE_INHERITED_MEMB = NO
# collaboration diagrams in a style similar to the OMG's Unified Modeling
# Language.
-UML_LOOK = NO
+UML_LOOK = YES
# If set to YES, the inheritance and collaboration graphs will show the
# relations between templates and their instances.
-TEMPLATE_RELATIONS = NO
+TEMPLATE_RELATIONS = YES
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
# tags are set to YES then doxygen will generate a graph for each documented
# So in most cases it will be better to enable call graphs for selected
# functions only using the \callgraph command.
-CALL_GRAPH = NO
+CALL_GRAPH = YES
# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
# will graphical hierarchy of all classes instead of a textual one.
#include <stdexcept>
#include <list>
+#include <boost/thread/mutex.hpp>
+
namespace yp2 {
class Package;
class Filter {
public:
virtual ~Filter(){};
+
+ ///sends Package off to next Filter, returns altered Package
virtual Package & process(Package & package) const {
return package;
};
virtual void configure(){};
-
- // set/get the C++ way .. just as showoff
-
- // get function - returns copy and keeps object const,
- // thus is right val in assignment
+
+ /// get function - right val in assignment
std::string name() const {
return m_name;
}
- // set function - returns reference and changes object,
- // thus is left val in assignment
+
+ /// set function - left val in assignment
std::string & name() {
return m_name;
}
- // more traditional set function, taking const reference
- // or copy (here const ref for demo), returning ref to object
- // can be chained with other similar functions!
+
+ /// set function - can be chained
Filter & name(const std::string & name){
m_name = name;
return *this;
};
- class Filter_Exception : public std::runtime_error {
+ class FilterException : public std::runtime_error {
public:
- Filter_Exception(const std::string message)
- : std::runtime_error("Filter_Exception: " + message){
+ FilterException(const std::string message)
+ : std::runtime_error("FilterException: " + message){
};
};
+
+ class RouterException : public std::runtime_error {
+ public:
+ RouterException(const std::string message)
+ : std::runtime_error("RouterException: " + message){};
+ };
+
+
+ class Router {
+ public:
+ Router(){};
+ virtual ~Router(){};
- class Router {
- public:
- Router(){};
- virtual ~Router(){};
- virtual const Filter *
- move(const Filter *filter, const Package *package) const {
- std::list<const Filter *>::const_iterator it;
- it = m_filter_list.begin();
- if (filter)
- {
- for (; it != m_filter_list.end(); it++)
- if (*it == filter)
- {
- it++;
- break;
- }
- }
- if (it == m_filter_list.end())
- {
- //throw Router_Exception("no routing rules known");
- return 0;
- }
- return *it;
- };
- virtual void configure(){};
- Router & rule(const Filter &filter){
- m_filter_list.push_back(&filter);
- return *this;
- }
- private:
- Router(const Router &);
- Router& operator=(const Router &);
- std::list<const Filter *> m_filter_list;
- };
+ /// determines next Filter to use from current Filter and Package
+ virtual const Filter *move(const Filter *filter,
+ const Package *package) const {
+ return 0;
+ };
+
+ /// re-read configuration of routing tables
+ virtual void configure(){};
+
+ /// add routing rule expressed as Filter to Router
+ virtual Router & rule(const Filter &filter){
+ return *this;
+ }
+ private:
+ /// disabled because class is singleton
+ Router(const Router &);
+
+ /// disabled because class is singleton
+ Router& operator=(const Router &);
+ };
+
+ class RouterChain : public Router {
+ public:
+ RouterChain(){};
+ virtual ~RouterChain(){};
+ virtual const Filter *move(const Filter *filter,
+ const Package *package) const {
+ std::list<const Filter *>::const_iterator it;
+ it = m_filter_list.begin();
+ if (filter)
+ {
+ for (; it != m_filter_list.end(); it++)
+ if (*it == filter)
+ {
+ it++;
+ break;
+ }
+ }
+ if (it == m_filter_list.end())
+ {
+ //throw RouterException("no routing rules known");
+ return 0;
+ }
+ return *it;
+ };
+ virtual void configure(){};
+ RouterChain & rule(const Filter &filter){
+ m_filter_list.push_back(&filter);
+ return *this;
+ }
+ protected:
+ std::list<const Filter *> m_filter_list;
+ private:
+ /// disabled because class is singleton
+ RouterChain(const RouterChain &);
+
+ /// disabled because class is singleton
+ RouterChain& operator=(const RouterChain &);
+ };
- class Router_Exception : public std::runtime_error {
+
+ class PackageException : public std::runtime_error {
public:
- Router_Exception(const std::string message)
- : std::runtime_error("Router_Exception: " + message){};
+ PackageException(const std::string message)
+ : std::runtime_error("PackageException: " + message){
+ };
};
class Package {
public:
- // send package to it's next filter defined in chain
+ Package(unsigned long int id = 0, bool close = 0)
+ : m_session_id(id), m_session_close(close),
+ m_filter(0), m_router(0), m_data(0) {}
+
+ /// send Package to it's next Filter defined in Router
Package & move() {
m_filter = m_router->move(m_filter, this);
if (m_filter)
return *this;
}
- // get function - returns copy and keeps object const,
- // thus is right val in assignment
+
+ /// get function - right val in assignment
+ unsigned int session_id() const {
+ return m_session_id;
+ }
+
+ /// get function - right val in assignment
+ unsigned int session_close() const {
+ return m_session_close;
+ }
+
+
+ /// get function - right val in assignment
unsigned int data() const {
return m_data;
}
- // set function - returns reference and changes object,
- // thus is left val in assignment
+
+ /// set function - left val in assignment
unsigned int & data() {
return m_data;
}
-
- // more traditional set function, taking const reference
- // or copy (here const ref for demo), returning ref to object
- // can be chained with other similar functions!
+
+ /// set function - can be chained
Package & data(const unsigned int & data){
m_data = data;
return *this;
}
- // get function - returns copy and keeps object const,
- // thus is right val in assignment
+
//Router router() const {
// return m_router;
//}
- // set function - returns reference and changes object,
- // thus is left val in assignment
+
//Router & router() {
// return m_router;
//}
- // more traditional set function, taking const reference
- // or copy (here const ref for demo), returning ref to object
- // can be chained with other similar functions!
+
+ /// set function - can be chained
Package & router(const Router &router){
m_filter = 0;
m_router = &router;
return *this;
}
- Package() {
- m_filter = 0;
- m_router = 0;
- m_data = 0;
- }
+
private:
- unsigned int m_data;
+ unsigned long int m_session_id;
+ bool m_session_close;
const Filter *m_filter;
const Router *m_router;
+ unsigned int m_data;
};
-
- class Package_Exception : public std::runtime_error {
- public:
- Package_Exception(const std::string message)
- : std::runtime_error("Package_Exception: " + message){
+
+ class Session
+ {
+ public:
+ Session() : m_id(0){};
+ /// returns next id, global state of id protected by boost::mutex
+ long unsigned int id() {
+ boost::mutex::scoped_lock scoped_lock(m_mutex);
+ ++m_id;
+ return m_id;
};
- };
+ private:
+ /// disabled because class is singleton
+ Session(const Session &);
+
+ /// disabled because class is singleton
+ Session& operator=(const Session &);
+
+ boost::mutex m_mutex;
+ unsigned long int m_id;
+
+ };
+
+
}