Subversion Repositories HomeAutomation

Rev

Rev 1326 | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
1309 runge 1
/*
1311 runge 2
 * Protocol.cpp
1309 runge 3
 *
4
 *  Created on: Jul 23, 2009
5
 *      Author: Mattias Runge
6
 */
7
 
1311 runge 8
#include "Protocol.h"
1309 runge 9
 
10
namespace atom {
11
 
1311 runge 12
Protocol::pointer Protocol::Instance(new Protocol());
1310 runge 13
 
1311 runge 14
Protocol::Protocol()
1309 runge 15
{
1328 runge 16
    this->myIsLoaded = false;
1326 runge 17
    LOG.setName("Protocol");
1309 runge 18
}
19
 
1311 runge 20
Protocol::~Protocol()
1309 runge 21
{
22
}
23
 
1311 runge 24
Protocol::pointer Protocol::getInstance()
1310 runge 25
{
1311 runge 26
    return Protocol::Instance;
1309 runge 27
}
1310 runge 28
 
1326 runge 29
void Protocol::load(string filename, string cachefilename)
1310 runge 30
{
31
    this->myXmlNode.load(filename);
1311 runge 32
 
1326 runge 33
    LOG.info("Loaded protocol from \"" + filename + "\".");
34
 
1311 runge 35
    // TODO Catch exceptions thrown by load
36
 
37
    // TODO Do validation of XML-data, check if needed sections are defined
1326 runge 38
 
39
 
40
    this->myXmlCacheNode.load(cachefilename);
41
 
42
    LOG.info("Loaded protocol cache from \"" + cachefilename + "\".");
43
 
44
    // TODO If not found generate one
45
 
46
    // TODO Check if versions match, if not update cache
1328 runge 47
 
48
    this->myIsLoaded = true;
1309 runge 49
}
1310 runge 50
 
1311 runge 51
xml::Node & Protocol::getRootNode()
1310 runge 52
{
53
    return this->myXmlNode;
54
}
55
 
1326 runge 56
xml::Node & Protocol::getRootCacheNode()
57
{
58
    return this->myXmlCacheNode;
1310 runge 59
}
1311 runge 60
 
1328 runge 61
bool Protocol::isLoaded()
62
{
63
    return this->myIsLoaded;
1326 runge 64
}
65
 
1328 runge 66
}
67