Skip to content

Commit 9d2dcf3

Browse files
Merge pull request #261 from deniskoronchik/dev
Some more functionality
2 parents 3058df3 + 2a83798 commit 9d2dcf3

21 files changed

+792
-73
lines changed

docs/_assets/main.css

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
.todo {
2+
background-color: #E06C6C;
3+
border: 1px solid #AD3939;
4+
color: #fff;
5+
padding: 5px;
6+
font-size: 14px;
7+
}
8+
9+
.todo:before {
10+
content: "TODO:";
11+
font-weight: bold;
12+
width: 100px;
13+
margin-right: 7px;
14+
}
15+
16+
.scg {
17+
display: block;
18+
}
19+
20+
.scg content span {
21+
line-height: 1 !important;
22+
}
23+
24+
.invalid {
25+
display: block;
26+
width: 64px;
27+
height: 64px;
28+
background-image: url(warning.svg);
29+
}
30+
31+
.invalid:after {
32+
content: "Error";
33+
margin-left: 70px;
34+
margin-right: auto;
35+
margin-top: auto;
36+
margin-bottom: auto;
37+
display: block;
38+
width: 200px;
39+
line-height: 64px;
40+
color: #740600;
41+
}
42+
43+
.note {
44+
background-color: #a3c69f !important;
45+
border: 1px solid #70936C;
46+
color: #444;
47+
}
48+
49+
.note code {
50+
background-color: #BDE0B9 !important;
51+
border: none;
52+
}

docs/_assets/main.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
function httpGetAsync(theUrl, callback)
2+
{
3+
var xmlHttp = new XMLHttpRequest();
4+
xmlHttp.onreadystatechange = function() {
5+
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
6+
callback(xmlHttp.responseText);
7+
}
8+
xmlHttp.open("GET", theUrl, true); // true for asynchronous
9+
xmlHttp.send(null);
10+
}
11+
12+
let scgCounter = 0;
13+
function SCgContainer(el) {
14+
// get source
15+
let viewer = null;
16+
const source = el.attributes['src'];
17+
if (!source) {
18+
el.className = 'invalid';
19+
} else {
20+
const id = `scg-content-${scgCounter}`;
21+
scgCounter++;
22+
el.setAttribute('id', id);
23+
el.className = 'scg';
24+
viewer = new SCgViewer(id);
25+
httpGetAsync(source.value, function(data) {
26+
viewer.loadFromData(data);
27+
viewer.fitSizeToContent();
28+
});
29+
}
30+
31+
return {
32+
viewer: viewer
33+
}
34+
}
35+
36+
let views = [];
37+
document.addEventListener('DOMContentLoaded', function() {
38+
const items = document.querySelectorAll('scg');
39+
items.forEach(function(d) {
40+
views.push(new SCgContainer(d));
41+
});
42+
});

docs/_assets/scg.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/_assets/warning.svg

Lines changed: 44 additions & 0 deletions
Loading

docs/changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* Some fixes in template search
1212
* Make log thread safe
1313
* Implement `ScLink` wrapper class
14+
* Add `ScBase64` encode/decode functions
15+
* Add common templates generation (see `sc_common_templ.hpp`)
1416

1517
## v0.3.1
1618

docs/cpp/common.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
## ScLink
2+
Include file: `#include <sc-memory/cpp/sc_link.hpp>`
23

34
There is a special wrapped class `ScLink` that makes work with sc-links simple. It allows to set/get common types values.
45
Supported types: `uint8_t`, `uint16_t`, `uint32_t`, `uint64_t`, `int8_t`, `int16_t`, `int32_t`, `int64_t`, `float`, `double`, `std::string`.
@@ -30,7 +31,58 @@ link.IsType<uint8_t>(); // throws ExceptionInvalidParams
3031
...
3132
```
3233
33-
<div class="todo">Add function to get type of specified sc-link</div>
34+
---
35+
36+
Also you can get type of specified `ScLink`:
37+
```cpp
38+
ScLink link;
39+
link.Set<uint32_t>(32);
40+
link.DetermineType(); // will return ScLink::Type::UInt32
41+
```
42+
43+
See `ScLink::Types` for full list of supported ones.
44+
45+
---
46+
47+
You can get value of any ScLink as `std::string`:
48+
```cpp
49+
ScLink link;
50+
link.Set<uint32_t>(32);
51+
link.GetAsString(); // will return "32"
52+
```
53+
54+
## Common constructions
55+
Include file: `#include <sc-memory/cpp/sc_common_templ.hpp>`
56+
57+
There are some function that allows to make a common routine work:
58+
59+
- `sc::ResolveRelationTuple` - allow to ensure that specified `quasy_binary` relation between tuple and specified element exists. Returns `ScAddr` of tuple. This function check if specified construction exists, and if it doesn't then generate it by template. Used template for check/generation:
60+
<scg src="../images/sc_ResolveRelationTuple.gwf"></scg>
61+
62+
Example:
63+
```cpp
64+
ScAddr const tuple = sc::ResolveRelationTuple(ctx, el, relAddr);
65+
// where:
66+
// el - is a ScAddr of element to ensure tuple exist
67+
// relAddr - is a ScAddr of quasy_binary relation
68+
```
69+
70+
---
71+
72+
- `sc::SetRelationValue` - create sc-link linked to `el` by relation `rel`. If it already exist, than changes it value to new one. Returns `ScAddr` of sc-link. Used template for check/generation:
73+
<scg src="../images/sc_SetRelationValue.gwf"></scg>
74+
75+
Example:
76+
```cpp
77+
std::string const value1 = "test_value";
78+
ScAddr const linkAddr1 = sc::SetRelationValue(ctx, el, relAddr1, value1);
79+
80+
uint32_t const value2 = 57;
81+
ScAddr const linkAddr2 = sc::SetRelationValue(ctx, el, relAddr1, value2);
82+
83+
SC_ASSERT(linkAddr1 == linkAddr2, ()); // should be valid (ScAddr of link doesn't changed)
84+
85+
```
3486
3587
3688
## Iterators
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<GWF version="2.0">
3+
<staticSector>
4+
<arc type="arc/var/pos" idtf="" shapeColor="193" id="1723175632" parent="0" id_b="1832769040" id_e="1723176112" b_x="-435" b_y="-60" e_x="0" e_y="0" dotBBalance="0" dotEBalance="0.564655">
5+
<points/>
6+
</arc>
7+
<node type="node/var/relation" idtf="_rel" shapeColor="0" id="1832769040" parent="0" left="0" top="0" right="58" bottom="41" textColor="164" text_angle="0" text_font="Times New Roman [Arial]" font_size="10" x="-435" y="-60" haveBus="false" idtf_pos="0">
8+
<content type="0" mime_type="" content_visibility="false" file_name=""/>
9+
</node>
10+
<node type="node/var/symmetry" idtf="_tuple" shapeColor="0" id="1832769872" parent="0" left="0" top="0" right="86" bottom="41" textColor="164" text_angle="0" text_font="Times New Roman [Arial]" font_size="10" x="-360" y="15" haveBus="false" idtf_pos="0">
11+
<content type="0" mime_type="" content_visibility="false" file_name=""/>
12+
</node>
13+
<node type="node/var/general_node" idtf="_el" shapeColor="0" id="1829555376" parent="0" left="0" top="0" right="47" bottom="41" textColor="164" text_angle="0" text_font="Times New Roman [Arial]" font_size="10" x="-495" y="15" haveBus="false" idtf_pos="0">
14+
<content type="0" mime_type="" content_visibility="false" file_name=""/>
15+
</node>
16+
<pair type="pair/var/orient" idtf="" shapeColor="0" id="1723176112" parent="0" id_b="1832769872" id_e="1829555376" b_x="-360" b_y="15" e_x="-495" e_y="15" dotBBalance="0" dotEBalance="0">
17+
<points/>
18+
</pair>
19+
</staticSector>
20+
</GWF>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<GWF version="2.0">
3+
<staticSector>
4+
<node type="node/var/relation" idtf="_rel" shapeColor="193" id="1832767792" parent="0" left="0" top="0" right="58" bottom="41" textColor="164" text_angle="0" text_font="Times New Roman [Arial]" font_size="10" x="-465" y="30" haveBus="false" idtf_pos="0">
5+
<content type="0" mime_type="" content_visibility="false" file_name=""/>
6+
</node>
7+
<node type="node/const/general_node" idtf="" shapeColor="0" id="1832768000" parent="0" x="-375" y="105" haveBus="false" idtf_pos="0">
8+
<content type="1" mime_type="content/term" content_visibility="true" file_name=""><![CDATA[<pre>
9+
10+
</pre>]]></content>
11+
</node>
12+
<node type="node/var/general_node" idtf="_el" shapeColor="0" id="1832763632" parent="0" left="0" top="0" right="47" bottom="41" textColor="164" text_angle="0" text_font="Times New Roman [Arial]" font_size="10" x="-525" y="105" haveBus="false" idtf_pos="0">
13+
<content type="0" mime_type="" content_visibility="false" file_name=""/>
14+
</node>
15+
<arc type="arc/var/pos" idtf="" shapeColor="0" id="1833577168" parent="0" id_b="1832767792" id_e="1833573808" b_x="-465" b_y="30" e_x="0" e_y="0" dotBBalance="0" dotEBalance="0.567416">
16+
<points/>
17+
</arc>
18+
<pair type="pair/var/orient" idtf="" shapeColor="0" id="1833573808" parent="0" id_b="1832763632" id_e="1832768000" b_x="-525" b_y="105" e_x="-375" e_y="105" dotBBalance="0" dotEBalance="0">
19+
<points/>
20+
</pair>
21+
</staticSector>
22+
</GWF>

docs/main.css

Lines changed: 0 additions & 24 deletions
This file was deleted.

mkdocs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
site_name: SC-machine
2+
23
extra_css:
3-
- main.css
4+
- _assets/main.css
5+
extra_javascript:
6+
- _assets/scg.min.js
7+
- _assets/main.js
48

59
pages:
610
- Home: index.md

0 commit comments

Comments
 (0)