Pagina Principale   Moduli   Lista dei namespaces   Gerarchia delle classi   Lista in ordine alfabetico   Lista dei composti   Lista dei files   Membri dei namespaces   Membri dei composti   Membri dei files   Esempi  

/home/fbassi/devel/projects/reti/Object/Object.cc

Vai alla documentazione di questo file.
00001 /*
00002  *    FBFS Distributed Object Repository
00003  *    Copyright (C) 2001 Francesco V. Bassi
00004  *
00005  *    This program is free software; you can redistribute it and/or modify
00006  *    it under the terms of the GNU General Public License as published by
00007  *    the Free Software Foundation; either version 2 of the License, or
00008  *    (at your option) any later version.
00009  *
00010  *    This program is distributed in the hope that it will be useful,
00011  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *    GNU General Public License for more details.
00014  *
00015  *    You should have received a copy of the GNU General Public License
00016  *    along with this program; if not, write to the Free Software
00017  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 
00020 #include "Object.h"
00021 
00022 #include <stdio.h>
00023 
00029 string fbfs::Object::Obj2string(const Obj &obj) {
00030     string s;
00031     const octet_sequence &seq = obj.value;
00032     for(int i=0; i<seq.length(); i++)
00033         s += seq[i];
00034     return s;
00035 };
00036 
00037 // Controllare bene. Forse è sbagliato il MM
00038 fbfs::Obj *fbfs::Object::string2Obj(const string &s) {
00039     Obj *obj = new Obj();
00040     obj->value = octet_sequence( s.length(), s.length(), (CORBA::Octet *) s.c_str() );
00041     return obj;
00042 };
00043 
00044 string fbfs::Object::Obj_prop2string(const Obj_prop &obj) {
00045     char buf[64];
00046     sprintf(buf, "%d:%d:%d", obj.type, obj.value_a, obj.value_b);
00047     return string(buf);
00048 };
00049 
00050 fbfs::Obj_prop fbfs::Object::string2Obj_prop(const string &s) {
00051     const char * cs = s.c_str();
00052     Obj_prop obj;
00053     sscanf(cs, "%d:%d:%d", &obj.type, &obj.value_a, &obj.value_b);
00054     return obj;
00055 };
00056 
00057 string fbfs::Object::Obj_id2string(const Obj_id &obj) {
00058     string s(obj.name);
00059     return s;
00060 };
00061 
00062 fbfs::Obj_id fbfs::Object::string2Obj_id(const string &s) {
00063     Obj_id obj;
00064     obj.name = (const char *) s.c_str();
00065     return obj;
00066 };
00067 
00068 string fbfs::Object::Obj_ts2string(const Obj_ts &obj) {
00069     char buf[32];
00070     sprintf(buf, "%d", obj.time);
00071     return string(buf);
00072 };
00073 
00074 fbfs::Obj_ts fbfs::Object::string2Obj_ts(const string &s) {
00075     const char * cs = s.c_str();
00076     Obj_ts obj;
00077     sscanf(cs, "%d", &obj.time);
00078     return obj;
00079 };
00080 
00081 bool fbfs::Object::cmp_ts( const Obj_ts &uno, const Obj_ts &due) {
00082     return uno.time == due.time;
00083 };

Generato il Thu Feb 15 13:24:56 2001 per A Simple Distributed Object Repository with CORBA & C++. da doxygen1.2.3 scritto da Dimitri van Heesch, © 1997-2000