DoxDoc.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * 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, see <http://www.gnu.org/licenses/>.
17 *
18 * @package
19 * @author
20 * @date
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24#include "DoxDoc.h"
25
26#include <SimoxUtility/algorithm/string/string_tools.h>
27
30
31#include "DoxLine.h"
32#include "DoxTable.h"
33#include "DoxTransitiongraph.h"
34
35
36using namespace armarx;
37
41
42void
44{
45 entries.push_back(entry);
46}
47
48void
50{
51 addLine("");
52}
53
54void
56{
57 writer->body.line("/**");
58
59 for (DoxEntryPtr entry : entries)
60 {
61 std::string doc = entry->getDoxString();
62 std::string delimiters = "\n";
63 std::vector<std::string> doclines = simox::alg::split(doc, delimiters);
64
65 for (std::string line : doclines)
66 {
67 writer->body.line(" * " + line);
68 }
69 }
70
71 writer->body.line("*/");
72}
73
74void
75armarx::DoxDoc::addLine(const std::string& line)
76{
77 DoxEntryPtr entry(new DoxLine(line));
78 addEntry(entry);
79}
80
81void
83 VariantInfoPtr variantInfo,
84 Ice::CommunicatorPtr communicator)
85{
86 std::vector<std::string> header;
87 header.push_back("Name");
88 header.push_back("Type");
89 header.push_back("Default value");
90 header.push_back("Description");
91
92 DoxTablePtr table = DoxTablePtr(new DoxTable(header));
93
94
95 for (RapidXmlReaderNode parameter : parameters.nodes())
96 {
97 std::vector<std::string> row;
98 row.push_back(parameter.attribute_value("name"));
99 std::string nestedType = parameter.attribute_value("type");
100
101 if (variantInfo->getNestedHumanNameFromBaseName(nestedType).compare("") != 0)
102 {
103 row.push_back(variantInfo->getNestedHumanNameFromBaseName(nestedType));
104 }
105 else
106 {
107 row.push_back(nestedType);
108 }
109
110 JSONObjectPtr jsonObject = new JSONObject(communicator);
111 std::string defaultValue = parameter.attribute_value_or_default("default", "");
112
113 if (defaultValue.size() > 0)
114 {
115 try
116 {
117 jsonObject->fromString(defaultValue);
118 SerializablePtr obj = jsonObject->deserializeIceObject();
119 VariantContainerBasePtr result = VariantContainerBasePtr::dynamicCast(obj);
120 std::string resultString = result->toString();
121 resultString = simox::alg::replace_all(resultString, "\n", "<br>");
122 row.push_back(resultString);
123 }
124 catch (Ice::Exception& e)
125 {
126 ARMARX_WARNING_S << "Cannot deserialize defaultValue of parameter "
127 << parameter.attribute_value("name") << ": \"" << defaultValue
128 << "\"\n"
129 << e.ice_id() << ":\n"
130 << e.what() << "\n"
131 << e.ice_stackTrace();
132 row.push_back(" ");
133 }
134 }
135 else
136 {
137 row.push_back(" ");
138 }
139
140 row.push_back(parameter.attribute_value_or_default("description", " "));
141
142 table->addRow(row);
143 }
144
145 addEntry(table);
146}
147
148void
150{
152
153 for (RapidXmlReaderNode transition : transitions.nodes())
154 {
155 if (transition.has_attribute("from") && transition.has_attribute("to") &&
156 transition.has_attribute("eventName"))
157 {
158 graph->addTransition(
159 DoxTransitionPtr(new DoxTransition(transition.attribute_value("from"),
160 transition.attribute_value("to"),
161 transition.attribute_value("eventName"))));
162 }
163 }
164
165 addEntry(graph);
166}
void addEntry(DoxEntryPtr entry)
Definition DoxDoc.cpp:43
void addTransitionGraph(const RapidXmlReaderNode &transitions)
Definition DoxDoc.cpp:149
void addLine()
Definition DoxDoc.cpp:49
void writeDoc(CppWriterPtr writer)
Definition DoxDoc.cpp:55
void addParameterTable(const RapidXmlReaderNode &parameters, VariantInfoPtr variantInfo, Ice::CommunicatorPtr communicator)
Definition DoxDoc.cpp:82
The JSONObject class is used to represent and (de)serialize JSON objects.
Definition JSONObject.h:44
std::vector< RapidXmlReaderNode > nodes(const char *name=nullptr) const
#define ARMARX_WARNING_S
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:213
::IceInternal::Handle<::Ice::Communicator > CommunicatorPtr
Definition IceManager.h:49
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< DoxTransition > DoxTransitionPtr
std::shared_ptr< DoxEntry > DoxEntryPtr
Definition DoxEntry.h:32
std::shared_ptr< CppWriter > CppWriterPtr
Definition CppWriter.h:35
std::shared_ptr< VariantInfo > VariantInfoPtr
Definition VariantInfo.h:39
IceInternal::Handle< JSONObject > JSONObjectPtr
Definition JSONObject.h:34
std::shared_ptr< DoxTransitionGraph > DoxTransitionGraphPtr
std::shared_ptr< DoxTable > DoxTablePtr
Definition DoxTable.h:35