+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * Author : Maxim Mamontov <faust@stargazer.dp.ua>
+ */
+
#ifndef SERVICE_CONF_H
#define SERVICE_CONF_H
-#include <string>
-
+#include "resetable.h"
#include "os_int.h"
+#include <string>
+
struct SERVICE_CONF
{
SERVICE_CONF()
uint8_t payDay;
};
+struct SERVICE_CONF_RES
+{
+SERVICE_CONF_RES()
+ : name(), comment(),
+ cost(), payDay()
+{}
+
+SERVICE_CONF_RES(const SERVICE_CONF & rhs)
+ : name(rhs.name), comment(rhs.comment),
+ cost(rhs.cost), payDay(rhs.payDay)
+{}
+
+SERVICE_CONF_RES & operator=(const SERVICE_CONF & conf)
+{
+name = conf.name;
+comment = conf.comment;
+cost = conf.cost;
+payDay = conf.payDay;
+return *this;
+}
+
+SERVICE_CONF GetData() const
+{
+SERVICE_CONF sc;
+sc.name = name.data();
+sc.comment = comment.data();
+sc.cost = cost.data();
+sc.payDay = payDay.data();
+return sc;
+}
+
+void Splice(const SERVICE_CONF_RES & rhs)
+{
+name.splice(rhs.name);
+comment.splice(rhs.comment);
+cost.splice(rhs.cost);
+payDay.splice(rhs.payDay);
+}
+
+RESETABLE<std::string> name;
+RESETABLE<std::string> comment;
+RESETABLE<double> cost;
+RESETABLE<uint8_t> payDay;
+};
+
inline
bool operator==(const SERVICE_CONF & a, const SERVICE_CONF & b)
{
#ifndef SERVICES_H
#define SERVICES_H
-#include <string>
-
#include "service_conf.h"
+#include <string>
+
class ADMIN;
class SERVICES {
virtual int Add(const SERVICE_CONF & service, const ADMIN * admin) = 0;
virtual int Del(const std::string & name, const ADMIN * admin) = 0;
virtual int Change(const SERVICE_CONF & service, const ADMIN * admin) = 0;
- virtual bool Find(const std::string & name, SERVICE_CONF * service) = 0;
+ virtual bool Find(const std::string & name, SERVICE_CONF * service) const = 0;
+ virtual bool Find(const std::string & name, SERVICE_CONF_RES * service) const = 0;
virtual bool Exists(const std::string & name) const = 0;
virtual const std::string & GetStrError() const = 0;
virtual size_t Count() const = 0;
#include "testtariffs.h"
#include "testadmin.h"
#include "teststore.h"
+#include "testservices.h"
namespace tut
{
TEST_TARIFFS tariffs;
TEST_ADMIN admin;
TEST_STORE store;
- USER_IMPL user(&settings, &store, &tariffs, &admin, NULL);
+ TEST_SERVICES services;
+ USER_IMPL user(&settings, &store, &tariffs, &admin, NULL, services);
USER_PROPERTY<double> & cash(user.GetProperty().cash);
USER_PROPERTY<std::string> & tariffName(user.GetProperty().tariffName);
TEST_TARIFFS tariffs;
TEST_ADMIN admin;
TEST_STORE store;
- USER_IMPL user(&settings, &store, &tariffs, &admin, NULL);
+ TEST_SERVICES services;
+ USER_IMPL user(&settings, &store, &tariffs, &admin, NULL, services);
USER_PROPERTY<double> & cash(user.GetProperty().cash);
USER_PROPERTY<double> & credit(user.GetProperty().credit);
TEST_TARIFFS tariffs;
TEST_ADMIN admin;
TEST_STORE store;
- USER_IMPL user(&settings, &store, &tariffs, &admin, NULL);
+ TEST_SERVICES services;
+ USER_IMPL user(&settings, &store, &tariffs, &admin, NULL, services);
USER_PROPERTY<double> & cash(user.GetProperty().cash);
USER_PROPERTY<double> & credit(user.GetProperty().credit);
#include "teststore.h"
#include "testauth.h"
#include "testusers.h"
+#include "testservices.h"
class AFTER_CONNECTED_NOTIFIER : public PROPERTY_NOTIFIER_BASE<bool>,
private NONCOPYABLE {
TEST_STORE store;
TEST_AUTH auth;
TEST_USERS users;
- USER_IMPL user(&settings, &store, &tariffs, &admin, &users);
+ TEST_SERVICES services;
+ USER_IMPL user(&settings, &store, &tariffs, &admin, &users, services);
AFTER_CONNECTED_NOTIFIER connectionNotifier;
TEST_STORE store;
TEST_AUTH auth;
TEST_USERS users;
- USER_IMPL user(&settings, &store, &tariffs, &admin, &users);
+ TEST_SERVICES services;
+ USER_IMPL user(&settings, &store, &tariffs, &admin, &users, services);
AFTER_CONNECTED_NOTIFIER connectionNotifier;
--- /dev/null
+#ifndef __TEST_SERVICES__
+#define __TEST_SERVICES__
+
+#include "stg/services.h"
+
+class TEST_SERVICES : public SERVICES
+{
+ public:
+ virtual int Add(const SERVICE_CONF & /*service*/, const ADMIN * /*admin*/) { return 0; }
+ virtual int Del(const std::string & /*name*/, const ADMIN * /*admin*/) { return 0; }
+ virtual int Change(const SERVICE_CONF & /*service*/, const ADMIN * /*admin*/) { return 0; }
+ virtual bool Find(const std::string & name, SERVICE_CONF * service) const { return false; }
+ virtual bool Find(const std::string & name, SERVICE_CONF_RES * service) const { return false; }
+ virtual bool Exists(const std::string & name) const { return false; }
+ virtual const std::string & GetStrError() const { return m_errorStr; }
+ virtual size_t Count() const { return 0; }
+
+ virtual int OpenSearch() const { return 0; }
+ virtual int SearchNext(int, SERVICE_CONF * /*service*/) const { return 0; }
+ virtual int CloseSearch(int) const { return 0; }
+
+ private:
+ std::string m_errorStr;
+};
+
+#endif
#ifndef __TEST_USERS_H__
#define __TEST_USERS_H__
+#include "stg/users.h"
+
class TEST_USERS : public USERS {
public:
TEST_USERS() {}