Rev 1766 | Rev 2066 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1766 | Rev 1989 | ||
|---|---|---|---|
| Line 22... | Line 22... | ||
| 22 | 22 | ||
| 23 | #include <stdexcept> |
23 | #include <stdexcept> |
| 24 | #include <string.h> |
24 | #include <string.h> |
| 25 | 25 | ||
| 26 | #include <boost/lexical_cast.hpp> |
26 | #include <boost/lexical_cast.hpp> |
| - | 27 | ||
| - | 28 | #include "common/log.h" |
|
| 27 | 29 | ||
| 28 | namespace atom { |
30 | namespace atom { |
| 29 | namespace can { |
31 | namespace can { |
| 30 | 32 | ||
| 31 | Protocol::Pointer Protocol::instance_; |
33 | Protocol::Pointer Protocol::instance_; |
| - | 34 | ||
| - | 35 | static const std::string log_module_ = "can::protocol"; |
|
| 32 | 36 | ||
| 33 | Protocol::Protocol() : LOG("can::Protocol") |
37 | Protocol::Protocol() : LOG("can::Protocol") |
| 34 | { |
38 | { |
| 35 | } |
39 | } |
| 36 | 40 | ||
| 37 | Protocol::~Protocol() |
41 | Protocol::~Protocol() |
| 38 | { |
42 | { |
| 39 | } |
43 | } |
| 40 | 44 | ||
| 41 | void Protocol::Create() |
45 | void Protocol::Create() |
| 42 | { |
46 | { |
| 43 |
|
47 | Protocol::instance_ = Protocol::Pointer(new Protocol()); |
| 44 | } |
48 | } |
| 45 | 49 | ||
| 46 | Protocol::Pointer Protocol::Instance() |
50 | Protocol::Pointer Protocol::Instance() |
| 47 | { |
51 | { |
| 48 |
|
52 | return Protocol::instance_; |
| 49 | } |
53 | } |
| 50 | 54 | ||
| 51 | void Protocol::Delete() |
55 | void Protocol::Delete() |
| 52 | { |
56 | { |
| 53 |
|
57 | Protocol::instance_.reset(); |
| 54 | } |
58 | } |
| 55 | 59 | ||
| 56 | bool Protocol::Load(std::string |
60 | bool Protocol::Load(std::string file_path) |
| 57 | { |
61 | { |
| 58 |
|
62 | try |
| 59 |
|
63 | { |
| 60 |
|
64 | this->root_node_.LoadFile(file_path); |
| 61 |
|
65 | } |
| 62 |
|
66 | catch (std::runtime_error& e) |
| 63 |
|
67 | { |
| 64 |
|
68 | LOG.Error(e.what()); |
| 65 |
|
69 | return false; |
| 66 |
|
70 | } |
| 67 | 71 | ||
| 68 |
|
72 | LOG.Info("Protocol loaded successfully."); |
| 69 |
|
73 | return true; |
| 70 | } |
74 | } |
| 71 | 75 | ||
| 72 | std::string Protocol::LookupClassName(unsigned int class_id) |
76 | std::string Protocol::LookupClassName(unsigned int class_id) |
| 73 | { |
77 | { |
| 74 | try |
78 | try |