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 CannotConvertToTypeException : public BaseException
151 {
152 public:
160  CannotConvertToTypeException(const char* className, const std::type_info& destTypeId) throw() :
161  BaseException(),
162  m_destTypeId(&destTypeId)
163  {
164  strncpy(m_className, className, 256);
165  m_className[255] = '\0';
166  // This is to be absolutely sure there is no buffer overflow
167  char tmp[256];
168  strncpy(tmp, m_destTypeId->name(), 256);
169  tmp[255] = '\0';
170  sprintf(m_errorMessage, "Impossible to convert object of type \"%s\" to type \"%s\"", m_className, tmp);
171  m_errorMessage[1023] = '\0';
172  }
173 
180  BaseException(other),
181  m_destTypeId(other.m_destTypeId)
182  {
183  strncpy(m_className, other.m_className, 256);
184  m_className[255] = '\0';
185  strncpy(m_errorMessage, other.m_errorMessage, 1024);
186  m_errorMessage[1023] = '\0';
187  }
188 
195  {
196  if (&other == this) {
197  return *this;
198  }
199 
200  BaseException::operator=(other);
201  strncpy(m_className, other.m_className, 256);
202  m_className[255] = '\0';
203  m_destTypeId = other.m_destTypeId;
204  strncpy(m_errorMessage, other.m_errorMessage, 1024);
205  m_errorMessage[1023] = '\0';
206 
207  return *this;
208  }
209 
213  virtual ~CannotConvertToTypeException() throw()
214  {
215  }
216 
222  virtual const char *what() const throw()
223  {
224  return m_errorMessage;
225  }
226 
232  const char *className() const throw()
233  {
234  return m_className;
235  }
236 
244  const std::type_info& destTypeName() const throw()
245  {
246  return *m_destTypeId;
247  }
248 
253  EXCEPTION_HELPER_FUNCTIONS(CannotConvertToTypeException)
254 
255 private:
259  char m_className[256];
260 
265  const std::type_info* m_destTypeId;
266 
270  char m_errorMessage[1024];
271 };
272 
277 class FARSA_CONF_TEMPLATE CannotFindTypeParameterException : public BaseException
278 {
279 public:
286  CannotFindTypeParameterException(const char* groupName) throw() :
287  BaseException()
288  {
289  strncpy(m_groupName, groupName, 256);
290  m_groupName[255] = '\0';
291  sprintf(m_errorMessage, "No \"type\" parameter in the given parameter object under the \"%s\" group", m_groupName);
292  m_errorMessage[511] = '\0';
293  }
294 
301  BaseException(other)
302  {
303  strncpy(m_groupName, other.m_groupName, 256);
304  m_groupName[255] = '\0';
305  strncpy(m_errorMessage, other.m_errorMessage, 512);
306  m_errorMessage[511] = '\0';
307  }
308 
315  {
316  if (&other == this) {
317  return *this;
318  }
319 
320  BaseException::operator=(other);
321  strncpy(m_groupName, other.m_groupName, 256);
322  m_groupName[255] = '\0';
323  strncpy(m_errorMessage, other.m_errorMessage, 512);
324  m_errorMessage[511] = '\0';
325 
326  return *this;
327  }
328 
333  {
334  }
335 
341  virtual const char *what() const throw()
342  {
343  return m_errorMessage;
344  }
345 
351  const char *groupName() const throw()
352  {
353  return m_groupName;
354  }
355 
360  EXCEPTION_HELPER_FUNCTIONS(CannotFindTypeParameterException)
361 
362 private:
367  char m_groupName[256];
368 
372  char m_errorMessage[512];
373 };
374 
379 class FARSA_CONF_TEMPLATE PrefixNotGroupException : public BaseException
380 {
381 public:
387  PrefixNotGroupException(const char* prefix) throw() :
388  BaseException()
389  {
390  strncpy(m_prefix, prefix, 256);
391  m_prefix[255] = '\0';
392  sprintf(m_errorMessage, "The provided prefix (\"%s\") is not a group name, cannot ceate object", m_prefix);
393  m_errorMessage[511] = '\0';
394  }
395 
402  BaseException(other)
403  {
404  strncpy(m_prefix, other.m_prefix, 256);
405  m_prefix[255] = '\0';
406  strncpy(m_errorMessage, other.m_errorMessage, 512);
407  m_errorMessage[511] = '\0';
408  }
409 
415  PrefixNotGroupException& operator=(const PrefixNotGroupException& other) throw()
416  {
417  if (&other == this) {
418  return *this;
419  }
420 
421  BaseException::operator=(other);
422  strncpy(m_prefix, other.m_prefix, 256);
423  m_prefix[255] = '\0';
424  strncpy(m_errorMessage, other.m_errorMessage, 512);
425  m_errorMessage[511] = '\0';
426 
427  return *this;
428  }
429 
433  virtual ~PrefixNotGroupException() throw()
434  {
435  }
436 
442  virtual const char *what() const throw()
443  {
444  return m_errorMessage;
445  }
446 
452  const char *prefix() const throw()
453  {
454  return m_prefix;
455  }
456 
461  EXCEPTION_HELPER_FUNCTIONS(PrefixNotGroupException)
462 
463 private:
467  char m_prefix[256];
468 
472  char m_errorMessage[512];
473 };
474 
479 class FARSA_CONF_TEMPLATE CyclicDependencyException : public BaseException
480 {
481 public:
489  CyclicDependencyException(const char* groupName) throw() :
490  BaseException()
491  {
492  strncpy(m_groupName, groupName, 256);
493  m_groupName[255] = '\0';
494  sprintf(m_errorMessage, "Cyclic dependency discovered when creating/configuring object for group \"%s\"", m_groupName);
495  m_errorMessage[511] = '\0';
496  }
497 
504  BaseException(other)
505  {
506  strncpy(m_groupName, other.m_groupName, 256);
507  m_groupName[255] = '\0';
508  strncpy(m_errorMessage, other.m_errorMessage, 512);
509  m_errorMessage[511] = '\0';
510  }
511 
517  CyclicDependencyException& operator=(const CyclicDependencyException& other) throw()
518  {
519  if (&other == this) {
520  return *this;
521  }
522 
523  BaseException::operator=(other);
524  strncpy(m_groupName, other.m_groupName, 256);
525  m_groupName[255] = '\0';
526  strncpy(m_errorMessage, other.m_errorMessage, 512);
527  m_errorMessage[511] = '\0';
528 
529  return *this;
530  }
531 
535  virtual ~CyclicDependencyException() throw()
536  {
537  }
538 
544  virtual const char *what() const throw()
545  {
546  return m_errorMessage;
547  }
548 
555  const char *groupName() const throw()
556  {
557  return m_groupName;
558  }
559 
564  EXCEPTION_HELPER_FUNCTIONS(CyclicDependencyException)
565 
566 private:
570  char m_groupName[256];
571 
575  char m_errorMessage[512];
576 };
577 
581 class FARSA_CONF_TEMPLATE CopyDuringObjectCreationException : public BaseException
582 {
583 public:
588  BaseException()
589  {
590  sprintf(m_errorMessage, "Trying to perform a copy of ConfigurationParameter objects during calls to getObjectFromGroup");
591  m_errorMessage[255] = '\0';
592  }
593 
600  BaseException(other)
601  {
602  strncpy(m_errorMessage, other.m_errorMessage, 256);
603  m_errorMessage[255] = '\0';
604  }
605 
612  {
613  if (&other == this) {
614  return *this;
615  }
616 
617  BaseException::operator=(other);
618  strncpy(m_errorMessage, other.m_errorMessage, 256);
619  m_errorMessage[255] = '\0';
620 
621  return *this;
622  }
623 
628  {
629  }
630 
636  virtual const char *what() const throw()
637  {
638  return m_errorMessage;
639  }
640 
645  EXCEPTION_HELPER_FUNCTIONS(CopyDuringObjectCreationException)
646 
647 private:
651  char m_errorMessage[256];
652 };
653 
659 class FARSA_CONF_TEMPLATE OtherObjectBeingCreatedException : public BaseException
660 {
661 public:
670  OtherObjectBeingCreatedException(const char* groupName) throw() :
671  BaseException()
672  {
673  strncpy(m_groupName, groupName, 256);
674  m_groupName[255] = '\0';
675  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);
676  m_errorMessage[511] = '\0';
677  }
678 
685  BaseException(other)
686  {
687  strncpy(m_groupName, other.m_groupName, 256);
688  m_groupName[255] = '\0';
689  strncpy(m_errorMessage, other.m_errorMessage, 512);
690  m_errorMessage[511] = '\0';
691  }
692 
699  {
700  if (&other == this) {
701  return *this;
702  }
703 
704  BaseException::operator=(other);
705  strncpy(m_groupName, other.m_groupName, 256);
706  m_groupName[255] = '\0';
707  strncpy(m_errorMessage, other.m_errorMessage, 512);
708  m_errorMessage[511] = '\0';
709 
710  return *this;
711  }
712 
717  {
718  }
719 
725  virtual const char *what() const throw()
726  {
727  return m_errorMessage;
728  }
729 
736  const char *groupName() const throw()
737  {
738  return m_groupName;
739  }
740 
745  EXCEPTION_HELPER_FUNCTIONS(OtherObjectBeingCreatedException)
746 
747 private:
751  char m_groupName[256];
752 
756  char m_errorMessage[512];
757 };
758 
763 class FARSA_CONF_TEMPLATE NoRuntimeModifiableParameter : public BaseException
764 {
765 public:
773  NoRuntimeModifiableParameter(const char* paramName) throw() :
774  BaseException()
775  {
776  strncpy(m_paramName, paramName, 256);
777  m_paramName[255] = '\0';
778  sprintf(m_errorMessage, "The parameter \"%s\" is not marked as runtime modifiable", m_paramName);
779  m_errorMessage[511] = '\0';
780  }
781 
788  BaseException(other)
789  {
790  strncpy(m_paramName, other.m_paramName, 256);
791  m_paramName[255] = '\0';
792  strncpy(m_errorMessage, other.m_errorMessage, 512);
793  m_errorMessage[511] = '\0';
794  }
795 
802  {
803  if (&other == this) {
804  return *this;
805  }
806 
807  BaseException::operator=(other);
808  strncpy(m_paramName, other.m_paramName, 256);
809  m_paramName[255] = '\0';
810  strncpy(m_errorMessage, other.m_errorMessage, 512);
811  m_errorMessage[511] = '\0';
812 
813  return *this;
814  }
815 
819  virtual ~NoRuntimeModifiableParameter() throw()
820  {
821  }
822 
828  virtual const char *what() const throw()
829  {
830  return m_errorMessage;
831  }
832 
838  const char *paramName() const throw()
839  {
840  return m_paramName;
841  }
842 
847  EXCEPTION_HELPER_FUNCTIONS(NoRuntimeModifiableParameter)
848 
849 private:
853  char m_paramName[256];
854 
858  char m_errorMessage[512];
859 };
860 
865 class FARSA_CONF_TEMPLATE TypeMismatchOnSettingRuntimeModifiableParameter : public BaseException
866 {
867 public:
879  TypeMismatchOnSettingRuntimeModifiableParameter(const char* paramName, const char* paramType, const char* requestType) throw() :
880  BaseException()
881  {
882  strncpy(m_paramName, paramName, 256);
883  m_paramName[255] = '\0';
884  strncpy(m_paramType, paramType, 256);
885  m_paramType[255] = '\0';
886  strncpy(m_requestType, requestType, 256);
887  m_requestType[255] = '\0';
888  sprintf(m_errorMessage, "Type mismatch on setting/getting parameter \"%s\" - expected \"%s\" - requested \"%s\"", m_paramName, m_paramType, m_requestType);
889  m_errorMessage[1023] = '\0';
890  }
891 
898  BaseException(other)
899  {
900  strncpy(m_paramName, other.m_paramName, 256);
901  m_paramName[255] = '\0';
902  strncpy(m_paramType, other.m_paramType, 256);
903  m_paramType[255] = '\0';
904  strncpy(m_requestType, other.m_requestType, 256);
905  m_requestType[255] = '\0';
906  strncpy(m_errorMessage, other.m_errorMessage, 1024);
907  m_errorMessage[1023] = '\0';
908  }
909 
916  {
917  if (&other == this) {
918  return *this;
919  }
920 
921  BaseException::operator=(other);
922  strncpy(m_paramName, other.m_paramName, 256);
923  m_paramName[255] = '\0';
924  strncpy(m_paramType, other.m_paramType, 256);
925  m_paramType[255] = '\0';
926  strncpy(m_requestType, other.m_requestType, 256);
927  m_requestType[255] = '\0';
928  strncpy(m_errorMessage, other.m_errorMessage, 1024);
929  m_errorMessage[1023] = '\0';
930 
931  return *this;
932  }
933 
938  {
939  }
940 
946  virtual const char *what() const throw()
947  {
948  return m_errorMessage;
949  }
950 
956  const char *paramName() const throw()
957  {
958  return m_paramName;
959  }
960 
966  const char *paramType() const throw()
967  {
968  return m_paramType;
969  }
970 
976  const char *requestType() const throw()
977  {
978  return m_requestType;
979  }
980 
985  EXCEPTION_HELPER_FUNCTIONS(TypeMismatchOnSettingRuntimeModifiableParameter)
986 
987 private:
991  char m_paramName[256];
992 
996  char m_paramType[256];
997 
1001  char m_requestType[256];
1002 
1006  char m_errorMessage[1024];
1007 };
1008 
1017 class FARSA_CONF_TEMPLATE UserDefinedCheckFailureException : public BaseException
1018 {
1019 public:
1033  UserDefinedCheckFailureException(const char* paramName, const char* paramValue, const char* description) throw() :
1034  BaseException()
1035  {
1036  strncpy(m_paramName, paramName, 256);
1037  m_paramName[255] = '\0';
1038  strncpy(m_paramValue, paramValue, 256);
1039  m_paramValue[255] = '\0';
1040  strncpy(m_description, description, 256);
1041  m_description[255] = '\0';
1042  sprintf(m_errorMessage, "User check failed on parameter \"%s\" - parameter value: \"%s\" - error description: %s", m_paramName, m_paramValue, m_description);
1043  m_errorMessage[1023] = '\0';
1044  }
1045 
1052  BaseException(other)
1053  {
1054  strncpy(m_paramName, other.m_paramName, 256);
1055  m_paramName[255] = '\0';
1056  strncpy(m_paramValue, other.m_paramValue, 256);
1057  m_paramValue[255] = '\0';
1058  strncpy(m_description, other.m_description, 256);
1059  m_description[255] = '\0';
1060  strncpy(m_errorMessage, other.m_errorMessage, 1024);
1061  m_errorMessage[1023] = '\0';
1062  }
1063 
1070  {
1071  if (&other == this) {
1072  return *this;
1073  }
1074 
1075  BaseException::operator=(other);
1076  strncpy(m_paramName, other.m_paramName, 256);
1077  m_paramName[255] = '\0';
1078  strncpy(m_paramValue, other.m_paramValue, 256);
1079  m_paramValue[255] = '\0';
1080  strncpy(m_description, other.m_description, 256);
1081  m_description[255] = '\0';
1082  strncpy(m_errorMessage, other.m_errorMessage, 1024);
1083  m_errorMessage[1023] = '\0';
1084 
1085  return *this;
1086  }
1087 
1092  {
1093  }
1094 
1100  virtual const char *what() const throw()
1101  {
1102  return m_errorMessage;
1103  }
1104 
1110  const char *paramName() const throw()
1111  {
1112  return m_paramName;
1113  }
1114 
1120  const char *paramValue() const throw()
1121  {
1122  return m_paramValue;
1123  }
1124 
1130  const char *description() const throw()
1131  {
1132  return m_description;
1133  }
1134 
1139  EXCEPTION_HELPER_FUNCTIONS(UserDefinedCheckFailureException)
1140 
1141 private:
1145  char m_paramName[256];
1146 
1150  char m_paramValue[256];
1151 
1155  char m_description[256];
1156 
1160  char m_errorMessage[1024];
1161 };
1162 
1166 class FARSA_CONF_TEMPLATE ResourceNotDeclaredException : public BaseException
1167 {
1168 public:
1176  ResourceNotDeclaredException(const char* resourceName) throw() :
1177  BaseException()
1178  {
1179  strncpy(m_resourceName, resourceName, 256);
1180  m_resourceName[255] = '\0';
1181  sprintf(m_errorMessage, "No resource declared with name \"%s\"", m_resourceName);
1182  m_errorMessage[511] = '\0';
1183  }
1184 
1191  BaseException(other)
1192  {
1193  strncpy(m_resourceName, other.m_resourceName, 256);
1194  m_resourceName[255] = '\0';
1195  strncpy(m_errorMessage, other.m_errorMessage, 512);
1196  m_errorMessage[511] = '\0';
1197  }
1198 
1205  {
1206  if (&other == this) {
1207  return *this;
1208  }
1209 
1210  BaseException::operator=(other);
1211  strncpy(m_resourceName, other.m_resourceName, 256);
1212  m_resourceName[255] = '\0';
1213  strncpy(m_errorMessage, other.m_errorMessage, 512);
1214  m_errorMessage[511] = '\0';
1215 
1216  return *this;
1217  }
1218 
1222  virtual ~ResourceNotDeclaredException() throw()
1223  {
1224  }
1225 
1231  virtual const char *what() const throw()
1232  {
1233  return m_errorMessage;
1234  }
1235 
1241  const char *resourceName() const throw()
1242  {
1243  return m_resourceName;
1244  }
1245 
1250  EXCEPTION_HELPER_FUNCTIONS(ResourceNotDeclaredException)
1251 
1252 private:
1256  char m_resourceName[256];
1257 
1261  char m_errorMessage[512];
1262 };
1263 
1271 class FARSA_CONF_TEMPLATE ResourceNotUsableException : public BaseException
1272 {
1273 public:
1281  ResourceNotUsableException(const char* resourceName) throw() :
1282  BaseException()
1283  {
1284  strncpy(m_resourceName, resourceName, 256);
1285  m_resourceName[255] = '\0';
1286  sprintf(m_errorMessage, "The resource named \"%s\" was not declared as usable before being used", m_resourceName);
1287  m_errorMessage[511] = '\0';
1288  }
1289 
1296  BaseException(other)
1297  {
1298  strncpy(m_resourceName, other.m_resourceName, 256);
1299  m_resourceName[255] = '\0';
1300  strncpy(m_errorMessage, other.m_errorMessage, 512);
1301  m_errorMessage[511] = '\0';
1302  }
1303 
1310  {
1311  if (&other == this) {
1312  return *this;
1313  }
1314 
1315  BaseException::operator=(other);
1316  strncpy(m_resourceName, other.m_resourceName, 256);
1317  m_resourceName[255] = '\0';
1318  strncpy(m_errorMessage, other.m_errorMessage, 512);
1319  m_errorMessage[511] = '\0';
1320 
1321  return *this;
1322  }
1323 
1327  virtual ~ResourceNotUsableException() throw()
1328  {
1329  }
1330 
1336  virtual const char *what() const throw()
1337  {
1338  return m_errorMessage;
1339  }
1340 
1346  const char *resourceName() const throw()
1347  {
1348  return m_resourceName;
1349  }
1350 
1355  EXCEPTION_HELPER_FUNCTIONS(ResourceNotUsableException)
1356 
1357 private:
1361  char m_resourceName[256];
1362 
1366  char m_errorMessage[512];
1367 };
1368 
1373 class FARSA_CONF_TEMPLATE ResourceTypeMismatchException : public BaseException
1374 {
1375 public:
1386  ResourceTypeMismatchException(const char* resourceName, const char* typeName) throw() :
1387  BaseException()
1388  {
1389  strncpy(m_resourceName, resourceName, 256);
1390  m_resourceName[255] = '\0';
1391  strncpy(m_typeName, typeName, 256);
1392  m_typeName[255] = '\0';
1393  sprintf(m_errorMessage, "Wrong type when requesting a resource; The type of the resource \"%s\" is not \"%s\"", m_resourceName, m_typeName);
1394  m_errorMessage[1023] = '\0';
1395  }
1396 
1403  BaseException(other)
1404  {
1405  strncpy(m_resourceName, other.m_resourceName, 256);
1406  m_resourceName[255] = '\0';
1407  strncpy(m_typeName, other.m_typeName, 256);
1408  m_typeName[255] = '\0';
1409  strncpy(m_errorMessage, other.m_errorMessage, 1024);
1410  m_errorMessage[1023] = '\0';
1411  }
1412 
1419  {
1420  if (&other == this) {
1421  return *this;
1422  }
1423 
1424  BaseException::operator=(other);
1425  strncpy(m_resourceName, other.m_resourceName, 256);
1426  m_resourceName[255] = '\0';
1427  strncpy(m_typeName, other.m_typeName, 256);
1428  m_typeName[255] = '\0';
1429  strncpy(m_errorMessage, other.m_errorMessage, 1024);
1430  m_errorMessage[1023] = '\0';
1431 
1432  return *this;
1433  }
1434 
1439  {
1440  }
1441 
1447  virtual const char *what() const throw()
1448  {
1449  return m_errorMessage;
1450  }
1451 
1457  const char *resourceName() const throw()
1458  {
1459  return m_resourceName;
1460  }
1461 
1467  const char *typeName() const throw()
1468  {
1469  return m_typeName;
1470  }
1471 
1476  EXCEPTION_HELPER_FUNCTIONS(ResourceTypeMismatchException)
1477 
1478 private:
1482  char m_resourceName[256];
1483 
1487  char m_typeName[256];
1488 
1492  char m_errorMessage[1024];
1493 };
1494 
1504 class FARSA_CONF_TEMPLATE UserRequiredResourceMissingException : public BaseException
1505 {
1506 public:
1517  UserRequiredResourceMissingException(const char* resourceName, const char* description) throw() :
1518  BaseException()
1519  {
1520  strncpy(m_resourceName, resourceName, 256);
1521  m_resourceName[255] = '\0';
1522  strncpy(m_description, description, 256);
1523  m_description[255] = '\0';
1524  sprintf(m_errorMessage, "The user requested a resource named \"%s\" which cannot be found. Error description: %s", m_resourceName, m_description);
1525  m_errorMessage[1023] = '\0';
1526  }
1527 
1534  BaseException(other)
1535  {
1536  strncpy(m_resourceName, other.m_resourceName, 256);
1537  m_resourceName[255] = '\0';
1538  strncpy(m_description, other.m_description, 256);
1539  m_description[255] = '\0';
1540  strncpy(m_errorMessage, other.m_errorMessage, 1024);
1541  m_errorMessage[1023] = '\0';
1542  }
1543 
1550  {
1551  if (&other == this) {
1552  return *this;
1553  }
1554 
1555  BaseException::operator=(other);
1556  strncpy(m_resourceName, other.m_resourceName, 256);
1557  m_resourceName[255] = '\0';
1558  strncpy(m_description, other.m_description, 256);
1559  m_description[255] = '\0';
1560  strncpy(m_errorMessage, other.m_errorMessage, 1024);
1561  m_errorMessage[1023] = '\0';
1562 
1563  return *this;
1564  }
1565 
1570  {
1571  }
1572 
1578  virtual const char *what() const throw()
1579  {
1580  return m_errorMessage;
1581  }
1582 
1588  const char *resourceName() const throw()
1589  {
1590  return m_resourceName;
1591  }
1592 
1598  const char *description() const throw()
1599  {
1600  return m_description;
1601  }
1602 
1607  EXCEPTION_HELPER_FUNCTIONS(UserRequiredResourceMissingException)
1608 
1609 private:
1613  char m_resourceName[256];
1614 
1618  char m_description[256];
1619 
1623  char m_errorMessage[1024];
1624 };
1625 
1631 class FARSA_CONF_TEMPLATE WrongResourceLockStatusForOperation : public BaseException
1632 {
1633 public:
1645  WrongResourceLockStatusForOperation(const char* operationName, bool lockStatusLocked) throw() :
1646  BaseException(),
1647  m_lockStatusLocked(lockStatusLocked)
1648  {
1649  strncpy(m_operationName, operationName, 256);
1650  m_operationName[255] = '\0';
1651  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"));
1652  m_errorMessage[511] = '\0';
1653  }
1654 
1661  BaseException(other),
1662  m_lockStatusLocked(other.m_lockStatusLocked)
1663  {
1664  strncpy(m_operationName, other.m_operationName, 256);
1665  m_operationName[255] = '\0';
1666  strncpy(m_errorMessage, other.m_errorMessage, 512);
1667  m_errorMessage[511] = '\0';
1668  }
1669 
1676  {
1677  if (&other == this) {
1678  return *this;
1679  }
1680 
1681  BaseException::operator=(other);
1682  m_lockStatusLocked = other.m_lockStatusLocked;
1683  strncpy(m_operationName, other.m_operationName, 256);
1684  m_operationName[255] = '\0';
1685  strncpy(m_errorMessage, other.m_errorMessage, 512);
1686  m_errorMessage[511] = '\0';
1687 
1688  return *this;
1689  }
1690 
1695  {
1696  }
1697 
1703  virtual const char *what() const throw()
1704  {
1705  return m_errorMessage;
1706  }
1707 
1714  bool lockStatusLocked() const throw()
1715  {
1716  return m_lockStatusLocked;
1717  }
1718 
1724  const char *operationName() const throw()
1725  {
1726  return m_operationName;
1727  }
1728 
1733  EXCEPTION_HELPER_FUNCTIONS(WrongResourceLockStatusForOperation)
1734 
1735 private:
1740  bool m_lockStatusLocked;
1741 
1745  char m_operationName[256];
1746 
1750  char m_errorMessage[512];
1751 };
1752 
1753 } // end namespace farsa
1754 
1755 // All the suff below is to restore the warning state on Windows
1756 #if defined(_MSC_VER)
1757  #pragma warning(pop)
1758 #endif
1759 
1760 #endif