diff options
author | Josh Blum | 2013-07-27 19:20:35 -0700 |
---|---|---|
committer | Josh Blum | 2013-07-27 19:20:35 -0700 |
commit | a3b5a07cf7c64f1a038839d3ef2f7b1d9fbf6c42 (patch) | |
tree | 533568f9a549aeae63930b9767a582b4975629f2 /lib/factory.cpp | |
parent | 9ee559e8be429e6ca18858de668289cf66e19a0f (diff) | |
download | sandhi-a3b5a07cf7c64f1a038839d3ef2f7b1d9fbf6c42.tar.gz sandhi-a3b5a07cf7c64f1a038839d3ef2f7b1d9fbf6c42.tar.bz2 sandhi-a3b5a07cf7c64f1a038839d3ef2f7b1d9fbf6c42.zip |
gras: added arg check with nice warning to callable and factory
Diffstat (limited to 'lib/factory.cpp')
-rw-r--r-- | lib/factory.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/factory.cpp b/lib/factory.cpp index 5c405f3..35b1b24 100644 --- a/lib/factory.cpp +++ b/lib/factory.cpp @@ -1,6 +1,7 @@ // Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. #include <gras/factory.hpp> +#include <boost/format.hpp> #include <boost/shared_ptr.hpp> #include <boost/thread/mutex.hpp> #include <stdexcept> @@ -18,6 +19,12 @@ FactoryRegistryEntry::~FactoryRegistryEntry(void) //NOP } +void FactoryRegistryEntry::arg_check(const PMCList &args, const size_t nargs) +{ + if (args.size() != nargs) throw std::runtime_error(str(boost::format( + "factory expected %u arguments but for %u") % nargs % args.size())); +} + typedef std::map<std::string, boost::shared_ptr<FactoryRegistryEntry> > FactoryRegistryType; static FactoryRegistryType &get_factory_registry(void) |