Newer
Older
/*----- PROTECTED REGION ID(DataExporter.cpp) ENABLED START -----*/
//=============================================================================
//
// file : DataExporter.cpp
//
// description : C++ source for the DataExporter class and its commands.
// The class is derived from Device. It represents the
// CORBA servant object which will be accessed from the
// network. All commands which can be executed on the
// DataExporter are implemented in this file.
//
// project : Data exporter
//
// This file is part of Tango device class.
// Tango 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 3 of the License, or
// (at your option) any later version.
// Tango 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 Tango. If not, see <http://www.gnu.org/licenses/>.
// $Author: $
//
// $Revision: $
// $Date: $
//
// $HeadURL: $
//
//=============================================================================
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//=============================================================================
#include <DataExporter.h>
#include <DataExporterClass.h>
#include <PlainServer.h>
#include <SSLServer.h>
#include <boost/filesystem.hpp>
/*----- PROTECTED REGION END -----*/ // DataExporter.cpp
/**
* DataExporter class description:
*/
//================================================================
// The following table gives the correspondence
// between command and method names.
//
// Command name | Method name
//================================================================
// State | Inherited (no method)
// Status | Inherited (no method)
// On | on
// Off | off
//================================================================
//================================================================
// Attributes managed is:
//================================================================
//================================================================
namespace DataExporter_ns
{
/*----- PROTECTED REGION ID(DataExporter::namespace_starting) ENABLED START -----*/
// static initializations
/*----- PROTECTED REGION END -----*/ // DataExporter::namespace_starting
//--------------------------------------------------------
/**
* Method : DataExporter::DataExporter()
* Description : Constructors for a Tango device
* implementing the classDataExporter
*/
//--------------------------------------------------------
DataExporter::DataExporter(Tango::DeviceClass *cl, string &s)
: TANGO_BASE_CLASS(cl, s.c_str())
{
/*----- PROTECTED REGION ID(DataExporter::constructor_1) ENABLED START -----*/
init_device();
/*----- PROTECTED REGION END -----*/ // DataExporter::constructor_1
}
//--------------------------------------------------------
DataExporter::DataExporter(Tango::DeviceClass *cl, const char *s)
: TANGO_BASE_CLASS(cl, s)
{
/*----- PROTECTED REGION ID(DataExporter::constructor_2) ENABLED START -----*/
init_device();
/*----- PROTECTED REGION END -----*/ // DataExporter::constructor_2
}
//--------------------------------------------------------
DataExporter::DataExporter(Tango::DeviceClass *cl, const char *s, const char *d)
: TANGO_BASE_CLASS(cl, s, d)
{
/*----- PROTECTED REGION ID(DataExporter::constructor_3) ENABLED START -----*/
init_device();
/*----- PROTECTED REGION END -----*/ // DataExporter::constructor_3
}
//--------------------------------------------------------
/**
* Method : DataExporter::delete_device()
* Description : will be called at device destruction or at init command
*/
//--------------------------------------------------------
void DataExporter::delete_device()
{
DEBUG_STREAM << "DataExporter::delete_device() " << device_name << endl;
/*----- PROTECTED REGION ID(DataExporter::delete_device) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // DataExporter::delete_device
}
//--------------------------------------------------------
/**
* Method : DataExporter::init_device()
* Description : will be called at device initialization.
*/
//--------------------------------------------------------
void DataExporter::init_device()
{
DEBUG_STREAM << "DataExporter::init_device() create device " << device_name << endl;
/*----- PROTECTED REGION ID(DataExporter::init_device_before) ENABLED START -----*/
set_state(Tango::INIT);
set_status("Initializing device");
/*----- PROTECTED REGION END -----*/ // DataExporter::init_device_before
// Get the device properties from database
get_device_property();
/*----- PROTECTED REGION ID(DataExporter::init_device) ENABLED START -----*/
if(get_state() != Tango::FAULT)
{
try
{
if(enableSSL)
m_server_sp = SSLServer::create(this, m_configuration_sp);
else
m_server_sp = PlainServer::create(this, m_configuration_sp);
}
catch(std::exception& ex)
{
set_state(Tango::FAULT);
std::stringstream error_stream;
error_stream << "DataExporter::init_device() " << ex.what() << std::endl;
set_status(error_stream.str());
}
catch(...)
{
set_state(Tango::FAULT);
set_status("DataExporter::init_device() unknown error");
}
}
/*----- PROTECTED REGION END -----*/ // DataExporter::init_device
}
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
//--------------------------------------------------------
/**
* Method : DataExporter::get_device_property()
* Description : Read database to initialize property data members.
*/
//--------------------------------------------------------
void DataExporter::get_device_property()
{
/*----- PROTECTED REGION ID(DataExporter::get_device_property_before) ENABLED START -----*/
//Exported tables multi map [schema table]
std::multimap<const std::string, const std::string> exportedTablesMap;
//Authorised user map [user password]
std::map<const std::string, const std::string> authorisedUsersMap;
/*----- PROTECTED REGION END -----*/ // DataExporter::get_device_property_before
// Read device properties from database.
Tango::DbData dev_prop;
dev_prop.push_back(Tango::DbDatum("CertificateFile"));
dev_prop.push_back(Tango::DbDatum("PrivateKeyFile"));
dev_prop.push_back(Tango::DbDatum("DHTempFile"));
dev_prop.push_back(Tango::DbDatum("ExportedTables"));
dev_prop.push_back(Tango::DbDatum("AuthorisedUsers"));
dev_prop.push_back(Tango::DbDatum("StoragePath"));
dev_prop.push_back(Tango::DbDatum("LocalHost"));
dev_prop.push_back(Tango::DbDatum("LocalPort"));
dev_prop.push_back(Tango::DbDatum("WorkerNumber"));
dev_prop.push_back(Tango::DbDatum("EnableSSL"));
dev_prop.push_back(Tango::DbDatum("DatabaseHost"));
dev_prop.push_back(Tango::DbDatum("DatabasePort"));
dev_prop.push_back(Tango::DbDatum("DatabaseUsername"));
dev_prop.push_back(Tango::DbDatum("DatabasePassword"));
dev_prop.push_back(Tango::DbDatum("DatabaseConnectionNumber"));
// is there at least one property to be read ?
if (dev_prop.size()>0)
{
// Call database and extract values
if (Tango::Util::instance()->_UseDb==true)
get_db_device()->get_property(dev_prop);
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
// get instance on DataExporterClass to get class property
Tango::DbDatum def_prop, cl_prop;
DataExporterClass *ds_class =
(static_cast<DataExporterClass *>(get_device_class()));
int i = -1;
// Try to initialize CertificateFile from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> certificateFile;
else {
// Try to initialize CertificateFile from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> certificateFile;
}
// And try to extract CertificateFile value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> certificateFile;
// Try to initialize PrivateKeyFile from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> privateKeyFile;
else {
// Try to initialize PrivateKeyFile from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> privateKeyFile;
}
// And try to extract PrivateKeyFile value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> privateKeyFile;
// Try to initialize DHTempFile from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> dHTempFile;
else {
// Try to initialize DHTempFile from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> dHTempFile;
}
// And try to extract DHTempFile value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> dHTempFile;
// Try to initialize ExportedTables from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> exportedTables;
else {
// Try to initialize ExportedTables from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> exportedTables;
}
// And try to extract ExportedTables value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> exportedTables;
// Try to initialize AuthorisedUsers from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> authorisedUsers;
else {
// Try to initialize AuthorisedUsers from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> authorisedUsers;
}
// And try to extract AuthorisedUsers value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> authorisedUsers;
// Try to initialize StoragePath from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> storagePath;
else {
// Try to initialize StoragePath from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> storagePath;
}
// And try to extract StoragePath value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> storagePath;
// Try to initialize LocalHost from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> localHost;
else {
// Try to initialize LocalHost from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> localHost;
}
// And try to extract LocalHost value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> localHost;
// Try to initialize LocalPort from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> localPort;
else {
// Try to initialize LocalPort from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> localPort;
}
// And try to extract LocalPort value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> localPort;
// Try to initialize WorkerNumber from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> workerNumber;
else {
// Try to initialize WorkerNumber from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> workerNumber;
}
// And try to extract WorkerNumber value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> workerNumber;
// Try to initialize EnableSSL from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> enableSSL;
else {
// Try to initialize EnableSSL from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> enableSSL;
}
// And try to extract EnableSSL value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> enableSSL;
// Try to initialize DatabaseHost from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> databaseHost;
else {
// Try to initialize DatabaseHost from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> databaseHost;
}
// And try to extract DatabaseHost value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> databaseHost;
// Try to initialize DatabasePort from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> databasePort;
else {
// Try to initialize DatabasePort from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> databasePort;
}
// And try to extract DatabasePort value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> databasePort;
// Try to initialize DatabaseUsername from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> databaseUsername;
else {
// Try to initialize DatabaseUsername from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> databaseUsername;
}
// And try to extract DatabaseUsername value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> databaseUsername;
// Try to initialize DatabasePassword from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> databasePassword;
else {
// Try to initialize DatabasePassword from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> databasePassword;
}
// And try to extract DatabasePassword value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> databasePassword;
// Try to initialize DatabaseConnectionNumber from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> databaseConnectionNumber;
else {
// Try to initialize DatabaseConnectionNumber from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> databaseConnectionNumber;
}
// And try to extract DatabaseConnectionNumber value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> databaseConnectionNumber;
}
/*----- PROTECTED REGION ID(DataExporter::get_device_property_after) ENABLED START -----*/
try
{
if(enableSSL)
{
if(certificateFile.empty())
throw(invalid_argument("CertificateFile property is empty or not defined"));
checkIfFileExists(certificateFile);
if(privateKeyFile.empty())
throw(invalid_argument("PrivateKeyFile property is empty or not defined"));
checkIfFileExists(privateKeyFile);
if(dHTempFile.empty())
throw(invalid_argument("DHTempFile property is empty or not defined"));
checkIfFileExists(dHTempFile);
}
if(exportedTables.empty())
throw(invalid_argument("ExportedTables property is empty or not defined"));
importExportedTables(exportedTables, exportedTablesMap);
if(authorisedUsers.empty())
throw(invalid_argument("AuthorisedUsers property is empty or not defined"));
importAuthorisedUsers(authorisedUsers, authorisedUsersMap);
if(storagePath.empty())
throw(invalid_argument("StoragePath property is empty or not defined"));
checkIfDirectoryExists(storagePath);
if(localHost.empty())
throw(invalid_argument("LocalHost property is empty or not defined"));
if(localPort<1 || localPort>MAX_LOCAL_PORT)
throw(invalid_argument("LocalPort property out of range or not defined"));
if(workerNumber<1 || workerNumber>MAX_WORKER_NUMBER)
throw(invalid_argument("WorkerNumber property out of range or not defined"));
if(databaseHost.empty())
throw(invalid_argument("DatabaseHost property is empty or not defined"));
if(databasePort<1 || databasePort>MAX_DB_PORT)
throw(invalid_argument("DatabasePort property out of range or not defined"));
if(databaseUsername.empty())
throw(invalid_argument("DatabaseUsername property is empty or not defined"));
if(databasePassword.empty())
throw(invalid_argument("DatabasePassword property is empty or not defined"));
if(databaseConnectionNumber<1 || databaseConnectionNumber>MAX_DB_CONNECTION_NUMBER)
throw(invalid_argument("DatabaseConnectionNumber property out of range or not defined"));
m_configuration_sp = Configuration::create(certificateFile,
privateKeyFile, dHTempFile, exportedTablesMap, authorisedUsersMap,
storagePath, localHost, localPort, workerNumber,
databaseHost, databasePort, databaseUsername, databasePassword,
databaseConnectionNumber);
}
catch(invalid_argument& ex)
{
set_state(Tango::FAULT);
stringstream error_stream;
error_stream << "DataExporter::get_device_property() " << ex.what() << endl;
set_status(error_stream.str());
}
/*----- PROTECTED REGION END -----*/ // DataExporter::get_device_property_after
}
//--------------------------------------------------------
/**
* Method : DataExporter::always_executed_hook()
* Description : method always executed before any command is executed
*/
//--------------------------------------------------------
void DataExporter::always_executed_hook()
{
INFO_STREAM << "DataExporter::always_executed_hook() " << device_name << endl;
/*----- PROTECTED REGION ID(DataExporter::always_executed_hook) ENABLED START -----*/
if(get_state() != Tango::FAULT)
{
if(m_server_sp)
{
set_state(m_server_sp->readState());
set_status(m_server_sp->readStatus());
}
}
/*----- PROTECTED REGION END -----*/ // DataExporter::always_executed_hook
}
//--------------------------------------------------------
/**
* Method : DataExporter::read_attr_hardware()
* Description : Hardware acquisition for attributes
*/
//--------------------------------------------------------
void DataExporter::read_attr_hardware(TANGO_UNUSED(vector<long> &attr_list))
{
DEBUG_STREAM << "DataExporter::read_attr_hardware(vector<long> &attr_list) entering... " << endl;
/*----- PROTECTED REGION ID(DataExporter::read_attr_hardware) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // DataExporter::read_attr_hardware
}
//--------------------------------------------------------
/**
* Method : DataExporter::add_dynamic_attributes()
* Description : Create the dynamic attributes if any
* for specified device.
*/
//--------------------------------------------------------
void DataExporter::add_dynamic_attributes()
{
/*----- PROTECTED REGION ID(DataExporter::add_dynamic_attributes) ENABLED START -----*/
// Add your own code to create and add dynamic attributes if any
/*----- PROTECTED REGION END -----*/ // DataExporter::add_dynamic_attributes
}
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
//--------------------------------------------------------
/**
* Command On related method
* Description: Activate data exporter
*
*/
//--------------------------------------------------------
void DataExporter::on()
{
DEBUG_STREAM << "DataExporter::On() - " << device_name << endl;
/*----- PROTECTED REGION ID(DataExporter::on) ENABLED START -----*/
try
{
if(m_server_sp)
m_server_sp->start();
}
catch(std::exception& ex)
{
set_state(Tango::FAULT);
std::stringstream error_stream;
error_stream << "DataExporter::On() " << ex.what() << std::endl;
set_status(error_stream.str());
}
catch(...)
{
set_state(Tango::FAULT);
set_status("DataExporter::On() unknown error");
}
/*----- PROTECTED REGION END -----*/ // DataExporter::on
}
//--------------------------------------------------------
/**
* Command Off related method
* Description: Deactivate data exporter
*
*/
//--------------------------------------------------------
void DataExporter::off()
{
DEBUG_STREAM << "DataExporter::Off() - " << device_name << endl;
/*----- PROTECTED REGION ID(DataExporter::off) ENABLED START -----*/
try
{
if(m_server_sp)
m_server_sp->stop();
}
catch(std::exception& ex)
{
set_state(Tango::FAULT);
std::stringstream error_stream;
error_stream << "DataExporter::Off() " << ex.what() << std::endl;
set_status(error_stream.str());
}
catch(...)
{
set_state(Tango::FAULT);
set_status("DataExporter::Off() unknown error");
}
/*----- PROTECTED REGION END -----*/ // DataExporter::off
}
/*----- PROTECTED REGION ID(DataExporter::namespace_ending) ENABLED START -----*/
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
//==============================================================================
// DataExporter::importExportedTables()
//==============================================================================
void DataExporter::importExportedTables(std::vector<std::string>& exportedTables,
std::multimap<const std::string, const std::string>& exportedTablesMap)
throw(std::invalid_argument)
{
DEBUG_STREAM << "DataExporter::importExportedTables() - " << device_name << endl;
for(unsigned int i=0; i<exportedTables.size(); ++i)
{
std::size_t found;
if((found=exportedTables.at(i).find(' ')) == std::string::npos)
{
std::stringstream errorStream;
errorStream << "ExportedTables property has invalid key at "
<< i << " position" << std::endl;
throw std::invalid_argument(errorStream.str());
}
std::string schema = exportedTables.at(i).substr(0, found);
std::string table = exportedTables.at(i).substr(found+1, std::string::npos);
INFO_STREAM << "DataExporter::importExportedTables() schema "
<< schema << " table " << table << endl;
exportedTablesMap.insert(std::pair<const std::string, const std::string> (schema, table));
}
}
//==============================================================================
// DataExporter::importAuthorisedUsers()
//==============================================================================
void DataExporter::importAuthorisedUsers(std::vector<std::string>& authorisedUsers,
std::map<const std::string, const std::string>& authorisedUsersMap)
throw(std::invalid_argument)
{
DEBUG_STREAM << "DataExporter::importAuthorisedUsers() - " << device_name << endl;
for(unsigned int i=0; i<authorisedUsers.size(); ++i)
{
std::size_t found;
if((found=authorisedUsers.at(i).find(' ')) == std::string::npos)
{
std::stringstream errorStream;
errorStream << "AuthorisedUsers property has invalid key at "
<< i << " position" << std::endl;
throw std::invalid_argument(errorStream.str());
}
std::string user = authorisedUsers.at(i).substr(0, found);
std::string password = authorisedUsers.at(i).substr(found+1, std::string::npos);
#ifdef VERBOSE_DEBUG
INFO_STREAM << "DataExporter::importAuthorisedUsers() user "
<< user << " password " << password << endl;
#endif
authorisedUsersMap.insert(std::pair<const std::string,
const std::string>(user, password));
}
}
//==============================================================================
// DataExporter::checkIfFileExists()
//==============================================================================
void DataExporter::checkIfFileExists(std::string fileName)
throw(std::invalid_argument)
{
DEBUG_STREAM << "DataExporter::checkIfFileExists() - " << device_name << endl;
boost::filesystem::path path(fileName);
if(!boost::filesystem::exists(path))
{
std::stringstream errorStream;
errorStream << "File " << fileName << " not exists" << std::endl;
throw std::invalid_argument(errorStream.str());
}
INFO_STREAM << "DataExporter::checkIfFileExists() " << fileName << endl;
}
//==============================================================================
// DataExporter::checkIfFileExists()
//==============================================================================
void DataExporter::checkIfDirectoryExists(std::string directoryName)
throw(std::invalid_argument)
{
DEBUG_STREAM << "DataExporter::checkIfFileExists() - " << device_name << endl;
boost::filesystem::path path(directoryName);
if(!boost::filesystem::exists(path))
{
std::stringstream errorStream;
errorStream << "Directory " << directoryName << " not exists" << std::endl;
throw std::invalid_argument(errorStream.str());
}
if(!boost::filesystem::is_directory(path))
{
std::stringstream errorStream;
errorStream << directoryName << " is not a directory" << std::endl;
throw std::invalid_argument(errorStream.str());
}
INFO_STREAM << "DataExporter::checkIfDirectoryExists() " << directoryName << endl;
}
/*----- PROTECTED REGION END -----*/ // DataExporter::namespace_ending
} // namespace