Changeset 11228 for trunk/FACT++/src
- Timestamp:
- 07/01/11 08:30:53 (13 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/argv.cc
r10707 r11228 4 4 5 5 using namespace std; 6 7 template<class T,class S> 8 std::ostream &operator<<(std::ostream &out, const pair<T,S> &f) 9 { 10 out << f.first << "|" << f.second; 11 return out; 12 } 13 template<class T, class S> 14 std::istream &operator>>(std::istream &in, pair<T,S> &f) 15 { 16 char c; 17 in >> f.first; 18 in >> c; 19 if (c!=':') 20 return in; 21 in >> f.second; 22 return in; 23 } 24 25 typedef pair<int,int> mytype; 26 27 28 //Source is OutputStreamable, meaning that an operator<< is defined 29 // that takes a std::ostream or std::wostream object on the left hand side 30 // and an instance of the argument type on the right. 31 32 // Target is InputStreamable, meaning that an operator>> is defined that 33 // takes a std::istream or std::wistream object on the left hand side and 34 // an instance of the result type on the right. 35 36 //Target is CopyConstructible [20.1.3]. 37 //Target is DefaultConstructible, meaning that it is possible to default-initialize an object of that type [8.5, 20.1.4]. 6 38 7 39 // -------------------------------------------------------------------------- … … 82 114 ("switch", po_switch(), "include path") 83 115 ("bool", var<bool>()->implicit_value(true), "include path") 116 ("mytype", var<mytype>(), "include path") 84 117 ; 85 118 … … 172 205 cout << conf.Has("switch") << " " << conf.Get<bool>("switch") << endl; 173 206 cout << conf.Has("bool") << " " << conf.Get<bool>("bool") << endl; 207 cout << conf.Has("mytype") << " " << conf.Get<mytype>("mytype") << endl; 174 208 175 209 return 0; -
trunk/FACT++/src/fad.cc
r11209 r11228 89 89 fHeader.fTriggerId = fHeader.fEventCounter; 90 90 fHeader.fTimeStamp = uint32_t((Time(Time::utc).UnixTime()-fStartTime)*10000); 91 fHeader.fFreqRefClock = 997+rand()/(RAND_MAX/7); 91 92 92 93 for (int i=0; i<FAD::kNumTemp; i++) -
trunk/FACT++/src/logtime.cc
r10348 r11228 6 6 #include <iostream> 7 7 8 #include "DimDescriptionService.h" 9 8 10 int main(int, const char **) 9 11 { 10 // We could use putenv to make the Configure class change the value...12 // We could use putenv to make the Configure class change the value... 11 13 setenv("DIM_DNS_NODE", "localhost", 0); 12 14 … … 14 16 DimServer::start("TIME"); 15 17 18 usleep(2000000); 19 20 DimServer::stop(); 21 22 return 0; 23 16 24 // Some info on the console 17 25 std::cout << "Offering TIME/MESSAGE...\n" << std::endl; 26 27 short s; 28 int i; 29 long long ll; 30 float f; 31 DimDescribedService servt("TIME/TEST", "O:1;I:1;C", 32 "This is my test command|Char[c]:This is a char| Int This is an int|String[s]:This is a string"); 33 34 DimDescribedService servs("TIME/SHORT", s, "[a]"); 35 DimDescribedService servx("TIME/LONGLONG", ll, "|: This is my long long"); 36 DimDescribedService servi("TIME/INT", i, "|MyInt [ mi ] "); 37 DimDescribedService servf("TIME/FLOAT", f, "| MyFloat : This is my float"); 38 DimDescribedService servc("TIME/TIME", const_cast<char*>(""), "|MyTime[T]:This is my time"); 39 40 DimCommand cmd("TIME/CMD", "I:2;F:2"); 41 42 DimDescriptionService des("TIME/CMD", "|range[addr]:From DAC to DAC|values[DAC]:DAC values to be set"); 43 44 { 45 Time t0; 18 46 19 47 // Setup a DimService called TIME/MESSAGE … … 23 51 // Send current time 24 52 msg.Message(Time().GetAsStr()); 53 // servx.Update(); 54 /* 55 servs.updateService(); 56 servi.updateService(); 57 servf.updateService(); 58 servc.updateService(); 59 */ 60 // wait approximately one second 61 usleep(100000); 25 62 26 // wait approximately one second 27 usleep(1000000);63 // if (t0.UnixTime()-Time().UnixTime()<-5) 64 // break; 28 65 } 66 } 67 68 DimDescribedService servxx("TIME/XXX", const_cast<char*>(""), "|MyTime[T]:This is my time"); 69 usleep(10000000); 29 70 30 71 return 0; -
trunk/FACT++/src/tools.cc
r10429 r11228 12 12 #include <stdarg.h> 13 13 14 #include <boost/filesystem.hpp> 15 14 16 using namespace std; 15 17 /* 16 18 string Tools::Format(const char *fmt, va_list &ap) 17 19 { … … 49 51 return str; 50 52 } 53 */ 51 54 52 55 // -------------------------------------------------------------------------- … … 54 57 //! This is a static helper to remove leading and trailing whitespaces. 55 58 //! 56 //! @param buf59 //! @param str 57 60 //! a pointer to the char array from which the whitespaces should be 58 61 //! removed … … 73 76 return str.substr(start, end-start+1); 74 77 } 78 79 // -------------------------------------------------------------------------- 80 // 81 //! Splits a string of the form [SERVER/]COMMAND[ arguments] 82 //! into SERVER, COMMAND and arguments. 83 //! 84 //! @param str 85 //! string to be splitted 86 //! 87 //! @returns 88 //! a vector<string> with three components. Depending on what is existing 89 //! in the string some of the components might be empty. 90 //! 91 /* 92 vector<string> Split(std::string str) 93 { 94 const size_t p0 = str.find_first_of('/'); 95 96 size_t p1 = str.find_first_of(' '); 97 98 vector<string> v(3); 99 100 // string starts with SERVER/COMMAND[ arguments] 101 if (p0<p1) 102 { 103 // SERVER 104 v[0] = str.substr(0, p0); 105 106 // COMMAND[ arguments) 107 str = str.substr(p0+1); 108 p1 = str.find_first_of(' '); 109 } 110 111 // String is of the form: COMMAND[ arguments] 112 113 // COMMAND 114 v[1] = str.substr(0, p1); 115 116 // Has arguments 117 if (p1!=string::npos) 118 v[2] = str.substr(p1+1); 119 120 return v; 121 } 122 */ -
trunk/FACT++/src/tools.h
r10429 r11228 1 1 #include <string> 2 #include <vector> 2 3 3 4 namespace Tools 4 5 { 5 std::string Format(const char *fmt, va_list &ap);6 std::string Form(const char *fmt, ...);6 // std::string Format(const char *fmt, va_list &ap); 7 // std::string Form(const char *fmt, ...); 7 8 std::string Trim(const std::string &str); 8 9 }
Note:
See TracChangeset
for help on using the changeset viewer.