]> Creatis software - bbtk.git/blob - packages/std/src/bbstdRandomString.cxx
#2745 BBTK Bug New Normal Not compiling windows stdRandomString 1. time function...
[bbtk.git] / packages / std / src / bbstdRandomString.cxx
1 //===== 
2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
3 //===== 
4 #include "bbstdRandomString.h"
5 #include "bbstdPackage.h"
6 #include "time.h"
7
8 namespace bbstd
9 {
10
11 BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,RandomString)
12 BBTK_BLACK_BOX_IMPLEMENTATION(RandomString,bbtk::AtomicBlackBox);
13 //===== 
14 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
15 //===== 
16
17
18 static const char alphanum[] =
19 "0123456789"
20 //"!@#$%^&*"
21 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
22 "abcdefghijklmnopqrstuvwxyz";
23
24 /*
25 char genRandom()
26 {
27 }
28 */
29
30 void RandomString::Process()
31 {
32
33 // THE MAIN PROCESSING METHOD BODY
34 //   Here we simply set the input 'In' value to the output 'Out'
35 //   And print out the output value
36 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
37 //    void bbSet{Input|Output}NAME(const TYPE&)
38 //    const TYPE& bbGet{Input|Output}NAME() const 
39 //    Where :
40 //    * NAME is the name of the input/output
41 //      (the one provided in the attribute 'name' of the tag 'input')
42 //    * TYPE is the C++ type of the input/output
43 //      (the one provided in the attribute 'type' of the tag 'input')
44 //    bbSetOutputOut( bbGetInputIn() );
45 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
46
47     int stringLength = sizeof(alphanum) - 1;
48     srand(time(NULL));
49     std::string STR;
50     for(unsigned int i = 0; i < 8; ++i)
51     {
52             STR += alphanum[rand() % stringLength];
53     }
54          bbSetOutputOut( STR );
55 printf("EED RandomString::Process randomString=%s\n",STR.c_str());
56 }
57
58 //===== 
59 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
60 //===== 
61 void RandomString::bbUserSetDefaultValues()
62 {
63
64 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
65 //    Here we initialize the input 'In' to 0
66 //   bbSetInputIn(0);
67   
68 }
69 //===== 
70 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
71 //===== 
72 void RandomString::bbUserInitializeProcessing()
73 {
74
75 //  THE INITIALIZATION METHOD BODY :
76 //    Here does nothing 
77 //    but this is where you should allocate the internal/output pointers 
78 //    if any 
79
80   
81 }
82 //===== 
83 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
84 //===== 
85 void RandomString::bbUserFinalizeProcessing()
86 {
87
88 //  THE FINALIZATION METHOD BODY :
89 //    Here does nothing 
90 //    but this is where you should desallocate the internal/output pointers 
91 //    if any
92   
93 }
94 }
95 // EO namespace bbstd
96
97