summaryrefslogtreecommitdiff
path: root/include/tng_io.hpp
blob: 202f9dbcba51b9e211b0440920554140f2674a7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
/* This code is part of the tng binary trajectory format.
 *
 *                      VERSION 1.4
 *
 * Written by Anders Gärdenäs
 * Copyright (c) 2012-2013, The GROMACS development team.
 * Check out http://www.gromacs.org for more information.
 *
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the Revised BSD License.
 */

#ifndef TNG_IO_HPP
#define TNG_IO_HPP

#include "tng_io.h"

namespace Tng
{
class Trajectory;
class Atom;
class Residue;
class Chain;
class Molecule;
typedef class Molecule * Molecule_t;


class Trajectory {
private:
    tng_trajectory_t traj;
    tng_function_status status;
public:
    /**
    * @brief Add a molecule to the trajectory.
    * @param name is a pointer to the string containing the name of the new molecule.
    * @param molecule is a pointer to the newly created molecule.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */

    tng_function_status addMolecule(const char *, Molecule_t);
    tng_function_status addMoleculeWithId(const char *, int64_t id, Molecule_t);
    tng_function_status findMolecule(const char *name, int64_t id, Molecule_t molecule);
    friend class Atom;
    friend class Residue;
    friend class Chain;
    friend class Molecule;

    //! Normal constructor
    Trajectory()
    { status = tng_trajectory_init(&traj); }

    //! Copy constructor
    Trajectory(Trajectory * src)
    { status = tng_trajectory_init_from_src(traj,&src->traj); }

    //! Detructor
    ~Trajectory()
    { status = tng_trajectory_destroy(&traj); }

    //! Status
    tng_function_status getStatus()
    { return status; }


    /**
    * @brief Get the name of the input file.
    * @param file_name the string to fill with the name of the input file,
    * memory must be allocated before.
    * @param max_len maximum char length of the string, i.e. how much memory has
    * been reserved for file_name. This includes \0 terminating character.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred (source string longer than destination string).
    */
    tng_function_status getInputFile (char *file_name, const int max_len)
    {
        return status = tng_input_file_get(traj, file_name,   max_len);
    }

    /**
    * @brief Set the name of the input file.
    * @param file_name the name of the input file.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status setInputFile(const char *file_name)
    {
        return status = tng_input_file_set(traj, file_name);
    }


    /**
    * @brief Get the name of the output file.
    * @param file_name the string to fill with the name of the output file,
    * memory must be allocated before.
    * @param max_len maximum char length of the string, i.e. how much memory has
    * been reserved for file_name. This includes \0 terminating character.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred (source string longer than destination string).
    */
    tng_function_status getOutputFile(char *file_name, const int max_len)
    {
        return status = tng_output_file_get(traj, file_name, max_len);
    }


    /**
    * @brief Set the name of the output file.
    * @param file_name the name of the output file.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status setOutputFile(const char *file_name)
    {
        return status = tng_output_file_set(traj, file_name);
    }

    /**
    * @brief Get the endianness of the output file.
    * current output file.
    * @param endianness will contain the enumeration of the endianness.
    * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (1) if the endianness
    * could not be retrieved.
    */
    tng_function_status getOutputFileEndianness
                    (tng_file_endianness *endianness)
    {
        return status = tng_output_file_endianness_get(traj, endianness);
    }

    /**
    * @brief Set the endianness of the output file.
    * @param endianness the enumeration of the endianness, can be either
    * TNG_BIG_ENDIAN (0) or TNG_LITTLE_ENDIAN (1).
    * @details The endianness cannot be changed after file output has started.
    * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (1) if the endianness
    * could not be set.
    */
    tng_function_status setOutputFileEndianness
                    (const tng_file_endianness endianness)
    {
        return status = tng_output_file_endianness_set(traj, endianness);
    }

    /**
    * @brief Get the name of the program used when creating the trajectory.
    * @param name the string to fill with the name of the program,
    * memory must be allocated before.
    * @param max_len maximum char length of the string, i.e. how much memory has
    * been reserved for name. This includes \0 terminating character.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred (source string longer than destination string).
    */
    tng_function_status getFirstProgramName(char *name, const int max_len)
    {
        return status = tng_first_program_name_get(traj,name,max_len);
    }


    /**
    * @brief Set the name of the program used when creating the trajectory..
    * @param new_name is a string containing the wanted name.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status setFirstProgramName(const char *new_name)
    {
        return status = tng_first_program_name_set(traj, new_name);
    }


    /**
    * @brief Get the name of the program used when last modifying the trajectory.
    * @param name the string to fill with the name of the program,
    * memory must be allocated before.
    * @param max_len maximum char length of the string, i.e. how much memory has
    * been reserved for name. This includes \0 terminating character.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred (source string longer than destination string).
    */
    tng_function_status getLastProgramName(char *name, const int max_len)
    {
        return status = tng_last_program_name_get(traj, name, max_len);
    }


    /**
    * @brief Set the name of the program used when last modifying the trajectory.
    * @param new_name is a string containing the wanted name.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status setLastProgramName(const char *new_name)
    {
        return status = tng_last_program_name_set(traj, new_name);
    }


    /**
    * @brief Get the name of the user who created the trajectory.
    * @param name the string to fill with the name of the user,
    * memory must be allocated before.
    * @param max_len maximum char length of the string, i.e. how much memory has
    * been reserved for name. This includes \0 terminating character.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred (source string longer than destination string).
    */
    tng_function_status getFirstUserName(char *name, const int max_len)
    {
        return status = tng_first_user_name_get(traj,name, max_len);
    }


    /**
    * @brief Set the name of the user who created the trajectory.
    * @param new_name is a string containing the wanted name.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status setFirstUserName(const char *new_name)
    {
        return status = tng_first_user_name_set(traj, new_name);
    }


    /**
    * @brief Get the name of the user who last modified the trajectory.
    * @param name the string to fill with the name of the user,
    * memory must be allocated before.
    * @param max_len maximum char length of the string, i.e. how much memory has
    * been reserved for name. This includes \0 terminating character.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred (source string longer than destination string).
    */
    tng_function_status getLastUserName(char *name, const int max_len)
    {
        return status = tng_last_user_name_get(traj,name,max_len);
    }


    /**
    * @brief Set the name of the user who last modified the trajectory.
    * @param new_name is a string containing the wanted name.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status setLastUserName(const char *new_name)
    {
        return status = tng_last_user_name_set(traj,new_name);
    }



    /**
    * @brief Get the name of the computer used when creating the trajectory.
    * @param name the string to fill with the name of the computer,
    * memory must be allocated before.
    * @param max_len maximum char length of the string, i.e. how much memory has
    * been reserved for name. This includes \0 terminating character.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred (source string longer than destination string).
    */
    tng_function_status getFirstComputerName(char *name, const int max_len)
    {
        return status = tng_first_computer_name_get(traj, name, max_len);
    }


    /**
    * @brief Set the name of the computer used when creating the trajectory.
    * @param new_name is a string containing the wanted name.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status setFirstComputerName(const char *new_name)
    {
        return status = tng_first_computer_name_set(traj, new_name);
    }


    /**
    * @brief Get the name of the computer used when last modifying the trajectory.
    * @param name the string to fill with the name of the computer,
    * memory must be allocated before.
    * @param max_len maximum char length of the string, i.e. how much memory has
    * been reserved for name. This includes \0 terminating character.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred (source string longer than destination string).
    */
    tng_function_status getLastComputerName(char *name, const int max_len)
    {
        return status = tng_last_computer_name_get(traj,name,max_len);
    }


    /**
    * @brief Set the name of the computer used when last modifying the trajectory.
    * @param new_name is a string containing the wanted name.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status setLastComputerName(const char *new_name)
    {
        return status = tng_last_computer_name_set(traj,new_name);
    }


    /**
    * @brief Get the pgp_signature of the user creating the trajectory.
    * @param signature the string to fill with the signature,
    * memory must be allocated before.
    * @param max_len maximum char length of the string, i.e. how much memory has
    * been reserved for name. This includes \0 terminating character.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred (source string longer than destination string).
    */
    tng_function_status getFirstSignature(char *signature, const int max_len)
    {
        return status = tng_last_computer_name_get(traj, signature,max_len);
    }


    /**
    * @brief Set the pgp_signature of the user creating the trajectory.
    * @param signature is a string containing the pgp_signature.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status setFirstSignature(const char *signature)
    {
        return status = tng_first_signature_set(traj, signature);
    }


    /**
    * @brief Get the pgp_signature of the user last modifying the trajectory.
    * @param signature the string to fill with the signature,
    * memory must be allocated before.
    * @param max_len maximum char length of the string, i.e. how much memory has
    * been reserved for name. This includes \0 terminating character.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred (source string longer than destination string).
    */
    tng_function_status getLastSignature(char *signature, const int max_len)
    {
        return status = tng_first_signature_get(traj, signature, max_len);
    }


    /**
    * @brief Set the pgp_signature of the user last modifying the trajectory.
    * @param signature is a string containing the pgp_signature.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status setLastSignature(const char *signature)
    {
        return status = tng_last_signature_set(traj, signature);
    }


    /**
    * @brief Get the name of the forcefield used in the trajectory.
    * @param name the string to fill with the name of the forcefield,
    * memory must be allocated before.
    * @param max_len maximum char length of the string, i.e. how much memory has
    * been reserved for name. This includes \0 terminating character.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred (source string longer than destination string).
    */
    tng_function_status getForcefieldName(char *name, const int max_len)
    {
        return status = tng_last_signature_get(traj,name,max_len);
    }


    /**
    * @brief Set the name of the forcefield used in the trajectory.
    * @param new_name is a string containing the wanted name.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status setForcefieldName(const char *new_name)
    {
        return status = tng_forcefield_name_set(traj, new_name);
    }


    /**
    * @brief Get the medium stride length of the trajectory.
    * @param len is pointing to a value set to the stride length.
    * @return TNG_SUCCESS (0) if successful.
    */
    tng_function_status getMediumStrideLength(int64_t *len)
    {
        return status = tng_medium_stride_length_get(traj,len);
    }


    /**
    * @brief Set the medium stride length of the trajectory.
    * @param len is the wanted medium stride length.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred.
    */
    tng_function_status setMediumStrideLength(const int64_t len)
    {
        return status = tng_medium_stride_length_set(traj,len);
    }


    /**
    * @brief Get the long stride length of the trajectory.
    * @param len is pointing to a value set to the stride length.
    * @return TNG_SUCCESS (0) if successful.
    */
    tng_function_status getLongStrideLength(int64_t *len)
    {
        return status = tng_long_stride_length_get(traj, len);
    }


    /**
    * @brief Set the long stride length of the trajectory.
    * @param len is the wanted long stride length.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred.
    */
    tng_function_status setLongStrideLength(const int64_t len)
    {
        return status = tng_long_stride_length_set(traj,len);
    }


    /**
    * @brief Get the current time per frame of the trajectory.
    * @param len is pointing to a value set to the time per frame.
    * @return TNG_SUCCESS (0) if successful.
    */
    tng_function_status getTimePerFrame(double *time)
    {
        return status = tng_time_per_frame_get(traj, time);
    }


    /**
    * @brief Set the time per frame of the trajectory.
    * @param len is the new time per frame.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred.
    */
    tng_function_status setTimePerFrame(const double time)
    {
        return status = tng_time_per_frame_set(traj, time);
    }


    /**
    * @brief Get the length of the input file.
    * @param len is pointing to a value set to the file length.
    * @return TNG_SUCCESS (0) if successful.
    */
    tng_function_status getInputFileLen(int64_t *len)
    {
        return status = tng_input_file_len_get(traj, len);
    }


    /**
    * @brief Get the number of frames in the trajectory
    * @param n is pointing to a value set to the number of frames.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred (could not find last frame set).
    */
    tng_function_status getNumFrames(int64_t *n)
    {
        return status = tng_num_frames_get(traj, n);
    }

    /**
    * @brief Get the current number of particles.
    * @param n is pointing to a value set to the number of particles.
    * @details If variable number of particles are used this function will return
    * the number of particles in the current frame set.
    * @return TNG_SUCCESS (0) if successful.
    */
    tng_function_status getNumParticles(int64_t *n)
    {
        return status = tng_num_particles_get(traj, n);
    }




    /**
    * @brief Get the current total number of molecules.
    * @param n is pointing to a value set to the number of molecules.
    * @details If variable number of particles are used this function will return
    * the total number of molecules in the current frame set.
    * @return TNG_SUCCESS (0) if successful.
    */
    tng_function_status getNumMolecules(int64_t *n)
    {
        return status = tng_num_molecules_get(traj,n);
    }

    /**
    * @brief Get the exponential used for distances in the trajectory.
    * @param exp is pointing to a value set to the distance unit exponential.
    * @details Example: If the distances are specified in nm (default) exp is -9.
    * If the distances are specified in Å exp is -10.
    * @return TNG_SUCCESS (0) if successful.
    */
    tng_function_status getDistanceUnitExponential
                    (int64_t *exp)
    {
        return status = tng_distance_unit_exponential_get(traj, exp);
    }

    /**
    * @brief Set the exponential used for distances in the trajectory.
    * @param exp is the distance unit exponential to use.
    * @details Example: If the distances are specified in nm (default) exp is -9.
    * If the distances are specified in Å exp is -10.
    * @return TNG_SUCCESS (0) if successful.
    */
    tng_function_status setDistanceUnitExponential
                    (int64_t exp)
    {
        return status = tng_distance_unit_exponential_set(traj, exp);
    }


    /**
    * @brief Get the number of frames per frame set.
    * per frame set.
    * @param n is pointing to a value set to the number of frames per frame set.
    * @return TNG_SUCCESS (0) if successful.
    */
    tng_function_status getNumFramesPerFrameSet(int64_t *n)
    {
        return status = tng_num_frames_per_frame_set_get(traj,n);
    }

    /**
    * @brief Set the number of frames per frame set.
    * @param n is the number of frames per frame set.
    * @details This does not affect already existing frame sets. For
    * consistency the number of frames per frame set should be set
    * betfore creating any frame sets.
    * @return TNG_SUCCESS (0) if successful.
    */
    tng_function_status setNumFramesPerFrameSet(const int64_t n)
    {
        return status = tng_num_frames_per_frame_set_set(traj,n);
    }

    /**
    * @brief Get the number of frame sets.
    * @param n is pointing to a value set to the number of frame sets.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status getNumFrameSets(int64_t *n)
    {
        return status = tng_num_frame_sets_get(traj, n);
    }


    /**
    * @brief Get the current trajectory frame set.
    * @param frame_set_p will be set to point at the memory position of
    * the found frame set.
    * @return TNG_SUCCESS (0) if successful.
    */
    tng_function_status getCurrentFrameSet(tng_trajectory_frame_set_t *frame_set_p)
    {
        return status = tng_current_frame_set_get(traj, frame_set_p);
    }


    /**
    * @brief Find the requested frame set number.
    * @param nr is the frame set number to search for.
    * @details tng_data->current_trajectory_frame_set will contain the
    * found trajectory if successful.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status findFrameSetNr(const int64_t nr)
    {
        return status = tng_frame_set_nr_find(traj,nr);
    }


    /**
    * @brief Find the frame set containing a specific frame.
    * @param frame is the frame number to search for.
    * @details tng_data->current_trajectory_frame_set will contain the
    * found trajectory if successful.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status findFrameSetOfFrame(const int64_t frame)
    {
        return status = tng_frame_set_of_frame_find(traj, frame);
    }


    /**
    * @brief Get the file position of the next frame set in the input file.
    * @param frame_set is the frame set of which to get the position of the
    * following frame set.
    * @param pos is pointing to a value set to the file position.
    * @return TNG_SUCCESS (0) if successful.
    */
    tng_function_status getNextFrameSetFilePos
        (const tng_trajectory_frame_set_t frame_set,int64_t *pos)
    {
        return status = tng_frame_set_next_frame_set_file_pos_get(traj,frame_set,pos );
    }

    /**
    * @brief Get the file position of the previous frame set in the input file.
    * @param frame_set is the frame set of which to get the position of the
    * previous frame set.
    * @param pos is pointing to a value set to the file position.
    * @return TNG_SUCCESS (0) if successful.
    */
    tng_function_status getPrevFrameSetFilePos
        (const tng_trajectory_frame_set_t frame_set,int64_t *pos)
    {
        return status = tng_frame_set_prev_frame_set_file_pos_get(traj, frame_set, pos);
    }


    /**
    * @brief Get the first and last frames of the frame set.
    * @param frame_set is the frame set of which to get the frame range.
    * @param first_frame is set to the first frame of the frame set.
    * @param last_frame is set to the last frame of the frame set.
    * @return TNG_SUCCESS (0) if successful.
    */
    tng_function_status getFrameSetFrameRange
        (const tng_trajectory_frame_set_t frame_set,
        int64_t *first_frame,
        int64_t *last_frame)
    {
        return status = tng_frame_set_frame_range_get(traj,frame_set, first_frame, last_frame);
    }


    /**
    * @brief Get the molecume name of real particle number (number in mol system).
    * @param nr is the real number of the particle in the molecular system.
    * @param name is a string, which is set to the name of the molecule. Memory
    * must be reserved beforehand.
    * @param max_len is the maximum length of name.
    * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
    * has occured.
    */
    tng_function_status getMoleculeNameOfParticleNr
        (const int64_t nr,char *name,int max_len)
    {
        return status = tng_molecule_name_of_particle_nr_get(traj,nr,name,max_len);
    }


    /**
    * @brief Get the chain name of real particle number (number in mol system).
    * @param nr is the real number of the particle in the molecular system.
    * @param name is a string, which is set to the name of the chain. Memory
    * must be reserved beforehand.
    * @param max_len is the maximum length of name.
    * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
    * has occured.
    */
    tng_function_status getChainNameOfParticleNr
        (const int64_t nr,char *name,int max_len)
    {
        return status = tng_chain_name_of_particle_nr_get(traj, nr, name, max_len);
    }


    /**
    * @brief Get the residue name of real particle number (number in mol system).
    * @param nr is the real number of the particle in the molecular system.
    * @param name is a string, which is set to the name of the residue. Memory
    * must be reserved beforehand.
    * @param max_len is the maximum length of name.
    * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
    * has occured.
    */
    tng_function_status getResidueNameOfParticleNr
        (const int64_t nr,char *name,int max_len)
    {
        return status = tng_residue_name_of_particle_nr_get(traj,nr,name,max_len);
    }


    /**
    * @brief Get the atom name of real particle number (number in mol system).
    * @param nr is the real number of the particle in the molecular system.
    * @param name is a string, which is set to the name of the atom. Memory
    * must be reserved beforehand.
    * @param max_len is the maximum length of name.
    * @return TNG_SUCCESS (0) if successful or TNG_FAILURE (!) if a minor error
    * has occured.
    */
    tng_function_status getAtomNameOfParticleNr
        (const int64_t nr,char *name,int max_len)
    {
        return status = tng_atom_name_of_particle_nr_get(traj, nr,name,max_len);
    }


    /**
    * @brief Add a particle mapping table.
    * @details Each particle mapping table will be written as a separate block,
    * followed by the data blocks for the corresponding particles. In most cases
    * there is one particle mapping block for each thread writing the trajectory.
    * @details The mapping information is added to the currently active frame set
    * of tng_data
    * @param first_particle_number is the first particle number of this mapping
    * block.
    * @param n_particles is the number of particles in this mapping block.
    * @param mapping_table is a list of the real particle numbers (i.e. the numbers
    * used in the molecular system). The list is n_particles long.
    * @details mapping_table[0] is the real particle number of the first particle
    * in the following data blocks.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status addParticleMapping
        (const int64_t first_particle_number,
        const int64_t n_particles,
        const int64_t *mapping_table)
    {
        return status = tng_particle_mapping_add(traj,first_particle_number,n_particles,mapping_table );
    }


    /**
    * @brief Read the header blocks from the input_file of tng_data.
    * @details The trajectory blocks must be read separately and iteratively in chunks
    * to fit in memory.
    * @details tng_data->input_file_path specifies
    * which file to read from. If the file (input_file) is not open it will be
    * opened.
    * @param hash_mode is an option to decide whether to use the md5 hash or not.
    * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
    * compared to the md5 hash of the read contents to ensure valid data.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status readFileHeaders(const tng_hash_mode hash_mode)
    {
        return status = tng_file_headers_read(traj, hash_mode);
    }


    /**
    * @brief Write the header blocks to the output_file of tng_data.
    * @details The trajectory blocks must be written separately and iteratively in chunks
    * to fit in memory.
    * @details tng_data->output_file_path
    * specifies which file to write to. If the file (output_file) is not open it
    * will be opened.
    * @param hash_mode is an option to decide whether to use the md5 hash or not.
    * If hash_mode == TNG_USE_HASH an md5 hash for each header block will be generated.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status writeFileHeaders(const tng_hash_mode hash_mode)
    {
        return status = tng_file_headers_write(traj, hash_mode);
    }



    /**
    * @brief Read one (the next) block (of any kind) from the input_file of tng_data.
    * which file to read from. If the file (input_file) is not open it will be
    * opened.
    * @param block_data is a pointer to the struct which will be populated with the
    * data.
    * @details If block_data->input_file_pos > 0 it is the position from where the
    * reading starts otherwise it starts from the current position.
    * @param hash_mode is an option to decide whether to use the md5 hash or not.
    * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
    * compared to the md5 hash of the read contents to ensure valid data.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status readNextBlock(const tng_hash_mode hash_mode, tng_gen_block_t block_data)
    {
        return status = tng_block_read_next(traj,block_data, hash_mode);
    }



    /**
    * @brief Read one (the next) frame set, including mapping and related data blocks
    * from the input_file of tng_data.
    * which file to read from. If the file (input_file) is not open it will be
    * opened.
    * @param hash_mode is an option to decide whether to use the md5 hash or not.
    * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
    * compared to the md5 hash of the read contents to ensure valid data.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status readNextFrameSet(const tng_hash_mode hash_mode)
    {
        return status = tng_frame_set_read_next(traj, hash_mode);
    }


    /**
    * @brief Write one frame set, including mapping and related data blocks
    * to the output_file of tng_data.
    * @details  tng_data->output_file_path specifies
    * which file to write to. If the file (output_file) is not open it will be
    * opened.
    * @param hash_mode is an option to decide whether to use the md5 hash or not.
    * If hash_mode == TNG_USE_HASH an md5 hash for each header block will be generated.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status writeFrameSet(const tng_hash_mode hash_mode)
    {
        return status = tng_frame_set_write(traj, hash_mode);
    }


    /**
    * @brief Create and initialise a frame set.
    * @param first_frame is the first frame of the frame set.
    * @param n_frames is the number of frames in the frame set.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status newFrameSet(const int64_t first_frame,
        const int64_t n_frames)
    {
        return status =  tng_frame_set_new(traj, first_frame, n_frames);
    }


    /**
    * @brief Create and initialise a frame set with the time of the first frame
    * specified.
    * @param first_frame is the first frame of the frame set.
    * @param n_frames is the number of frames in the frame set.
    * @param first_frame_time is the time stamp of the first frame (in seconds).
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status newFrameSetWithTime
                (const int64_t first_frame,
                 const int64_t n_frames,
                 const double first_frame_time)
    {
        return status =  tng_frame_set_with_time_new(traj,
                                                     first_frame, n_frames,
                                                     first_frame_time);
    }


    /**
    * @brief Set the time stamp of the first frame of the current frame set.
    * @param first_frame_time is the time stamp of the first frame in the
    * frame set.
    * @return TNG_SUCCESS (0) if successful.
    */
    tng_function_status setTimeOfFirstFrameOfFrameSet
                    (const double first_frame_time)
    {
        return status = tng_frame_set_first_frame_time_set(traj,
                                                           first_frame_time);
    }

    /**
    * @brief Add a non-particle dependent data block.
    * @param id is the block ID of the block to add.
    * @param block_name is a descriptive name of the block to add
    * @param datatype is the datatype of the data in the block (e.g. int/float)
    * @param block_type_flag indicates if this is a non-trajectory block (added
    * directly to tng_data) or if it is a trajectory block (added to the
    * frame set)
    * @param n_frames is the number of frames of the data block (automatically
    * set to 1 if adding a non-trajectory data block)
    * @param n_values_per_frame is how many values a stored each frame (e.g. 9
    * for a box shape block)
    * @param stride_length is how many frames are between each entry in the
    * data block
    * @param codec_id is the ID of the codec to compress the data.
    * @param new_data is an array of data values to add.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status addDataBlock(const int64_t id,
        const char *block_name,
        const tng_data_type datatype,
        const tng_block_type block_type_flag,
        int64_t n_frames,
        const int64_t n_values_per_frame,
        const int64_t stride_length,
        const int64_t codec_id,
        void *new_data)
    {
        return status = tng_data_block_add(traj, id,block_name,
            datatype,block_type_flag, n_frames,
            n_values_per_frame, stride_length,
            codec_id, new_data);
    }


    /**
    * @brief Add a particle dependent data block.
    * @param id is the block ID of the block to add.
    * @param block_name is a descriptive name of the block to add
    * @param datatype is the datatype of the data in the block (e.g. int/float)
    * @param block_type_flag indicates if this is a non-trajectory block (added
    * directly to tng_data) or if it is a trajectory block (added to the
    * frame set)
    * @param n_frames is the number of frames of the data block (automatically
    * set to 1 if adding a non-trajectory data block)
    * @param n_values_per_frame is how many values a stored each frame (e.g. 9
    * for a box shape block)
    * @param stride_length is how many frames are between each entry in the
    * data block
    * @param first_particle_number is the number of the first particle stored
    * in this data block
    * @param n_particles is the number of particles stored in this data block
    * @param codec_id is the ID of the codec to compress the data.
    * @param new_data is an array of data values to add.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status addParticleDataBlock(const int64_t id,
        const char *block_name,
        const tng_data_type datatype,
        const tng_block_type block_type_flag,
        int64_t n_frames,
        const int64_t n_values_per_frame,
        const int64_t stride_length,
        const int64_t first_particle_number,
        const int64_t n_particles,
        const int64_t codec_id,
        void *new_data)
    {
        return status = tng_particle_data_block_add(traj,id,    block_name,
            datatype, block_type_flag, n_frames,n_values_per_frame,
            stride_length,first_particle_number,n_particles,
            codec_id, new_data);
    }


    /**
    * @brief Write data of one trajectory frame to the output_file of tng_data.
    * @param frame_nr is the index number of the frame to write.
    * @param block_id is the ID of the data block to write the data to.
    * @param data is an array of data to write. The length of the array should
    * equal n_values_per_frame.
    * @param hash_mode is an option to decide whether to use the md5 hash or not.
    * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
    * compared to the md5 hash of the read contents to ensure valid data.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status writeFrameData(const int64_t frame_nr,
        const int64_t block_id,
        const void *data,
        const tng_hash_mode hash_mode)
    {
        return status = tng_frame_data_write(traj,frame_nr,block_id,data,hash_mode);
    }


    /**
    * @brief Write particle data of one trajectory frame to the output_file of
    * tng_data.
    * @param frame_nr is the index number of the frame to write.
    * @param block_id is the ID of the data block to write the data to.
    * @param val_first_particle is the number of the first particle in the data
    * array.
    * @param val_n_particles is the number of particles in the data array.
    * @param data is a 1D-array of data to write. The length of the array should
    * equal n_particles * n_values_per_frame.
    * @param hash_mode is an option to decide whether to use the md5 hash or not.
    * If hash_mode == TNG_USE_HASH the written md5 hash in the file will be
    * compared to the md5 hash of the read contents to ensure valid data.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status writeFrameParticleData(const int64_t frame_nr,
        const int64_t block_id,
        const int64_t val_first_particle,
        const int64_t val_n_particles,
        const void *data,
        const tng_hash_mode hash_mode)
    {
        return status = tng_frame_particle_data_write(traj,frame_nr,block_id,val_first_particle,val_n_particles,data,hash_mode);
    }


    /**
    * @brief Free data is an array of values (2D).
    * @param values is the 2D array to free and will be set to 0 afterwards.
    * @param n_frames is the number of frames in the data array.
    * @param n_values_per_frame is the number of values per frame in the data array.
    * @param type is the data type of the data in the array (e.g. int/float/char).
    * @return TNG_SUCCESS (0) if successful.
    */
    tng_function_status freeDataValues(union data_values **values,
        const int64_t n_frames,
        const int64_t n_values_per_frame,
        const tng_data_type type)
    {
        return status = tng_data_values_free(traj, values, n_frames,n_values_per_frame,type);
    }


    /**
    * @brief Free data is an array of values (3D).
    * @param values is the array to free and will be set to 0 afterwards.
    * @param n_frames is the number of frames in the data array.
    * @param n_particles is the number of particles in the data array.
    * @param n_values_per_frame is the number of values per frame in the data array.
    * @param type is the data type of the data in the array (e.g. int/float/char).
    * @return TNG_SUCCESS (0) if successful.
    */
    tng_function_status freeParticleDataValues(union data_values ***values,
        const int64_t n_frames,
        const int64_t n_particles,
        const int64_t n_values_per_frame,
        const tng_data_type type)
    {
        return status = tng_particle_data_values_free(traj, values,n_frames,n_particles,n_values_per_frame,type);
    }


    /**
    * @brief Retrieve non-particle data, from the last read frame set. Obsolete!
    * which file to read from. If the file (input_file) is not open it will be
    * opened.
    * @param block_id is the id number of the particle data block to read.
    * @param values is a pointer to a 2-dimensional array (memory unallocated), which
    * will be filled with data. The array will be sized
    * (n_frames * n_values_per_frame).
    * Since ***values is allocated in this function it is the callers
    * responsibility to free the memory.
    * @param n_frames is set to the number of particles in the returned data. This is
    * needed to properly reach and/or free the data afterwards.
    * @param n_values_per_frame is set to the number of values per frame in the data.
    * This is needed to properly reach and/or free the data afterwards.
    * @param type is set to the data type of the data in the array.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status getData(const int64_t block_id,
        union data_values ***values,
        int64_t *n_frames,
        int64_t *n_values_per_frame,
        char *type)
    {
        return status = tng_data_get(traj, block_id, values, n_frames,
                                     n_values_per_frame, type);
    }

    /**
    * @brief Retrieve a vector (1D array) of non-particle data, from the last read frame set.
    * @param block_id is the id number of the particle data block to read.
    * @param values is a pointer to a 1-dimensional array (memory unallocated), which
    * will be filled with data. The length of the array will be (n_frames * n_values_per_frame).
    * Since **values is allocated in this function it is the callers
    * responsibility to free the memory.
    * @param n_frames is set to the number of particles in the returned data. This is
    * needed to properly reach and/or free the data afterwards.
    * @param stride_length is set to the stride length of the returned data.
    * @param n_values_per_frame is set to the number of values per frame in the data.
    * This is needed to properly reach and/or free the data afterwards.
    * @param type is set to the data type of the data in the array.
    * @details This does only work for numerical (int, float, double) data.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status getDataVector
                (const int64_t block_id,
                 void **values,
                 int64_t *n_frames,
                 int64_t *stride_length,
                 int64_t *n_values_per_frame,
                 char *type)
    {
        return status = tng_data_vector_get(traj, block_id, values, n_frames,
                                            stride_length, n_values_per_frame,
                                            type);
    }

    /**
    * @brief Read and retrieve non-particle data, in a specific interval. Obsolete!
    * which file to read from. If the file (input_file) is not open it will be
    * opened.
    * @param block_id is the id number of the particle data block to read.
    * @param start_frame_nr is the index number of the first frame to read.
    * @param end_frame_nr is the index number of the last frame to read.
    * @param hash_mode is an option to decide whether to use the md5 hash or not.
    * If hash_mode == TNG_USE_HASH the md5 hash in the file will be
    * compared to the md5 hash of the read contents to ensure valid data.
    * @param values is a pointer to a 2-dimensional array (memory unallocated), which
    * will be filled with data. The array will be sized
    * (n_frames * n_values_per_frame).
    * Since ***values is allocated in this function it is the callers
    * responsibility to free the memory.
    * @param n_values_per_frame is set to the number of values per frame in the data.
    * This is needed to properly reach and/or free the data afterwards.
    * @param type is set to the data type of the data in the array.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status getDataInterval(const int64_t block_id,
        const int64_t start_frame_nr,
        const int64_t end_frame_nr,
        const tng_hash_mode hash_mode,
        union data_values ***values,
        int64_t *n_values_per_frame,
        char *type)
    {
        return status = tng_data_interval_get(traj, block_id, start_frame_nr,
                                              end_frame_nr, hash_mode, values,
                                              n_values_per_frame, type);
    }


    /**
    * @brief Read and retrieve a vector (1D array) of non-particle data,
    * in a specific interval.
    * @param block_id is the id number of the particle data block to read.
    * @param start_frame_nr is the index number of the first frame to read.
    * @param end_frame_nr is the index number of the last frame to read.
    * @param hash_mode is an option to decide whether to use the md5 hash or not.
    * If hash_mode == TNG_USE_HASH the md5 hash in the file will be
    * compared to the md5 hash of the read contents to ensure valid data.
    * @param values is a pointer to a 1-dimensional array (memory unallocated), which
    * will be filled with data. The length of the array will be (n_frames * n_values_per_frame).
    * Since **values is allocated in this function it is the callers
    * responsibility to free the memory.
    * @param stride_length is set to the stride length (writing frequency) of
    * the data.
    * @param n_values_per_frame is set to the number of values per frame in the data.
    * This is needed to properly reach and/or free the data afterwards.
    * @param type is set to the data type of the data in the array.
    * @details This does only work for numerical (int, float, double) data.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status getDataVectorInterval
                (const int64_t block_id,
                 const int64_t start_frame_nr,
                 const int64_t end_frame_nr,
                 const char hash_mode,
                 void **values,
                 int64_t *stride_length,
                 int64_t *n_values_per_frame,
                 char *type)
    {
        return status = tng_data_vector_interval_get(traj, block_id,
                                                     start_frame_nr,
                                                     end_frame_nr,
                                                     hash_mode, values,
                                                     stride_length,
                                                     n_values_per_frame,
                                                     type);
    }

    /**
    * @brief Retrieve particle data, from the last read frame set. Obsolete!
    * @details The particle dimension of the returned values array is translated
    * to real particle numbering, i.e. the numbering of the actual molecular
    * system.
    * specifies which file to read from. If the file (input_file) is not open it
    * will be opened.
    * @param block_id is the id number of the particle data block to read.
    * @param values is a pointer to a 3-dimensional array (memory unallocated), which
    * will be filled with data. The array will be sized
    * (n_frames * n_particles * n_values_per_frame).
    * Since ****values is allocated in this function it is the callers
    * responsibility to free the memory.
    * @param n_frames is set to the number of particles in the returned data. This is
    * needed to properly reach and/or free the data afterwards.
    * @param n_particles is set to the number of particles in the returned data. This is
    * needed to properly reach and/or free the data afterwards.
    * @param n_values_per_frame is set to the number of values per frame in the data.
    * This is needed to properly reach and/or free the data afterwards.
    * @param type is set to the data type of the data in the array.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status getParticleData(const int64_t block_id,
        union data_values ****values,
        int64_t *n_frames,
        int64_t *n_particles,
        int64_t *n_values_per_frame,
        char *type)
    {
        return status = (tng_particle_data_get(traj, block_id, values, n_frames,
            n_particles, n_values_per_frame, type));
    }


    /**
    * @brief Retrieve a vector (1D array) of particle data, from the last read frame set.
    * @details The particle dimension of the returned values array is translated
    * to real particle numbering, i.e. the numbering of the actual molecular
    * system.
    * @param block_id is the id number of the particle data block to read.
    * @param values is a pointer to a 1-dimensional array (memory unallocated), which
    * will be filled with data. The length of the array will be
    * (n_frames * n_particles * n_values_per_frame).
    * Since **values is allocated in this function it is the callers
    * responsibility to free the memory.
    * @param n_frames is set to the number of frames in the returned data. This is
    * needed to properly reach and/or free the data afterwards.
    * @param stride_length is set to the stride length of the returned data.
    * @param n_particles is set to the number of particles in the returned data. This is
    * needed to properly reach and/or free the data afterwards.
    * @param n_values_per_frame is set to the number of values per frame in the data.
    * This is needed to properly reach and/or free the data afterwards.
    * @param type is set to the data type of the data in the array.
    * @details This does only work for numerical (int, float, double) data.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status getParticleDataVector
                (const int64_t block_id,
                 void **values,
                 int64_t *n_frames,
                 int64_t *stride_length,
                 int64_t *n_particles,
                 int64_t *n_values_per_frame,
                 char *type)
    {
        return status = tng_particle_data_vector_get(traj, block_id,
                                                     values, n_frames,
                                                     stride_length,
                                                     n_particles,
                                                     n_values_per_frame, type);
    }


    /**
    * @brief Read and retrieve particle data, in a specific interval. Obsolete!
    * @details The particle dimension of the returned values array is translated
    * to real particle numbering, i.e. the numbering of the actual molecular
    * system.
    * @param block_id is the id number of the particle data block to read.
    * @param start_frame_nr is the index number of the first frame to read.
    * @param end_frame_nr is the index number of the last frame to read.
    * @param hash_mode is an option to decide whether to use the md5 hash or not.
    * If hash_mode == TNG_USE_HASH the md5 hash in the file will be
    * compared to the md5 hash of the read contents to ensure valid data.
    * @param values is a pointer to a 3-dimensional array (memory unallocated), which
    * will be filled with data. The array will be sized
    * (n_frames * n_particles * n_values_per_frame).
    * Since ****values is allocated in this function it is the callers
    * responsibility to free the memory.
    * @param n_particles is set to the number of particles in the returned data. This is
    * needed to properly reach and/or free the data afterwards.
    * @param n_values_per_frame is set to the number of values per frame in the data.
    * This is needed to properly reach and/or free the data afterwards.
    * @param type is set to the data type of the data in the array.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status getParticleDataInterval(const int64_t block_id,
        const int64_t start_frame_nr,
        const int64_t end_frame_nr,
        const tng_hash_mode hash_mode,
        union data_values ****values,
        int64_t *n_particles,
        int64_t *n_values_per_frame,
        char *type)
    {
        return status = (tng_particle_data_interval_get(traj, block_id, start_frame_nr,
            end_frame_nr, hash_mode, values,
            n_particles, n_values_per_frame,
            type));
    }


    /**
    * @brief Read and retrieve a vector (1D array) particle data, in a
    * specific interval.
    * @details The particle dimension of the returned values array is translated
    * to real particle numbering, i.e. the numbering of the actual molecular
    * system.
    * @param block_id is the id number of the particle data block to read.
    * @param start_frame_nr is the index number of the first frame to read.
    * @param end_frame_nr is the index number of the last frame to read.
    * @param hash_mode is an option to decide whether to use the md5 hash or not.
    * If hash_mode == TNG_USE_HASH the md5 hash in the file will be
    * compared to the md5 hash of the read contents to ensure valid data.
    * @param values is a pointer to a 1-dimensional array (memory unallocated), which
    * will be filled with data. The length of the array will be
    * (n_frames * n_particles * n_values_per_frame).
    * Since **values is allocated in this function it is the callers
    * responsibility to free the memory.
    * @param stride_length is set to the stride length (writing frequency) of
    * the data.
    * @param n_particles is set to the number of particles in the returned data. This is
    * needed to properly reach and/or free the data afterwards.
    * @param n_values_per_frame is set to the number of values per frame in the data.
    * This is needed to properly reach and/or free the data afterwards.
    * @param type is set to the data type of the data in the array.
    * @details This does only work for numerical (int, float, double) data.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status getParticleDataVectorInterval
                (const int64_t block_id,
                 const int64_t start_frame_nr,
                 const int64_t end_frame_nr,
                 const tng_hash_mode hash_mode,
                 void **values,
                 int64_t *n_particles,
                 int64_t *stride_length,
                 int64_t *n_values_per_frame,
                 char *type)
    {
        return status = tng_particle_data_vector_interval_get(traj, block_id,
                                                              start_frame_nr,
                                                              end_frame_nr,
                                                              hash_mode,
                                                              values,
                                                              n_particles,
                                                              stride_length,
                                                              n_values_per_frame,
                                                              type);
    }


    /** @brief Get the date and time of initial file creation in ISO format (string).
    *  @param time is a pointer to the string in which the date will be stored. Memory
    must be reserved beforehand.
    * @return TNG_SUCCESS (0) if successful.
    */
    tng_function_status getTimeStr(char *time)
    {
        return status = tng_time_get_str(traj, time);
    }


};





class Molecule
{
private:

    tng_molecule_t mol;
    Trajectory * traj;
    tng_function_status status;
public:
    tng_function_status addChain(const char *name, Chain *chain);
    tng_function_status findChain(const char *name, int64_t id, Chain *chain);
    friend class Trajectory;
    //Constructor
    Molecule(Trajectory * trajectory)
    {
        traj = trajectory;

        //status = tng_molecule_init(traj->traj,mol);
    }
    /**
     *@Dose nothing, use ~TngMolecule()
    */
    ~Molecule()
    {
        status = tng_molecule_destroy(traj->traj,mol);
    }
        //! Status
    tng_function_status getStatus()
    { return status; }


    /**
    * @brief Set the name of a molecule.
    * @param new_name is a string containing the wanted name.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status setName(const char *new_name)
    {
        return status = tng_molecule_name_set(traj->traj,mol,new_name);
    }

    /**
    * @brief Get the count of a molecule.
    * @param cnt is a pointer to the variable to be populated with the count.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status getCnt(int64_t *cnt)
    {
        return status = tng_molecule_cnt_get(traj->traj,mol,cnt);
    }

    /**
    * @brief Set the count of a molecule.
    * @param cnt is the number of instances of this molecule.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if a minor error
    * has occurred or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status setCnt(int64_t cnt)
    {
        return status = tng_molecule_cnt_set(traj->traj,mol,cnt);
    }

};

    tng_function_status Trajectory::addMolecule(const char *name, Molecule_t molecule)
{
    return status = tng_molecule_add(traj,name, &molecule->mol);
}

    tng_function_status Trajectory::addMoleculeWithId
                (const char *name,
                 const int64_t id,
                 Molecule_t molecule)
{
    return status = tng_molecule_w_id_add(traj, name, id, &molecule->mol);
}

/**
* @brief Find a molecule.
* @param tng_data is the trajectory data container containing the molecule.
* @param name is a string containing the name of the molecule. If name is empty
* only id will be used for finding the molecule.
* @param id is the id of the molecule to look for. If id is -1 only the name of
* the molecule will be used for finding the molecule.
* @param molecule is a pointer to the molecule if it was found - otherwise 0.
* @return TNG_SUCCESS (0) if the molecule is found or TNG_FAILURE (1) if the
* molecule is not found.
* @details If name is an empty string and id is -1 the first molecule will be
* found.
*/
tng_function_status Trajectory::findMolecule
                (const char *name,
                int64_t id,
                Molecule_t molecule)
{
    return status = tng_molecule_find(traj, name, id,
                            &molecule->mol);
}


class Atom
{
private:
    tng_atom_t atom;
    Trajectory * traj;
    tng_function_status status;
public:
    friend class Residue;
    //constructor
    Atom(Trajectory * trajectory)
    {
        traj = trajectory;
    }
    //deonstructor
    /**
     *@Dose nothing, use ~TngMolecule()
    */
        ~Atom()
    {
        //delete atom;
    }
            //! Status
    tng_function_status getStatus()
    { return status; }
    /**
    * @brief Set the name of an atom.
    * @param new_name is a string containing the wanted name.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status setName(const char *new_name)
    {
        return status = tng_atom_name_set(traj->traj, atom , new_name);
    }

    /**
    * @param new_type is a string containing the atom type.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status setType(const char *new_type)
    {
        return status = tng_atom_type_set(traj->traj, atom, new_type);
    }
};

class Residue
{
    private:
    tng_residue_t residue;
    Trajectory * traj;
    tng_function_status status;
public:
    friend class Chain;
    //constructor
    Residue(Trajectory  * trajectory)
    {
        traj = trajectory;
    }
    //deonstructor
    /**
     *@Dose nothing, use ~TngMolecule()
    */
        ~Residue()
    {
        //delete residue;
    }
    //! Status
    tng_function_status getStatus()
    { return status; }
    /**
    * @brief Set the name of a residue.
    * @param residue is the residue to rename.
    * @param new_name is a string containing the wanted name.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status setName(const char *new_name)
    {
        return status = tng_residue_name_set(traj->traj, residue,new_name);
    }

    /**
    * @brief Add an atom to a residue.
    * @param atom_name is a string containing the name of the atom.
    * @param atom_type is a string containing the atom type of the atom.
    * @param atom is a pointer to the newly created atom.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status addAtom(const char *atom_name,
        const char *atom_type,
        Atom * atom)
    {
        return status = tng_residue_atom_add(traj->traj, residue, atom_name,
                                             atom_type, &atom->atom);
    }


    /**
    * @brief Add an atom with a specific ID to a residue.
    * @param atom_name is a string containing the name of the atom.
    * @param atom_type is a string containing the atom type of the atom.
    * @param id is the ID of the created atom.
    * @param atom is a pointer to the newly created atom.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if the ID could
    * not be set properly or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status addAtomWithId
                (const char *atom_name,
                 const char *atom_type,
                 const int64_t id,
                 Atom * atom)
    {
        return status = tng_residue_atom_w_id_add(traj->traj, residue,
                                                  atom_name, atom_type,
                                                  id, &atom->atom);
    }

};

class Chain
{
    private:
    tng_chain_t chain;
    Trajectory * traj;
    tng_function_status status;
public:
    friend class Molecule;
    //constructor
    Chain(Trajectory * trajectory)
    {
        traj = trajectory;
    }
    //deonstructor
    /**
     *@Dose nothing, use ~TngMolecule()
    */
        ~Chain()
    {
        //delete chain;
    }
    //! Status
    tng_function_status getStatus()
    { return status; }
    /**
    * @brief Set the name of a chain.
    * @param new_name is a string containing the wanted name.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status setName(const char *new_name)
    {
        return status  = tng_chain_name_set(traj->traj, chain, new_name);
    }


    /**
    * @brief Find a residue in a chain.
    * @param name is a string containing the name of the residue.
    * @param id is the id of the residue to find. If id == -1 the first residue
    * that matches the specified name will be found.
    * @param residue is a pointer to the residue if it was found - otherwise 0.
    * @return TNG_SUCCESS (0) if the residue is found or TNG_FAILURE (1) if the
    * residue is not found.
    * @details If name is an empty string the first residue will be found.
    */
    tng_function_status findResidue
                (const char *name,
                 int64_t id,
                 Residue *residue)
    {
        return status = tng_chain_residue_find(traj->traj, chain, name,
                                               id, &residue->residue);
    }

    /**
    * @brief Add a residue to a chain.
    * @param name is a string containing the name of the residue.
    * @param residue is a pointer to the newly created residue.
    * @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
    * error has occured.
    */
    tng_function_status addResidue(const char *name,
        Residue * residue)
    {
        return status = tng_chain_residue_add(traj->traj, chain,
                                              name, &residue->residue);
    }

    /**
    * @brief Add a residue with a specific ID to a chain.
    * @param name is a string containing the name of the residue.
    * @param id is the ID of the created residue.
    * @param residue is a pointer to the newly created residue.
    * @return TNG_SUCCESS (0) if successful, TNG_FAILURE (1) if the ID could
    * not be set properly or TNG_CRITICAL (2) if a major error has occured.
    */
    tng_function_status addResidueWithId
                (const char *name,
                 const int64_t id,
                 Residue * residue)
    {
        return status = tng_chain_residue_w_id_add(traj->traj, chain,
                                                   name, id, &residue->residue);
    }
};

/**
* @brief Add a chain to a molecule.
* @param name is a string containing the name of the chain.
* @param chain s a pointer to the newly created chain.
* @return TNG_SUCCESS (0) if successful or TNG_CRITICAL (2) if a major
* error has occured.
*/
tng_function_status Molecule::addChain(const char *name, Chain *chain)
{
    return status = tng_molecule_chain_add(traj->traj,mol,name,&chain->chain);
}

/**
* @brief Find a chain in a molecule.
* @param name is a string containing the name of the chain. If name is empty
* only id will be used for finding the chain.
* @param id is the id of the chain to look for. If id is -1 only the name of
* the chain will be used for finding the chain.
* @param chain is a pointer to the chain if it was found - otherwise 0.
* @return TNG_SUCCESS (0) if the chain is found or TNG_FAILURE (1) if the
* chain is not found.
* @details If name is an empty string and id is -1 the first chain will be
* found.
*/
tng_function_status Molecule::findChain
                (const char *name,
                int64_t id,
                Chain *chain)
{
    return status = tng_molecule_chain_find(traj->traj, mol, name, id,
                                            &chain->chain);
}

}
#endif
contact: Jan Huwald // Impressum