configurationexceptions.h
1 /***************************************************************************
2  * Copyright (C) 2008 by Tomassino Ferrauto *
3  * t_ferrauto@yahoo.it *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
21 #ifndef CONFIGURATIONEXCEPTIONS_H
22 #define CONFIGURATIONEXCEPTIONS_H
23 
24 #include <typeinfo>
25 #include <exception>
26 #include <cstring>
27 #include <cstdio>
28 #include "baseexception.h"
29 
30 // All the suff below is to avoid warnings on Windows about the use of the
31 // unsafe function sprintf and strcpy...
32 #if defined(_MSC_VER)
33  #pragma warning(push)
34  #pragma warning(disable:4996)
35 #endif
36 
37 namespace farsa {
38 
39 // NOTE: I don't use snprintf instead of sprintf because it seems not to be in
40 // the current C++ standard (C++03, it is instead in the C99 standard). Note
41 // however that no buffer overflow is possible (buffer lengths are carefully
42 // checked)
43 
48 class FARSA_CONF_TEMPLATE ClassNameNotRegisteredException : public BaseException
49 {
50 public:
58  ClassNameNotRegisteredException(const char* className) throw() :
59  BaseException()
60  {
61  strncpy(m_className, className, 256);
62  m_className[255] = '\0';
63  sprintf(m_errorMessage, "No class \"%s\" registered into Factory", m_className);
64  m_errorMessage[511] = '\0';
65  }
66 
73  BaseException(other)
74  {
75  strncpy(m_className, other.m_className, 256);
76  m_className[255] = '\0';
77  strncpy(m_errorMessage, other.m_errorMessage, 512);
78  m_errorMessage[511] = '\0';
79  }
80 
87  {
88  if (&other == this) {
89  return *this;
90  }
91 
92  BaseException::operator=(other);
93  strncpy(m_className, other.m_className, 256);
94  m_className[255] = '\0';
95  strncpy(m_errorMessage, other.m_errorMessage, 512);
96  m_errorMessage[511] = '\0';
97 
98  return *this;
99  }
100 
105  {
106  }
107 
113  virtual const char *what() const throw()
114  {
115  return m_errorMessage;
116  }
117 
123  const char *className() const throw()
124  {
125  return m_className;
126  }
127 
132  EXCEPTION_HELPER_FUNCTIONS(ClassNameNotRegisteredException)
133 
134 private:
138  char m_className[256];
139 
143  char m_errorMessage[512];
144 };
145 
150 class FARSA_CONF_TEMPLATE ClassNameIsAbstractException : public BaseException
151 {
152 public:
160  ClassNameIsAbstractException(const char* className) throw() :
161  BaseException()
162  {
163  strncpy(m_className, className, 256);
164  m_className[255] = '\0';
165  sprintf(m_errorMessage, "The class \"%s\" is abstract and cannot be created", m_className);
166  m_errorMessage[511] = '\0';
167  }
168 
175  BaseException(other)
176  {
177  strncpy(m_className, other.m_className, 256);
178  m_className[255] = '\0';
179  strncpy(m_errorMessage, other.m_errorMessage, 512);
180  m_errorMessage[511] = '\0';
181  }
182 
189  {
190  if (&other == this) {
191  return *this;
192  }
193 
194  BaseException::operator=(other);
195  strncpy(m_className, other.m_className, 256);
196  m_className[255] = '\0';
197  strncpy(m_errorMessage, other.m_errorMessage, 512);
198  m_errorMessage[511] = '\0';
199 
200  return *this;
201  }
202 
207  {
208  }
209 
215  virtual const char *what() const throw()
216  {
217  return m_errorMessage;
218  }
219 
225  const char *className() const throw()
226  {
227  return m_className;
228  }
229 
234  EXCEPTION_HELPER_FUNCTIONS(ClassNameIsAbstractException)
235 
236 private:
240  char m_className[256];
241 
245  char m_errorMessage[512];
246 };
247 
252 class FARSA_CONF_TEMPLATE CannotConvertToTypeException : public BaseException
253 {
254 public:
262  CannotConvertToTypeException(const char* className, const std::type_info& destTypeId) throw() :
263  BaseException(),
264  m_destTypeId(&destTypeId)
265  {
266  strncpy(m_className, className, 256);
267  m_className[255] = '\0';
268  // This is to be absolutely sure there is no buffer overflow
269  char tmp[256];
270  strncpy(tmp, m_destTypeId->name(), 256);
271  tmp[255] = '\0';
272  sprintf(m_errorMessage, "Impossible to convert object of type \"%s\" to type \"%s\"", m_className, tmp);
273  m_errorMessage[1023] = '\0';
274  }
275 
282  BaseException(other),
283  m_destTypeId(other.m_destTypeId)
284  {
285  strncpy(m_className, other.m_className, 256);
286  m_className[255] = '\0';
287  strncpy(m_errorMessage, other.m_errorMessage, 1024);
288  m_errorMessage[1023] = '\0';
289  }
290 
297  {
298  if (&other == this) {
299  return *this;
300  }
301 
302  BaseException::operator=(other);
303  strncpy(m_className, other.m_className, 256);
304  m_className[255] = '\0';
305  m_destTypeId = other.m_destTypeId;
306  strncpy(m_errorMessage, other.m_errorMessage, 1024);
307  m_errorMessage[1023] = '\0';
308 
309  return *this;
310  }
311 
316  {
317  }
318 
324  virtual const char *what() const throw()
325  {
326  return m_errorMessage;
327  }
328 
334  const char *className() const throw()
335  {
336  return m_className;
337  }
338 
346  const std::type_info& destTypeName() const throw()
347  {
348  return *m_destTypeId;
349  }
350 
355  EXCEPTION_HELPER_FUNCTIONS(CannotConvertToTypeException)
356 
357 private:
361  char m_className[256];
362 
367  const std::type_info* m_destTypeId;
368 
372  char m_errorMessage[1024];
373 };
374 
379 class FARSA_CONF_TEMPLATE CannotFindTypeParameterException : public BaseException
380 {
381 public:
388  CannotFindTypeParameterException(const char* groupName) throw() :
389  BaseException()
390  {
391  strncpy(m_groupName, groupName, 256);
392  m_groupName[255] = '\0';
393  sprintf(m_errorMessage, "No \"type\" parameter in the given parameter object under the \"%s\" group", m_groupName);
394  m_errorMessage[511] = '\0';
395  }
396 
403  BaseException(other)
404  {
405  strncpy(m_groupName, other.m_groupName, 256);
406  m_groupName[255] = '\0';
407  strncpy(m_errorMessage, other.m_errorMessage, 512);
408  m_errorMessage[511] = '\0';
409  }
410 
417  {
418  if (&other == this) {
419  return *this;
420  }
421 
422  BaseException::operator=(other);
423  strncpy(m_groupName, other.m_groupName, 256);
424  m_groupName[255] = '\0';
425  strncpy(m_errorMessage, other.m_errorMessage, 512);
426  m_errorMessage[511] = '\0';
427 
428  return *this;
429  }
430 
435  {
436  }
437 
443  virtual const char *what() const throw()
444  {
445  return m_errorMessage;
446  }
447 
453  const char *groupName() const throw()
454  {
455  return m_groupName;
456  }
457 
462  EXCEPTION_HELPER_FUNCTIONS(CannotFindTypeParameterException)
463 
464 private:
469  char m_groupName[256];
470 
474  char m_errorMessage[512];
475 };
476 
481 class FARSA_CONF_TEMPLATE PrefixNotGroupException : public BaseException
482 {
483 public:
489  PrefixNotGroupException(const char* prefix) throw() :
490  BaseException()
491  {
492  strncpy(m_prefix, prefix, 256);
493  m_prefix[255] = '\0';
494  sprintf(m_errorMessage, "The provided prefix (\"%s\") is not a group name, cannot ceate object", m_prefix);
495  m_errorMessage[511] = '\0';
496  }
497 
504  BaseException(other)
505  {
506  strncpy(m_prefix, other.m_prefix, 256);
507  m_prefix[255] = '\0';
508  strncpy(m_errorMessage, other.m_errorMessage, 512);
509  m_errorMessage[511] = '\0';
510  }
511 
518  {
519  if (&other == this) {
520  return *this;
521  }
522 
523  BaseException::operator=(other);
524  strncpy(m_prefix, other.m_prefix, 256);
525  m_prefix[255] = '\0';
526  strncpy(m_errorMessage, other.m_errorMessage, 512);
527  m_errorMessage[511] = '\0';
528 
529  return *this;
530  }
531 
535  virtual ~PrefixNotGroupException() throw()
536  {
537  }
538 
544  virtual const char *what() const throw()
545  {
546  return m_errorMessage;
547  }
548 
554  const char *prefix() const throw()
555  {
556  return m_prefix;
557  }
558 
563  EXCEPTION_HELPER_FUNCTIONS(PrefixNotGroupException)
564 
565 private:
569  char m_prefix[256];
570 
574  char m_errorMessage[512];
575 };
576 
581 class FARSA_CONF_TEMPLATE CyclicDependencyException : public BaseException
582 {
583 public:
591  CyclicDependencyException(const char* groupName) throw() :
592  BaseException()
593  {
594  strncpy(m_groupName, groupName, 256);
595  m_groupName[255] = '\0';
596  sprintf(m_errorMessage, "Cyclic dependency discovered when creating/configuring object for group \"%s\"", m_groupName);
597  m_errorMessage[511] = '\0';
598  }
599 
606  BaseException(other)
607  {
608  strncpy(m_groupName, other.m_groupName, 256);
609  m_groupName[255] = '\0';
610  strncpy(m_errorMessage, other.m_errorMessage, 512);
611  m_errorMessage[511] = '\0';
612  }
613 
620  {
621  if (&other == this) {
622  return *this;
623  }
624 
625  BaseException::operator=(other);
626  strncpy(m_groupName, other.m_groupName, 256);
627  m_groupName[255] = '\0';
628  strncpy(m_errorMessage, other.m_errorMessage, 512);
629  m_errorMessage[511] = '\0';
630 
631  return *this;
632  }
633 
637  virtual ~CyclicDependencyException() throw()
638  {
639  }
640 
646  virtual const char *what() const throw()
647  {
648  return m_errorMessage;
649  }
650 
657  const char *groupName() const throw()
658  {
659  return m_groupName;
660  }
661 
666  EXCEPTION_HELPER_FUNCTIONS(CyclicDependencyException)
667 
668 private:
672  char m_groupName[256];
673 
677  char m_errorMessage[512];
678 };
679 
683 class FARSA_CONF_TEMPLATE CopyDuringObjectCreationException : public BaseException
684 {
685 public:
690  BaseException()
691  {
692  sprintf(m_errorMessage, "Trying to perform a copy of ConfigurationParameter objects during calls to getObjectFromGroup");
693  m_errorMessage[255] = '\0';
694  }
695 
702  BaseException(other)
703  {
704  strncpy(m_errorMessage, other.m_errorMessage, 256);
705  m_errorMessage[255] = '\0';
706  }
707 
714  {
715  if (&other == this) {
716  return *this;
717  }
718 
719  BaseException::operator=(other);
720  strncpy(m_errorMessage, other.m_errorMessage, 256);
721  m_errorMessage[255] = '\0';
722 
723  return *this;
724  }
725 
730  {
731  }
732 
738  virtual const char *what() const throw()
739  {
740  return m_errorMessage;
741  }
742 
747  EXCEPTION_HELPER_FUNCTIONS(CopyDuringObjectCreationException)
748 
749 private:
753  char m_errorMessage[256];
754 };
755 
761 class FARSA_CONF_TEMPLATE OtherObjectBeingCreatedException : public BaseException
762 {
763 public:
772  OtherObjectBeingCreatedException(const char* groupName) throw() :
773  BaseException()
774  {
775  strncpy(m_groupName, groupName, 256);
776  m_groupName[255] = '\0';
777  sprintf(m_errorMessage, "A new object is requested for group \"%s\" while another one is being created or has been created but not configured", m_groupName);
778  m_errorMessage[511] = '\0';
779  }
780 
787  BaseException(other)
788  {
789  strncpy(m_groupName, other.m_groupName, 256);
790  m_groupName[255] = '\0';
791  strncpy(m_errorMessage, other.m_errorMessage, 512);
792  m_errorMessage[511] = '\0';
793  }
794 
801  {
802  if (&other == this) {
803  return *this;
804  }
805 
806  BaseException::operator=(other);
807  strncpy(m_groupName, other.m_groupName, 256);
808  m_groupName[255] = '\0';
809  strncpy(m_errorMessage, other.m_errorMessage, 512);
810  m_errorMessage[511] = '\0';
811 
812  return *this;
813  }
814 
819  {
820  }
821 
827  virtual const char *what() const throw()
828  {
829  return m_errorMessage;
830  }
831 
838  const char *groupName() const throw()
839  {
840  return m_groupName;
841  }
842 
847  EXCEPTION_HELPER_FUNCTIONS(OtherObjectBeingCreatedException)
848 
849 private:
853  char m_groupName[256];
854 
858  char m_errorMessage[512];
859 };
860 
865 class FARSA_CONF_TEMPLATE NoRuntimeModifiableParameter : public BaseException
866 {
867 public:
875  NoRuntimeModifiableParameter(const char* paramName) throw() :
876  BaseException()
877  {
878  strncpy(m_paramName, paramName, 256);
879  m_paramName[255] = '\0';
880  sprintf(m_errorMessage, "The parameter \"%s\" is not marked as runtime modifiable", m_paramName);
881  m_errorMessage[511] = '\0';
882  }
883 
890  BaseException(other)
891  {
892  strncpy(m_paramName, other.m_paramName, 256);
893  m_paramName[255] = '\0';
894  strncpy(m_errorMessage, other.m_errorMessage, 512);
895  m_errorMessage[511] = '\0';
896  }
897 
904  {
905  if (&other == this) {
906  return *this;
907  }
908 
909  BaseException::operator=(other);
910  strncpy(m_paramName, other.m_paramName, 256);
911  m_paramName[255] = '\0';
912  strncpy(m_errorMessage, other.m_errorMessage, 512);
913  m_errorMessage[511] = '\0';
914 
915  return *this;
916  }
917 
922  {
923  }
924 
930  virtual const char *what() const throw()
931  {
932  return m_errorMessage;
933  }
934 
940  const char *paramName() const throw()
941  {
942  return m_paramName;
943  }
944 
949  EXCEPTION_HELPER_FUNCTIONS(NoRuntimeModifiableParameter)
950 
951 private:
955  char m_paramName[256];
956 
960  char m_errorMessage[512];
961 };
962 
967 class FARSA_CONF_TEMPLATE TypeMismatchOnSettingRuntimeModifiableParameter : public BaseException
968 {
969 public:
981  TypeMismatchOnSettingRuntimeModifiableParameter(const char* paramName, const char* paramType, const char* requestType) throw() :
982  BaseException()
983  {
984  strncpy(m_paramName, paramName, 256);
985  m_paramName[255] = '\0';
986  strncpy(m_paramType, paramType, 256);
987  m_paramType[255] = '\0';
988  strncpy(m_requestType, requestType, 256);
989  m_requestType[255] = '\0';
990  sprintf(m_errorMessage, "Type mismatch on setting/getting parameter \"%s\" - expected \"%s\" - requested \"%s\"", m_paramName, m_paramType, m_requestType);
991  m_errorMessage[1023] = '\0';
992  }
993 
1000  BaseException(other)
1001  {
1002  strncpy(m_paramName, other.m_paramName, 256);
1003  m_paramName[255] = '\0';
1004  strncpy(m_paramType, other.m_paramType, 256);
1005  m_paramType[255] = '\0';
1006  strncpy(m_requestType, other.m_requestType, 256);
1007  m_requestType[255] = '\0';
1008  strncpy(m_errorMessage, other.m_errorMessage, 1024);
1009  m_errorMessage[1023] = '\0';
1010  }
1011 
1018  {
1019  if (&other == this) {
1020  return *this;
1021  }
1022 
1023  BaseException::operator=(other);
1024  strncpy(m_paramName, other.m_paramName, 256);
1025  m_paramName[255] = '\0';
1026  strncpy(m_paramType, other.m_paramType, 256);
1027  m_paramType[255] = '\0';
1028  strncpy(m_requestType, other.m_requestType, 256);
1029  m_requestType[255] = '\0';
1030  strncpy(m_errorMessage, other.m_errorMessage, 1024);
1031  m_errorMessage[1023] = '\0';
1032 
1033  return *this;
1034  }
1035 
1040  {
1041  }
1042 
1048  virtual const char *what() const throw()
1049  {
1050  return m_errorMessage;
1051  }
1052 
1058  const char *paramName() const throw()
1059  {
1060  return m_paramName;
1061  }
1062 
1068  const char *paramType() const throw()
1069  {
1070  return m_paramType;
1071  }
1072 
1078  const char *requestType() const throw()
1079  {
1080  return m_requestType;
1081  }
1082 
1087  EXCEPTION_HELPER_FUNCTIONS(TypeMismatchOnSettingRuntimeModifiableParameter)
1088 
1089 private:
1093  char m_paramName[256];
1094 
1098  char m_paramType[256];
1099 
1103  char m_requestType[256];
1104 
1108  char m_errorMessage[1024];
1109 };
1110 
1119 class FARSA_CONF_TEMPLATE UserDefinedCheckFailureException : public BaseException
1120 {
1121 public:
1135  UserDefinedCheckFailureException(const char* paramName, const char* paramValue, const char* description) throw() :
1136  BaseException()
1137  {
1138  strncpy(m_paramName, paramName, 256);
1139  m_paramName[255] = '\0';
1140  strncpy(m_paramValue, paramValue, 256);
1141  m_paramValue[255] = '\0';
1142  strncpy(m_description, description, 256);
1143  m_description[255] = '\0';
1144  sprintf(m_errorMessage, "User check failed on parameter \"%s\" - parameter value: \"%s\" - error description: %s", m_paramName, m_paramValue, m_description);
1145  m_errorMessage[1023] = '\0';
1146  }
1147 
1154  BaseException(other)
1155  {
1156  strncpy(m_paramName, other.m_paramName, 256);
1157  m_paramName[255] = '\0';
1158  strncpy(m_paramValue, other.m_paramValue, 256);
1159  m_paramValue[255] = '\0';
1160  strncpy(m_description, other.m_description, 256);
1161  m_description[255] = '\0';
1162  strncpy(m_errorMessage, other.m_errorMessage, 1024);
1163  m_errorMessage[1023] = '\0';
1164  }
1165 
1172  {
1173  if (&other == this) {
1174  return *this;
1175  }
1176 
1177  BaseException::operator=(other);
1178  strncpy(m_paramName, other.m_paramName, 256);
1179  m_paramName[255] = '\0';
1180  strncpy(m_paramValue, other.m_paramValue, 256);
1181  m_paramValue[255] = '\0';
1182  strncpy(m_description, other.m_description, 256);
1183  m_description[255] = '\0';
1184  strncpy(m_errorMessage, other.m_errorMessage, 1024);
1185  m_errorMessage[1023] = '\0';
1186 
1187  return *this;
1188  }
1189 
1194  {
1195  }
1196 
1202  virtual const char *what() const throw()
1203  {
1204  return m_errorMessage;
1205  }
1206 
1212  const char *paramName() const throw()
1213  {
1214  return m_paramName;
1215  }
1216 
1222  const char *paramValue() const throw()
1223  {
1224  return m_paramValue;
1225  }
1226 
1232  const char *description() const throw()
1233  {
1234  return m_description;
1235  }
1236 
1241  EXCEPTION_HELPER_FUNCTIONS(UserDefinedCheckFailureException)
1242 
1243 private:
1247  char m_paramName[256];
1248 
1252  char m_paramValue[256];
1253 
1257  char m_description[256];
1258 
1262  char m_errorMessage[1024];
1263 };
1264 
1268 class FARSA_CONF_TEMPLATE ResourceNotDeclaredException : public BaseException
1269 {
1270 public:
1278  ResourceNotDeclaredException(const char* resourceName) throw() :
1279  BaseException()
1280  {
1281  strncpy(m_resourceName, resourceName, 256);
1282  m_resourceName[255] = '\0';
1283  sprintf(m_errorMessage, "No resource declared with name \"%s\"", m_resourceName);
1284  m_errorMessage[511] = '\0';
1285  }
1286 
1293  BaseException(other)
1294  {
1295  strncpy(m_resourceName, other.m_resourceName, 256);
1296  m_resourceName[255] = '\0';
1297  strncpy(m_errorMessage, other.m_errorMessage, 512);
1298  m_errorMessage[511] = '\0';
1299  }
1300 
1307  {
1308  if (&other == this) {
1309  return *this;
1310  }
1311 
1312  BaseException::operator=(other);
1313  strncpy(m_resourceName, other.m_resourceName, 256);
1314  m_resourceName[255] = '\0';
1315  strncpy(m_errorMessage, other.m_errorMessage, 512);
1316  m_errorMessage[511] = '\0';
1317 
1318  return *this;
1319  }
1320 
1325  {
1326  }
1327 
1333  virtual const char *what() const throw()
1334  {
1335  return m_errorMessage;
1336  }
1337 
1343  const char *resourceName() const throw()
1344  {
1345  return m_resourceName;
1346  }
1347 
1352  EXCEPTION_HELPER_FUNCTIONS(ResourceNotDeclaredException)
1353 
1354 private:
1358  char m_resourceName[256];
1359 
1363  char m_errorMessage[512];
1364 };
1365 
1373 class FARSA_CONF_TEMPLATE ResourceNotUsableException : public BaseException
1374 {
1375 public:
1383  ResourceNotUsableException(const char* resourceName) throw() :
1384  BaseException()
1385  {
1386  strncpy(m_resourceName, resourceName, 256);
1387  m_resourceName[255] = '\0';
1388  sprintf(m_errorMessage, "The resource named \"%s\" was not declared as usable before being used", m_resourceName);
1389  m_errorMessage[511] = '\0';
1390  }
1391 
1398  BaseException(other)
1399  {
1400  strncpy(m_resourceName, other.m_resourceName, 256);
1401  m_resourceName[255] = '\0';
1402  strncpy(m_errorMessage, other.m_errorMessage, 512);
1403  m_errorMessage[511] = '\0';
1404  }
1405 
1412  {
1413  if (&other == this) {
1414  return *this;
1415  }
1416 
1417  BaseException::operator=(other);
1418  strncpy(m_resourceName, other.m_resourceName, 256);
1419  m_resourceName[255] = '\0';
1420  strncpy(m_errorMessage, other.m_errorMessage, 512);
1421  m_errorMessage[511] = '\0';
1422 
1423  return *this;
1424  }
1425 
1430  {
1431  }
1432 
1438  virtual const char *what() const throw()
1439  {
1440  return m_errorMessage;
1441  }
1442 
1448  const char *resourceName() const throw()
1449  {
1450  return m_resourceName;
1451  }
1452 
1457  EXCEPTION_HELPER_FUNCTIONS(ResourceNotUsableException)
1458 
1459 private:
1463  char m_resourceName[256];
1464 
1468  char m_errorMessage[512];
1469 };
1470 
1475 class FARSA_CONF_TEMPLATE ResourceTypeMismatchException : public BaseException
1476 {
1477 public:
1488  ResourceTypeMismatchException(const char* resourceName, const char* typeName) throw() :
1489  BaseException()
1490  {
1491  strncpy(m_resourceName, resourceName, 256);
1492  m_resourceName[255] = '\0';
1493  strncpy(m_typeName, typeName, 256);
1494  m_typeName[255] = '\0';
1495  sprintf(m_errorMessage, "Wrong type when requesting a resource; The type of the resource \"%s\" is not \"%s\"", m_resourceName, m_typeName);
1496  m_errorMessage[1023] = '\0';
1497  }
1498 
1505  BaseException(other)
1506  {
1507  strncpy(m_resourceName, other.m_resourceName, 256);
1508  m_resourceName[255] = '\0';
1509  strncpy(m_typeName, other.m_typeName, 256);
1510  m_typeName[255] = '\0';
1511  strncpy(m_errorMessage, other.m_errorMessage, 1024);
1512  m_errorMessage[1023] = '\0';
1513  }
1514 
1521  {
1522  if (&other == this) {
1523  return *this;
1524  }
1525 
1526  BaseException::operator=(other);
1527  strncpy(m_resourceName, other.m_resourceName, 256);
1528  m_resourceName[255] = '\0';
1529  strncpy(m_typeName, other.m_typeName, 256);
1530  m_typeName[255] = '\0';
1531  strncpy(m_errorMessage, other.m_errorMessage, 1024);
1532  m_errorMessage[1023] = '\0';
1533 
1534  return *this;
1535  }
1536 
1541  {
1542  }
1543 
1549  virtual const char *what() const throw()
1550  {
1551  return m_errorMessage;
1552  }
1553 
1559  const char *resourceName() const throw()
1560  {
1561  return m_resourceName;
1562  }
1563 
1569  const char *typeName() const throw()
1570  {
1571  return m_typeName;
1572  }
1573 
1578  EXCEPTION_HELPER_FUNCTIONS(ResourceTypeMismatchException)
1579 
1580 private:
1584  char m_resourceName[256];
1585 
1589  char m_typeName[256];
1590 
1594  char m_errorMessage[1024];
1595 };
1596 
1606 class FARSA_CONF_TEMPLATE UserRequiredResourceMissingException : public BaseException
1607 {
1608 public:
1619  UserRequiredResourceMissingException(const char* resourceName, const char* description) throw() :
1620  BaseException()
1621  {
1622  strncpy(m_resourceName, resourceName, 256);
1623  m_resourceName[255] = '\0';
1624  strncpy(m_description, description, 256);
1625  m_description[255] = '\0';
1626  sprintf(m_errorMessage, "The user requested a resource named \"%s\" which cannot be found. Error description: %s", m_resourceName, m_description);
1627  m_errorMessage[1023] = '\0';
1628  }
1629 
1636  BaseException(other)
1637  {
1638  strncpy(m_resourceName, other.m_resourceName, 256);
1639  m_resourceName[255] = '\0';
1640  strncpy(m_description, other.m_description, 256);
1641  m_description[255] = '\0';
1642  strncpy(m_errorMessage, other.m_errorMessage, 1024);
1643  m_errorMessage[1023] = '\0';
1644  }
1645 
1652  {
1653  if (&other == this) {
1654  return *this;
1655  }
1656 
1657  BaseException::operator=(other);
1658  strncpy(m_resourceName, other.m_resourceName, 256);
1659  m_resourceName[255] = '\0';
1660  strncpy(m_description, other.m_description, 256);
1661  m_description[255] = '\0';
1662  strncpy(m_errorMessage, other.m_errorMessage, 1024);
1663  m_errorMessage[1023] = '\0';
1664 
1665  return *this;
1666  }
1667 
1672  {
1673  }
1674 
1680  virtual const char *what() const throw()
1681  {
1682  return m_errorMessage;
1683  }
1684 
1690  const char *resourceName() const throw()
1691  {
1692  return m_resourceName;
1693  }
1694 
1700  const char *description() const throw()
1701  {
1702  return m_description;
1703  }
1704 
1709  EXCEPTION_HELPER_FUNCTIONS(UserRequiredResourceMissingException)
1710 
1711 private:
1715  char m_resourceName[256];
1716 
1720  char m_description[256];
1721 
1725  char m_errorMessage[1024];
1726 };
1727 
1733 class FARSA_CONF_TEMPLATE WrongResourceLockStatusForOperation : public BaseException
1734 {
1735 public:
1747  WrongResourceLockStatusForOperation(const char* operationName, bool lockStatusLocked) throw() :
1748  BaseException(),
1749  m_lockStatusLocked(lockStatusLocked)
1750  {
1751  strncpy(m_operationName, operationName, 256);
1752  m_operationName[255] = '\0';
1753  sprintf(m_errorMessage, "The operation \"%s\" could not be performed because the lock on resources %s but it %s have been", m_operationName, (m_lockStatusLocked ? "was held" : "wasn't held"), (m_lockStatusLocked ? "shouldn't" : "should"));
1754  m_errorMessage[511] = '\0';
1755  }
1756 
1763  BaseException(other),
1764  m_lockStatusLocked(other.m_lockStatusLocked)
1765  {
1766  strncpy(m_operationName, other.m_operationName, 256);
1767  m_operationName[255] = '\0';
1768  strncpy(m_errorMessage, other.m_errorMessage, 512);
1769  m_errorMessage[511] = '\0';
1770  }
1771 
1778  {
1779  if (&other == this) {
1780  return *this;
1781  }
1782 
1783  BaseException::operator=(other);
1784  m_lockStatusLocked = other.m_lockStatusLocked;
1785  strncpy(m_operationName, other.m_operationName, 256);
1786  m_operationName[255] = '\0';
1787  strncpy(m_errorMessage, other.m_errorMessage, 512);
1788  m_errorMessage[511] = '\0';
1789 
1790  return *this;
1791  }
1792 
1797  {
1798  }
1799 
1805  virtual const char *what() const throw()
1806  {
1807  return m_errorMessage;
1808  }
1809 
1816  bool lockStatusLocked() const throw()
1817  {
1818  return m_lockStatusLocked;
1819  }
1820 
1826  const char *operationName() const throw()
1827  {
1828  return m_operationName;
1829  }
1830 
1835  EXCEPTION_HELPER_FUNCTIONS(WrongResourceLockStatusForOperation)
1836 
1837 private:
1842  bool m_lockStatusLocked;
1843 
1847  char m_operationName[256];
1848 
1852  char m_errorMessage[512];
1853 };
1854 
1855 } // end namespace farsa
1856 
1857 // All the suff below is to restore the warning state on Windows
1858 #if defined(_MSC_VER)
1859  #pragma warning(pop)
1860 #endif
1861 
1862 #endif
UserDefinedCheckFailureException(const char *paramName, const char *paramValue, const char *description)
Constructor.
const char * resourceName() const
Returns the name of the resource not declared as usable.
const char * className() const
Returns the name of the class that couldn't be found.
PrefixNotGroupException(const char *prefix)
Constructor.
The exception thrown when casting an ParameterSettable object to the requested type fails...
const char * groupName() const
Returns the name of the group in which the cycle has been discovered.
CopyDuringObjectCreationException(const CopyDuringObjectCreationException &other)
Copy constructor.
virtual ~CyclicDependencyException()
Destructor.
const char * groupName() const
Returns the name of the class that couldn't be found.
const char * paramType() const
Returns the expected type of the parameter.
CannotFindTypeParameterException(const CannotFindTypeParameterException &other)
Copy constructor.
NoRuntimeModifiableParameter & operator=(const NoRuntimeModifiableParameter &other)
Copy operator.
The exception thrown when requesting a resource that hasn't been declared as usable.
The exception thrown when a resource has different type from requested type.
ClassNameIsAbstractException & operator=(const ClassNameIsAbstractException &other)
Copy operator.
virtual const char * what() const
Returns a C string describing the exception.
const char * paramName() const
Returns the name of the parameter that couldn't be found.
TypeMismatchOnSettingRuntimeModifiableParameter & operator=(const TypeMismatchOnSettingRuntimeModifiableParameter &other)
Copy operator.
ClassNameNotRegisteredException(const char *className)
Constructor.
ClassNameNotRegisteredException & operator=(const ClassNameNotRegisteredException &other)
Copy operator.
ClassNameNotRegisteredException(const ClassNameNotRegisteredException &other)
Copy constructor.
The exception thrown when a cyclic dependency is discovered during object creation using the Configur...
NoRuntimeModifiableParameter(const char *paramName)
Constructor.
virtual const char * what() const
Returns a C string describing the exception.
WrongResourceLockStatusForOperation(const WrongResourceLockStatusForOperation &other)
Copy constructor.
const char * resourceName() const
Returns the name of the resource that couldn't be found.
const char * paramName() const
Returns the name of the parameter.
virtual const char * what() const
Returns a C string describing the exception.
CopyDuringObjectCreationException & operator=(const CopyDuringObjectCreationException &other)
Copy operator.
TypeMismatchOnSettingRuntimeModifiableParameter(const TypeMismatchOnSettingRuntimeModifiableParameter &other)
Copy constructor.
virtual const char * what() const
Returns a C string describing the exception.
The exception thrown when requested class name is registered but cannot be created because it is abst...
OtherObjectBeingCreatedException(const char *groupName)
Constructor.
CannotFindTypeParameterException & operator=(const CannotFindTypeParameterException &other)
Copy operator.
UserRequiredResourceMissingException & operator=(const UserRequiredResourceMissingException &other)
Copy operator.
The exception to throw when a user check on a parameter fails.
The exception thrown when requesting a resource never declared.
const char * operationName() const
Returns the name of the operation that couldn't be perfomed.
UserRequiredResourceMissingException(const UserRequiredResourceMissingException &other)
Copy constructor.
ResourceTypeMismatchException(const ResourceTypeMismatchException &other)
Copy constructor.
ResourceNotUsableException(const ResourceNotUsableException &other)
Copy constructor.
virtual const char * what() const
Returns a C string describing the exception.
ClassNameIsAbstractException(const ClassNameIsAbstractException &other)
Copy constructor.
OtherObjectBeingCreatedException(const OtherObjectBeingCreatedException &other)
Copy constructor.
UserDefinedCheckFailureException(const UserDefinedCheckFailureException &other)
Copy constructor.
const char * typeName() const
Returns the type name of the resource.
The exception thrown when requested class name is not registered with the factory.
const char * className() const
Returns the name of the class that couldn't be found.
CyclicDependencyException(const char *groupName)
Constructor.
ResourceNotDeclaredException(const char *resourceName)
Constructor.
WrongResourceLockStatusForOperation & operator=(const WrongResourceLockStatusForOperation &other)
Copy operator.
The exception thrown when the user requests a new object for a group but there is another object for ...
const char * paramName() const
Returns the name of the parameter.
virtual const char * what() const
Returns a C string describing the exception.
UserRequiredResourceMissingException(const char *resourceName, const char *description)
Constructor.
virtual const char * what() const
Returns a C string describing the exception.
const char * groupName() const
Returns the name of the group in which the cycle has been discovered.
bool lockStatusLocked() const
Returns the lock status when the exception was thrown.
virtual const char * what() const
Returns a C string describing the exception.
CannotConvertToTypeException & operator=(const CannotConvertToTypeException &other)
Copy operator.
ClassNameIsAbstractException(const char *className)
Constructor.
The exception thrown when an operation is performed on a ConcurrentResourcesUser object but the lock ...
CannotConvertToTypeException(const char *className, const std::type_info &destTypeId)
Constructor.
virtual const char * what() const
Returns a C string describing the exception.
const char * resourceName() const
Returns the name of the resource.
ResourceNotUsableException(const char *resourceName)
Constructor.
ResourceNotUsableException & operator=(const ResourceNotUsableException &other)
Copy operator.
PrefixNotGroupException & operator=(const PrefixNotGroupException &other)
Copy operator.
const char * description() const
Returns the error description.
The exception to throw when a user needs a resouce during configuration which doesn't exist...
ResourceTypeMismatchException(const char *resourceName, const char *typeName)
Constructor.
CannotFindTypeParameterException(const char *groupName)
Constructor.
virtual const char * what() const
Returns a C string describing the exception.
virtual const char * what() const
Returns a C string describing the exception.
OtherObjectBeingCreatedException & operator=(const OtherObjectBeingCreatedException &other)
Copy operator.
const char * prefix() const
Returns the prefix that we expected to be a group but is not.
NoRuntimeModifiableParameter(const NoRuntimeModifiableParameter &other)
Copy constructor.
The exception thrown when trying to create an object from a using a prefi that is not a group...
const char * requestType() const
Returns the requested type.
virtual const char * what() const
Returns a C string describing the exception.
ResourceTypeMismatchException & operator=(const ResourceTypeMismatchException &other)
Copy operator.
The exception thrown when the type mismatch on the requested runtime modification of a parameter...
The exception thrown when requested to create an object from a group and the "type" parameter is not ...
virtual const char * what() const
Returns a C string describing the exception.
const std::type_info & destTypeName() const
Returns the type_info of the type to which the new object should have been converted.
const char * resourceName() const
Returns the name of the resource.
ResourceNotDeclaredException(const ResourceNotDeclaredException &other)
Copy constructor.
TypeMismatchOnSettingRuntimeModifiableParameter(const char *paramName, const char *paramType, const char *requestType)
Constructor.
const char * description() const
Returns the error description.
virtual ~PrefixNotGroupException()
Destructor.
const char * paramValue() const
Returns the value of the parameter.
UserDefinedCheckFailureException & operator=(const UserDefinedCheckFailureException &other)
Copy operator.
virtual const char * what() const
Returns a C string describing the exception.
const char * className() const
Returns the name of the class that couldn't be found.
CannotConvertToTypeException(const CannotConvertToTypeException &other)
Copy constructor.
ResourceNotDeclaredException & operator=(const ResourceNotDeclaredException &other)
Copy operator.
PrefixNotGroupException(const PrefixNotGroupException &other)
Copy constructor.
The exception thrown when trying to copy a ConfigurationParameter.
CyclicDependencyException & operator=(const CyclicDependencyException &other)
Copy operator.
WrongResourceLockStatusForOperation(const char *operationName, bool lockStatusLocked)
Constructor.
virtual const char * what() const
Returns a C string describing the exception.
CyclicDependencyException(const CyclicDependencyException &other)
Copy constructor.
virtual const char * what() const
Returns a C string describing the exception.
The exception thrown when requested a runtime modification of a parameter not marked as runtime modif...