Skip to content

Instantly share code, notes, and snippets.

@kladd
kladd / main.rs
Created June 8, 2023 12:39
krpc-client walk parts tree
use krpc_client::Client;
use krpc_client::error::RpcError;
use krpc_client::services::space_center::SpaceCenter;
const INDENT_WIDTH: usize = 4;
// Port of https://krpc.github.io/krpc/cpp/api/space-center/parts.html#trees-of-parts
fn main() -> Result<(), RpcError> {
let client = Client::new("kRPC TEST", "127.0.0.1", 50000, 50001).unwrap();
let sc = SpaceCenter::new(client);
@kladd
kladd / driver.cpp
Last active August 29, 2015 14:28
RIDC user instanced ODE
#include <iostream>
#include "ridc.h"
using namespace std;
class MyOde : public ODE {
public:
MyOde(int my_neq /**, anything else I want **/) {
ti = 0;
neq = 10;
@kladd
kladd / driver.cpp
Created August 24, 2015 20:24
ridc without PARAMETER
#include <iostream>
#include "ridc.h"
using namespace std;
class MyOde : public ODE {
public:
MyOde() {
ti = 0;
neq = 10;
@kladd
kladd / driver.cpp
Last active August 29, 2015 14:28
RIDC, templates and abstract class
#include <iostream>
#include "ridc.h"
using namespace std;
class MyOde : public ODE {
public:
void rhs(double t, double *u, PARAMETER param, double *f) {
cout << "This is the user defined RHS function." << endl;
}
#include <iostream>
using namespace std;
//////////////////////////// ridc.h
template <class UserDefined>
void ridc()
{
UserDefined::step();
}
class Implicit {
void rhs(...) { ... }
void step(...) { ... }
}
class Explicit {
void rhs(...) { ... }
void step(...) { ... }
}
package main
/*
#include <stdio.h>
void echostr(char *str);
*/
import "C"
/*
void echostr(char *str)
{
package main
/*
#include <stdio.h>
void echostr(char *str)
{
printf("%s\n", str);
}
*/
import "C"
import "fmt"
name := v.Type().Field(i).Tag.Get("url")
switch v.Field(i).Type() {
case "string":
value = v.Field(i).String()
// ...
}